Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/bulletproof_aggregated.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ int secp256k1_bulletproof_ipa_compress_step(const secp256k1_context *ctx,
* ux is the fixed IPA binding scalar.
*
* It MUST be derived exactly once from:
* ux = H(commit_inp || <a,b>)
* ux = H(domain || commit_inp || <a,b>)
*
* and reused consistently throughout the IPA:
* - L/R cross-term construction
Expand Down Expand Up @@ -712,6 +712,8 @@ int derive_ipa_binding_challenge(const secp256k1_context *ctx,
/* 2. Hash */
if (EVP_DigestInit_ex(mdctx, EVP_sha256(), NULL) != 1)
goto cleanup;
if (EVP_DigestUpdate(mdctx, "MPT_BULLETPROOF_IPA", 19) != 1)
goto cleanup;
if (EVP_DigestUpdate(mdctx, hash_input, 2 * kMPT_SCALAR_SIZE) != 1)
goto cleanup;
if (EVP_DigestFinal_ex(mdctx, hash_output, NULL) != 1)
Expand All @@ -732,7 +734,7 @@ int derive_ipa_binding_challenge(const secp256k1_context *ctx,
}

/**
* Derive u = H(last_challenge || L || R) reduced to a valid scalar.
* Derive u = H(domain || last_challenge || L || R) reduced to a valid scalar.
* IMPORTANT: use the SAME exact logic in verifier.
*/

Expand Down Expand Up @@ -764,6 +766,8 @@ int derive_ipa_round_challenge(

if (EVP_DigestInit_ex(mdctx, EVP_sha256(), NULL) != 1)
goto cleanup;
if (EVP_DigestUpdate(mdctx, "MPT_BULLETPROOF_IPA", 19) != 1)
goto cleanup;
if (EVP_DigestUpdate(mdctx, last_challenge, kMPT_SCALAR_SIZE) != 1)
goto cleanup;
if (EVP_DigestUpdate(mdctx, L_ser, kMPT_PUBKEY_SIZE) != 1)
Expand Down Expand Up @@ -1785,7 +1789,7 @@ int secp256k1_bulletproof_prove_agg(
}

/* ---- 9. Challenge x ---- */
/* x = H(A || S || y || z || T1 || T2 || context_id) */
/* x = H(domain || A || S || y || z || T1 || T2 || context_id) */
{
unsigned char A_ser[kMPT_PUBKEY_SIZE], S_ser[kMPT_PUBKEY_SIZE],
T1_ser[kMPT_PUBKEY_SIZE], T2_ser[kMPT_PUBKEY_SIZE];
Expand Down Expand Up @@ -1819,6 +1823,8 @@ int secp256k1_bulletproof_prove_agg(

if (EVP_DigestInit_ex(mdctx, EVP_sha256(), NULL) != 1)
goto fs_x_cleanup;
if (EVP_DigestUpdate(mdctx, "MPT_BULLETPROOF_RANGE", 21) != 1)
goto fs_x_cleanup;
if (EVP_DigestUpdate(mdctx, A_ser, kMPT_PUBKEY_SIZE) != 1)
goto fs_x_cleanup;
if (EVP_DigestUpdate(mdctx, S_ser, kMPT_PUBKEY_SIZE) != 1)
Expand Down Expand Up @@ -2471,10 +2477,12 @@ int secp256k1_bulletproof_verify_agg(
scalar_vector_powers(ctx, (unsigned char (*)[kMPT_SCALAR_SIZE])y_inv_powers,
y_inv, n);

/* ---------------- x = H(A || S || y || z || T1 || T2 || context)
/* ---------------- x = H(domain || A || S || y || z || T1 || T2 || context)
* ---------------- */
if (EVP_DigestInit_ex(mdctx, EVP_sha256(), NULL) != 1)
goto fs_fail;
if (EVP_DigestUpdate(mdctx, "MPT_BULLETPROOF_RANGE", 21) != 1)
goto fs_fail;
if (EVP_DigestUpdate(mdctx, A_ser, kMPT_PUBKEY_SIZE) != 1)
goto fs_fail;
if (EVP_DigestUpdate(mdctx, S_ser, kMPT_PUBKEY_SIZE) != 1)
Expand Down
Loading