}
// trim a scalar for scalar multiplication
-static void trim_scalar(u8 trimmed[32], const u8 scalar[32])
+static void trim_scalar(u8 scalar[32])
{
- COPY(trimmed, scalar, 32);
- trimmed[ 0] &= 248;
- trimmed[31] &= 127;
- trimmed[31] |= 64;
+ scalar[ 0] &= 248;
+ scalar[31] &= 127;
+ scalar[31] |= 64;
}
// get bit from scalar at position i
{
// restrict the possible scalar values
u8 e[32];
- trim_scalar(e, your_secret_key);
+ COPY(e, your_secret_key, 32);
+ trim_scalar(e);
scalarmult(raw_shared_secret, e, their_public_key, 255);
WIPE_BUFFER(e);
}
{
u8 a[64];
hash->hash(a, secret_key, 32);
- trim_scalar(a, a);
+ trim_scalar(a);
ge A;
ge_scalarmult_base(&A, a);
ge_tobytes(public_key, &A);
u8 *a = ctx->buf;
u8 *prefix = ctx->buf + 32;
ctx->hash->hash(a, secret_key, 32);
- trim_scalar(a, a);
+ trim_scalar(a);
if (public_key == 0) {
crypto_sign_public_key_custom_hash(ctx->pk, secret_key, ctx->hash);
0x94, 0x14, 0x56, 0x3b, 0x4b, 0xa4, 0x47, 0x0f, };
// separate the main factor & the cofactor of the scalar
u8 scalar[32];
- trim_scalar(scalar, secret_key);
+ COPY(scalar, secret_key, 32);
+ trim_scalar(scalar);
// Separate the main factor and the cofactor
//
{
u8 scalar[32];
ge pk;
- trim_scalar(scalar, secret_key);
+ COPY(scalar, secret_key, 32);
+ trim_scalar(scalar);
ge_scalarmult_base(&pk, scalar);
// Select low order point
0xfffffffe, 0xffffffff, 0xffffffff, 0x0fffffff,};
u8 scalar[32];
- trim_scalar(scalar, private_key);
+ COPY(scalar, private_key, 32);
+ trim_scalar(scalar);
// Convert the scalar in Montgomery form
// m_scl = scalar * 2^256 (modulo L)