Skip to content

bip-0327: add test vectors for cases no vector covers - #2329

Open
fametrano wants to merge 1 commit into
bitcoin:masterfrom
fametrano:bip327-vectors
Open

fametrano wants to merge 1 commit into
bitcoin:masterfrom
fametrano:bip327-vectors

Conversation

@fametrano

Copy link
Copy Markdown
Contributor

I implemented BIP327 independently in btclib-ecc (Python), and these are the cases my tests reach and the vectors do not. reference.py computes every new value, every new case is appended so no existing index changes, and btclib-ecc reproduces every case of the five changed files, with the same error messages.

  • det_sign: plain and x-only tweaks with a 38-byte message.
  • sign_verify: a 100-byte message; a single signer; a secnonce whose second half is zero; a secnonce generated for another signer's public key; fewer pubnonces than pubkeys at verification.
  • sig_agg: a single signer. gen_vectors_helper.py gains the case, so it still generates the file.
  • nonce_gen: an extra_in shorter than 32 bytes.
  • tweak: a 31-byte tweak; fewer is_xonly flags than tweaks.

One case I left out: a secnonce whose second half is 1. reference.py accepts it, so it is not an error case, and every valid sign_verify case signs with secnonces[0]. Adding it would need a change to reference.py, such as a secnonce index in the valid cases. Would you want that?

The changelog gets version 1.0.5.

Assisted-by: my usual tools (LLM, Internet, computer). Mistakes are mine.

New cases:
- one signer: nonce_agg of one nonce, sign, verify, sig_agg
- a 100-byte message
- a plain and an x-only tweak over a 38-byte message (det_sign)
- an extra_in shorter than 32 bytes
- a secnonce whose second half is zero
- a secnonce generated for another signer's public key
- fewer pubnonces than pubkeys at verify
- fewer is_xonly flags than tweaks
- a 31-byte tweak

reference.py computed every value. The sig_agg case is generated by
gen_vectors_helper.py, which now includes it.

Assisted-by: my usual tools (LLM, Internet, computer). Mistakes are mine.
Signed-off-by: Ferdinando Ametrano <ferdinando@ametrano.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant