Implementation of batch ECDSA signatures in circom for the P-256 curve for the Nova proof system using Nova-Scotia.
These circuits are not audited, and this is not intended to be used as a library for production-grade applications.
This repository provides proof-of-concept implementations of ECDSA operations on the P-256 curve in circom using Nova-Scotia. These implementations are for demonstration purposes only.
circuits: Contains the signature aggregation circuit which is in accordance with Nova-Scotia's syntax. TheECDSAVerifyNoPubkeyCheck(n,k)function is imported from circom-ecdsa-p256 submodule.scripts: ContainsgenerateSampleSignature.tswhich generatesp256signatures, converts the bigint values to643-bitregister arrays and dumps it intosrc/data/batch.json.src: Includes themain.rsfile to generate & verify proofs using Nova proof system
Due to P256 curve having no cycles, and the nature of Ethereum precompiles, we use BigInt arithmetic from the original circom-ecdsa implementation instead of the efficient circom-ecdsa to take advantage of Nova's BN254/grumpkin cycle.
Make sure you have the following dependencies pre-installed
- Run
git submodule update --init --recursive - Run
yarnat the top level to install npm dependencies - Run
yarninside ofcircuits/circom-ecdsa-p256to install npm dependencies for thecircom-ecdsa-p256library. - Run
yarninside ofcircuits/circom-ecdsa-p256/circuits/circom-pairingto install npm dependencies for thecircom-pairinglibrary.
- Compile the circuits and generate the relevant
r1cs&wasmfiles
circom circuits/batch_ecdsa.circom --r1cs --sym --wasm- Move the
batch_ecdsa.r1csfile from the root tosrc/data/
mv batch_ecdsa.r1cs src/data- Move the
batch_ecdsa.wasmfile frombatch_ecdsa_jstosrc/data
mv batch_ecdsa_js/batch_ecdsa.wasm src/data/- Make sure you've generated the signatures using the script. The signatures are populated in
src/data/batch.json
ts-node scripts/generateSampleSignature.ts- Now to generate & verify a recursive proof, simply do
cargo run
The signature aggregator circuit is implemented in circuits/batch_ecdsa.circom.
- The circuit takes in a public input
step_in, auxillary inputsignaturesand outputstep_outin accordance with Nova-Scotia's syntax.
signal input step_in[m];
signal input signatures[N_SIGS][m];
signal output step_out[m];- The 256-bits input is chunked and represented as
kn-bits values wherekis6andnis43. TheECDSAVerifyNoPubkeyCheck(n,k)circuit takes in four inputs -r,s,msghash,pubkey[2]of which all the inputs are43-bit arrays. - Since Nova-Scotia (and Nova) does not support folding in 2D arrays, the inputs are represented as 1D arrays of length
5*k=5*6=30. - The
step_in&signaturesare then trandformed into 2D arrays to input values in theECDSAVerifyNoPubkeyCheck(n,k)circuit
All benchmarks were run on an
| verify 10 | verify 100 | verify 300 | verify | |
|---|---|---|---|---|
| Constraints | ? | ? | ? | ? |
| Loading r1cs | ? | ? | ? | ? |
| Public parameter generation | ? | ? | ? | ? |
| Proving time | ? | ? | ? | ? |
| Proof verification time | ? | ? | ? | ? |
- The circuit uses circom-ecdsa-p256 as submodule.
- The inspiration for this project is taken from nova-browser-ecdsa