mirror of
https://github.com/bitcoin/bips.git
synced 2026-11-16 19:48:35 +00:00
Add Sign test vectors with k2' = n and k2' = n + 1. Together they detect implementations that check the secret nonce values only for zero, that check k2' <= n instead of k2' < n, or that reduce k2' mod n before checking it for zero. No single value detects the last two: among values of at least n, checking k2' <= n accepts only n, while reducing first rejects only n. For k2' = n, the optional correctness check at the end of Sign also fails, because k2'*G is infinity, so this vector detects the k2' <= n mistake only in implementations that omit that check. Add NonceGen and DeterministicSign test vectors with a 256-byte message. They detect implementations that encode only the low byte of len(m); the longest message in the previous test vectors has 38 bytes. DeterministicSign needs its own vector because it encodes len(m) separately.
BIP327 test vectors
BIP327 specifies the length and number of the inputs of each algorithm, for example that each tweak is a 32-byte array and that there is one tweak mode for each tweak. The test vectors only contain inputs that meet these specifications. Since BIP327 does not specify how algorithms handle other inputs, such as a 31-byte tweak or a missing tweak mode, the test vectors do not test them.
A test vector should only be added if it detects a plausible implementation mistake that the other test vectors do not detect. The comment of the test vector names the mistake, for example "Detects implementations that set gacc to g instead of multiplying it by g".