feat: add BIP-340 Schnorr verification circuit with native secp256k1 CRT proving - #155
feat: add BIP-340 Schnorr verification circuit with native secp256k1 CRT proving#155jaromil wants to merge 1 commit into
Conversation
abhvious
left a comment
There was a problem hiding this comment.
can you also add a readme explaining the purpose, and the circuit metrics.
in addition # of gates, what is the depth and # of witnesses ?
|
Dear abhi, thanks for your prompt review! this is an holiday project so please consider I'll be a bit slow to answer. Just a heads up about the purpose of this circuit: I am trying to do a usable implementation of this paper: Improved Concurrent-Secure |
|
Added lib/circuits/bip340/README.md with the circuit boundary, backend, and test commands. The circuit has 26,802 wires, 41,443 quadratic terms, depth 9, and 2,301 private witness elements. |
|
We would like to incorporate this circuit into the repository. Would you be willing to make the following changes: (a) try to minimize the # of changes needed to support this circuit, e.g., do not include changes that are not necessary to convolution.h, etc. we intend to make the contrib dir a place where experimental, contributed circuits are kept -- i indeed also was interested in the blind-schnorr application from Georg, and more recently Ivan + students. I'm glad that you worked it out, but please give some more summary details on the performance, and in particular the design decisions that you made for selecting the primitives that Ivan uses to describe the scheme (e.g., the special commitment, etc). |
26cef17 to
b7f9066
Compare
… suite Add production-ready BIP-340 Schnorr signature verification: - Circuit (bip340_verify.h): proves s·G - e·P = R with x-only keys, double-and-add trace, canonical scalar range, point-on-curve, ry-bitness (256 gates), even-y parity (LSB-zero gate) - Witness generator (bip340_witness.h): full projective trace - CRT capacity guard (bip340_guard.h): rejects block_enc > 2^22 - 22-test suite: eval, 19-vector validation, ZK prover/verifier, adversarial soundness mutations, CRT parameter validation, multi-instance scaling, malformed-hex fixture hardening - Test fixtures: Bitcoin Core BIP-340 CSV vectors, generated .inc files, semantic golden facts JSON - Build integration: CMakeLists.txt, proofs.cmake, test wiring Circuit metrics: 26,802 wires, 41,443 quad terms, depth=9 add BIP-340 reference implementation with sumcheck circuit model Sage reference code for cross-validation of the C++ production circuit: - bip340.py: standalone BIP-340 verification using Sage EC arithmetic - bip340_circuit.py: simplified Sage circuit with ry-bitness and even-parity constraints, witness generation - sumcheck prover/verifier lifecycle test for the Sage circuit - Golden-fact tests comparing Sage vs checked-in JSON invariants - Test vector validation against all 19 Bitcoin Core vectors - Fixture generator (generate_bip340_vectors_inc.py) with strict upstream CSV header validation - Mypy type stubs for sage.all, EllipticCurve, FiniteRingElement - Runner script (run_bip340_sage_tests.sh)
|
@abhvious addressed all your last remarks, hope it suffices. [edit] just to be clear, this is not the blind-schnorr implementation of the construction by Della Monica & Visconti, which is way more complex and requires RPBSch + NIWI which I've implemented in Zenroom using the zkcc DSL to overcome its complexity. This is just what the README says and it is a useful primitive for that paper and other future developments. |
BIP-340 Schnorr signature verification circuit proved over the native secp256k1 base field using the CRT Reed-Solomon backend.
C++ circuit (lib/circuits/bip340/)
Proves the Schnorr relation s·G - e·P = R with x-only keys, covering:
Circuit metrics: 26,802 wires, 41,443 quad terms, depth=9
Test suite (22 tests)
Sage reference (docs/specs/code/)