- “InvalidCurveAttack”. the json says “The point of the public key is not on the curve.” – shouldn’t we have these? (How is this different from “InvalidPublic”? I assume the keys in case of “InvalidCurveAttack” are on some other curve.
You’re right – we should have these. We changed it so that we’re no longer skipping InvalidCurveAttack
test vectors.
What is “InvalidEncoding”?
We are now including this test case.
- “WrongCurve”: I really don’t understand the JSON here. For example, test case 492 says: “public key has invalid point of order 2 on secp256r1. The point of the public key is a valid on secp256k1. “, but then says “invalid”?! Do you know what they have in mind?
All these 20 cases of WrongCurve have a public key whose ASN.1 representation carries an OID for a different curve (not secp256k1). None of the libsecp256k1 code parses this ASN.1 structure so we are not including these in the test cases.
In that specific case (tcId 492) they encode public key bytes that in secp256r1 coincide with a point of order 2 but in secp256k1 is a valid point (is in the (prime) group). We are just skipping this since this confusion is at an abstraction level higher than libsecp256k1. Again, none of the libsecp256k1 code parses this ASN.1 where the confusion (may) happen.
“UnnamendCurve”: Have you tried these? If we reject correctly, let’s just include them?
These are now included.
test case 511 has “public key of order 3” with “WeakPublicKey”, “InvalidPublic”, “UnnamedCurve”. How can it be invalid and at the same time have an order?
I guess their definition of invalid here is “does not lie in the proper subgroup”. This is consistent with the SEC (see §3.2.2.1 step 4 of https://www.secg.org/sec1-v2.pdf - ensures that the order or the point is large).
We are now skipping tcID 496, 497, 502, 503, 504, 505, 507. All these public keys have a custom ASN.1 encoding that explicitly encodes some curve parameters (including the order). Again, libsecp256k1 never parses these so we don’t care about these. In the tests we skip them.
For example, tcId 496 has the following public key:
0openssl asn1parse -in 496.bin -i -inform DR -dump
1 0:d=0 hl=4 l= 307 cons: SEQUENCE
2 4:d=1 hl=3 l= 236 cons: SEQUENCE
3 7:d=2 hl=2 l= 7 prim: OBJECT :id-ecPublicKey
4 16:d=2 hl=3 l= 224 cons: SEQUENCE
5 19:d=3 hl=2 l= 1 prim: INTEGER :01
6 22:d=3 hl=2 l= 44 cons: SEQUENCE
7 24:d=4 hl=2 l= 7 prim: OBJECT :prime-field
8 33:d=4 hl=2 l= 33 prim: INTEGER :FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F
9 68:d=3 hl=2 l= 68 cons: SEQUENCE
10 70:d=4 hl=2 l= 32 prim: OCTET STRING
11 0000 - 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
12 0010 - 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
13 104:d=4 hl=2 l= 32 prim: OCTET STRING
14 0000 - 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
15 0010 - 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 07 ................
16 138:d=3 hl=2 l= 65 prim: OCTET STRING
17 0000 - 04 79 be 66 7e f9 dc bb-ac 55 a0 62 95 ce 87 0b .y.f~....U.b....
18 0010 - 07 02 9b fc db 2d ce 28-d9 59 f2 81 5b 16 f8 17 .....-.(.Y..[...
19 0020 - 98 48 3a da 77 26 a3 c4-65 5d a4 fb fc 0e 11 08 .H:.w&..e]......
20 0030 - a8 fd 17 b4 48 a6 85 54-19 9c 47 d0 8f fb 10 d4 ....H..T..G.....
21 0040 - b8 .
22 205:d=3 hl=2 l= 33 prim: INTEGER :-FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141
23 240:d=3 hl=2 l= 1 prim: INTEGER :01
24 243:d=1 hl=2 l= 66 prim: BIT STRING
25 0000 - 00 04 49 c2 48 ed c6 59-e1 84 82 b7 10 57 48 a4 ..I.H..Y.....WH.
26 0010 - b9 5d 3a 46 95 2a 5b a7-2d a0 d7 02 dc 97 a6 4e .]:F.*[.-......N
27 0020 - 99 79 9d 8c ff 7a 5c 4b-92 5e 43 60 ec e2 5c cf .y...z\K.^C`..\.
28 0030 - 30 7d 7a 9a 70 63 28 6b-bd 16 ef 64 c6 5f 54 67 0}z.pc(k...d._Tg
29 0040 - 57 e2
For reference this is the ASN.1 encoding:
0xxd 496.bin
100000000: 3082 0133 3081 ec06 072a 8648 ce3d 0201 0..30....*.H.=..
200000010: 3081 e002 0101 302c 0607 2a86 48ce 3d01 0.....0,..*.H.=.
300000020: 0102 2100 ffff ffff ffff ffff ffff ffff ..!.............
400000030: ffff ffff ffff ffff ffff ffff ffff fffe ................
500000040: ffff fc2f 3044 0420 0000 0000 0000 0000 .../0D. ........
600000050: 0000 0000 0000 0000 0000 0000 0000 0000 ................
700000060: 0000 0000 0000 0000 0420 0000 0000 0000 ......... ......
800000070: 0000 0000 0000 0000 0000 0000 0000 0000 ................
900000080: 0000 0000 0000 0000 0007 0441 0479 be66 ...........A.y.f
1000000090: 7ef9 dcbb ac55 a062 95ce 870b 0702 9bfc ~....U.b........
11000000a0: db2d ce28 d959 f281 5b16 f817 9848 3ada .-.(.Y..[....H:.
12000000b0: 7726 a3c4 655d a4fb fc0e 1108 a8fd 17b4 w&..e]..........
13000000c0: 48a6 8554 199c 47d0 8ffb 10d4 b802 21ff H..T..G.......!.
14000000d0: 0000 0000 0000 0000 0000 0000 0000 0001 ................
15000000e0: 4551 2319 50b7 5fc4 402d a173 2fc9 bebf EQ#.P._.@-.s/...
16000000f0: 0201 0103 4200 0449 c248 edc6 59e1 8482 ....B..I.H..Y...
1700000100: b710 5748 a4b9 5d3a 4695 2a5b a72d a0d7 ..WH..]:F.*[.-..
1800000110: 02dc 97a6 4e99 799d 8cff 7a5c 4b92 5e43 ....N.y...z\K.^C
1900000120: 60ec e25c cf30 7d7a 9a70 6328 6bbd 16ef `..\.0}z.pc(k...
2000000130: 64c6 5f54 6757 e2 d._TgW.
Here the order of the curve is encoded as explicit parameter (which is the “wrong” order): -115792089237316195423570985008687907852837564279074904382605163141518161494337 or -FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141.
All other skipped cases are analogous.