perf,feat: groth16.ProvingKey implements BinaryDumper using gnark-crypto unsafe#1124
perf,feat: groth16.ProvingKey implements BinaryDumper using gnark-crypto unsafe#1124
Conversation
|
Considering a rename to |
|
Any security issues if we skip subgroup checks? I want to use
|
|
yes, you should do subgroup checks if you don't trust the source of the points you are reading. this method (ReadDump / WriteDump) is intended for scenarios where you store some points / key on a trusted destination / have other mechanism to verify integrity (checksum, ...). |
|
In the worst case, the prover read a malicious proving key, and generate an invalid proof. An honest verifier will detect the invalid proof and reject it. Soundness property of SNARK. It seems ok to skip subgroup checks in such case. |
Sister PR to Consensys/gnark-crypto#501 .
Essentially, addresses the issue of slow deserialization for (large) proving keys.
ReadFromandUnsafeReadFromcan take many seconds (if not minutes) due to subgroup checks, point decompression and "safe" point reconstruction (involve at least converting[]bytecanonical field elements into Montgomery repr).This PR introduces
pk.WriteDumpandpk.ReadDumpfor scenarios where want to minimize loading time, don't need portability (usesunsafe;pk.ReadDumpmust read a stream generated bypk.WriteDumpon a similar architecture: 32/64 bit little/big endian (most popular platforms these days are 64bits little endian)), and don't need to perform any sanity checks.A quick bench for a medium sized
groth16.ProvingKeyfor bls12-377; divides by 100x decoding time 🔥 (but since we useunsafewe are io bound, here we ... kind of benchmarkmemcopyfor 80% of the pk).