daimo-eth / p256-verifier

P256 signature verification solidity contract
https://p256.eth.limo
MIT License
147 stars 28 forks source link

test: Wycheproof vectors #4

Closed dcposch closed 10 months ago

dcposch commented 10 months ago

Left to do

socket-security[bot] commented 10 months ago

New dependencies detected. Learn more about Socket for GitHub ↗︎

Packages Version New capabilities Transitives Size Publisher
ts-node 10.9.1 filesystem, environment +17 42.6 MB cspotcode
typescript 5.2.2 filesystem +0 40.6 MB typescript-bot
@tsconfig/node20 20.1.2 None +0 2.5 kB typescript-deploys
cross-fetch 4.0.0 network +0 88.1 kB lquixada
@lapo/asn1js 1.2.4 None +0 251 kB lapo
dcposch commented 10 months ago

Loading 291 distinct (x,y,r,s,hash) from Wycheproof

Wycheproof doesn't just test P256, it also tests a bunch of cases that aren't relevant to us, including:

Ignoring those + deduplicating on the actual inputs to the precompile, we get 291 distinct vectors.

image
nalinbhardwaj commented 10 months ago

the two bugs discovered by the first batch of wycheproof are also described here: [1]: https://aaltodoc.aalto.fi/bitstream/handle/123456789/116317/master_Lomeli_Ramos_Angel_2022.pdf?sequence=1&isAllowed=y section 5.4.2

The fix was to be more defensive about points at infinity for both cases.

dcposch commented 10 months ago

291 vectors, 4 errors remaining

image