Repository navigation
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
Tested on be2bc19. I think Regarding your question about Notice what happens in If struct SignOptions {
int sighash_type{SIGHASH_DEFAULT};
std::optional<uint256> aux_rand{std::nullopt};
};and in const uint256 aux_rand = m_options.aux_rand.value_or(GetRandHash());
if (!key.SignSchnorr(*hash, sig, merkle_root, aux_rand)) return false;Then default transaction signing keeps fresh randomness, but MutableTransactionSignatureCreator creator_zero_aux(tx, txinpos, utxos[txinpos].nValue, &txdata, {.sighash_type = hashtype, .aux_rand = uint256{}});
std::vector<unsigned char> zero_aux_sig;
BOOST_CHECK(creator_zero_aux.CreateSchnorrSig(provider, zero_aux_sig, pubkey, nullptr, &merkle_root, SigVersion::TAPROOT));
BOOST_CHECK_EQUAL(HexStr(zero_aux_sig), expected);Verified this locally with |
MutableTransactionSignatureCreator::CreateSchnorrSig passed all-zero auxiliary data to SignSchnorr. BIP340 recommends fresh randomness there, for protection against fault injection and side-channel attacks. Pass GetRandHash() instead, unless the new SignOptions::aux_rand sets a fixed value. The BIP341 key path vectors were generated with zero auxiliary data. The test now sets aux_rand to zero to compare the creator's signature with the vectors, and checks that two signatures made with the default options differ. The script_sign fuzz target can now reach GetRandHash() through SignTransaction, so it seeds the global RNG like the other signing targets.
|
Done in 1f274ea, as you suggested: |
|
ACK 1f274ea Re-reviewed the commit. Cleanly addresses the test vector coupling by keeping |

Bitcoin Core signs Taproot inputs with all-zero BIP340 auxiliary data. BIP340 recommends fresh randomness there, as protection against fault injection and side-channel attacks. I made
CreateSchnorrSigpassGetRandHash()instead, unlessSignOptions::aux_randsets a fixed value.In the unit tests, only
script_tests/bip341_keypath_test_vectorsdepended on the zero value: the BIP341 vectors were made with zero auxiliary data. It now builds the signature creator withaux_randset to zero and compares its signature byte for byte with the vectors, then signs twice with default options and checks that the two signatures differ. IfCreateSchnorrSigignoresaux_rand, the vector check fails for all 7 key path inputs. The signing-related functional tests pass unchanged. Thescript_signfuzz target can now reachGetRandHash(), so it seeds the RNG like the other signing targets.I chose
GetRandHash()overGetStrongRandBytes(). Both draw from the same RNG, which is seeded with OS entropy at startup, so the output is unpredictable;GetRandHash()skips the OS callGetStrongRandBytes()makes on each draw. BIP340 says any non-repeating value increases protection against fault injection, and that no security property other than side-channel resistance depends on the quality of this randomness. In unit testsGetRandHash()follows the test seed, so the tests stay reproducible;GetStrongRandBytes()does not.Default signing is no longer deterministic.
SignOptions::aux_randsets a fixed auxiliary value where one is needed, as in the vector test; Yudis-bit suggested it.Fixes #31883.
Made with my usual tools: a computer, the Internet and an LLM. The mistakes, as usual, are all mine.