ApplyTweak multiplies gacc by g, which is -1 if an x-only tweak negates
the aggregate public key. In every previous tweak sequence, the product
of all values of g equals the last one. Add a test vector with two
x-only tweaks, of which only the first negates the aggregate public key.
It detects implementations that set gacc to g instead of multiplying it
by g.
PartialSigAgg adds e*g*tacc, where g is -1 if the aggregate public key Q
has an odd Y coordinate. In the previous PartialSigAgg test vectors,
tacc is 0 whenever Q has an odd Y coordinate. Add a test vector with a
plain tweak and an odd Q, generated by gen_vectors_helper.py. It detects
implementations that omit g.
The PartialSigVerify test vector with the partial signature n fails the
verification equation even without the range check. So it does not
detect implementations that omit the range check or that check s > n
instead of s >= n. Change the pubnonces of the test vector such that the
partial signature 0 is valid, keeping the aggregate nonce. Since
n*G = 0*G, the partial signature n then satisfies the verification
equation, and only the range check rejects it. The previous version of
the test vector detects no mistake that the new version does not detect,
so it is replaced rather than kept.
gen_vectors_helper.py computes the new pubnonces.
In the previous NonceGen test vectors, every rand_ consists of the byte
0F repeated 32 times, every present sk of the byte 02 repeated 32 times,
and every pk has an even Y coordinate. Add a test vector whose rand_ and
sk are not a repeated byte and whose pk has an odd Y coordinate. It
detects implementations that reverse the byte order of rand_ or sk, that
replace the first byte of pk with 02, or that use only the first byte of
rand_.
With the last mistake, two NonceGen invocations with the same other
arguments return the same secnonce with probability 1/256, although the
BIP requires that Sign is never executed twice with the same secnonce.
A public key and its negation have the same X coordinate, and their
compressed encodings differ only in the first byte. Add a Sign test
vector with a secnonce generated for the negation of the signer's public
key, and a KeyAgg test vector with a public key and its negation. They
detect implementations that compare public keys only by their X
coordinates, in the public key check of Sign, in GetSecondKey, or in
KeyAggCoeffInternal. Distinct public keys in the previous test vectors
also have distinct X coordinates.
The public key check in Sign ensures that the secret key provided to
Sign is determined when NonceGen is invoked. Comparing only X
coordinates determines the secret key only up to negation.
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.
Add Sign test vectors for a secnonce with k2' = 0 and for a secnonce
generated for a different public key. No previous test vector detected
an implementation that checks only k1', or one that omits the public
key check added in 1.0.0-rc.2.
Add test vectors for a single signer, a 4-byte extra_in, and plain and
x-only tweaks in DeterministicSign. They detect implementations that
reject a single signer, encode the length of extra_in as 32 whenever
extra_in is present, or treat every tweak in DeterministicSign as
x-only.
Add a README to the vectors directory. It states that the test vectors
only contain inputs whose length and number meet the specification of
BIP327, and that a test vector should only be added if it detects a
plausible implementation mistake that the other test vectors do not
detect. Name that mistake in the comment of each added test vector.
Co-authored-by: Ferdinando Ametrano <ferdinando@ametrano.net>
The valid vector "input eligibility: bare OP_2 script is not a segwit
v2 witness program" passed only because its "checks" field limited it
to the input eligibility check. Its only input, the bare OP_2, is not
eligible, so its silent payment output script cannot be derived and the
output scripts check fails.
Replace it with a vector that adds an eligible P2WPKH input carrying
the ECDH share and DLEQ proof. The bare OP_2 input keeps only
PSBT_IN_NON_WITNESS_UTXO, which the segwit version check reads, so the
vector still tests that bare OP_2 is not taken for a segwit v2 witness
program, with no "checks" field. The bare OP_2 input is unsigned, so the
vector is In Progress; add its row to the Valid PSBTs table at its
position in the JSON file.
Vector by @macgyver13.
This moves the anti-pre-mine commitment back into `pszTimestamp` and
keeps it as ASCII text, rather than using it as a fake public key. The
genesis transaction's output is replaced by an `OP_RETURN` to avoid
confusion over spendability. Using the `OP_RETURN` output and `nVersion`
rolling for additional nonce bits are explicitly allowed.
BIP352 scanning assumes consensus-valid transactions. These fixtures
have a Taproot control parity mismatch and ECDSA encodings without
a sighash byte.
Correct both sending and receiving copies. The DER lengths and R/S
stay unchanged. Append SIGHASH_ALL outside DER as an encoding
correction. Complete transaction signature validity remains outside
these input-only fixtures.
The 29 vectors pass the official reference runner before and after.
Expected outputs, addresses and shared secrets are unchanged.
Now PSBT_OUT_SP_V0_INFO provides labeled-spend public key not the base-spend
public key.
Modify test vector with labeled-spend key to the same recipient from:
two sp outputs - output 0 uses label=3 / output 1 uses label=1
to:
three sp outputs (same scan key) - output 0 uses label=1, outputs 1 and 2 uses label=2 (same spend key)
This vector excercises the BIP375 sorting outputs with same scan key properly.
The next commit will fix the validation logic and address this failing test.
bump ChangeLog to 0.1.3
"The PSBT_OUT_SP_V0_INFO should be serialized as a zero byte for the
version, followed by the 33 bytes of the scan key and then 33 bytes for
the spend key" names the field, and the field is 66 bytes: its table
entry is "<33 byte scan key> <33 byte spend key>", the test vectors carry
66, and the validator refuses anything else.
The sentence is in the Unique Identification section and was added with
it, so what it describes is the output script that stands in for a silent
payment output when building the unsigned transaction that identifies the
psbt -- 67 bytes there, and nothing about the field. Read as the field's
own serialization it contradicts the table, which is how it first read
here.
Only the wording changes.
In the "PSBT with invalid output witnessScript typed key" case, the
value of the PSBT_OUT_WITNESS_SCRIPT record no longer hashes to the
P2WSH program in the output's redeemScript: 65f0b3dd trimmed it to its
last six bytes while fixing a short read.
Re-encode the record as `02 0100 25 <script>`: the key stays one byte
too long, which is what the case tests, and the value is the original
37-byte script again. Same total length, same layout as the "invalid
output redeemScript typed key" case.