git submodule update --init --recursive
python3 src/eddsa/generate.py <N>
populates keys/signature
with N random signatures to be used for testing.
More precisely, it:
- generates N random positive integers
v
- for each integer
v
produces a signature(R, S)
using a random key pair(sk, pk)
- each signature is represented as 6 binary strings in the following order:
- the integer signed
v
(in little-endian bit order) - x component of the public key
pk.x
(in little-endian bit order) - y component of the public key
pk.y
(in little-endian bit order) - x component of the point part of the signature
R.x
(in little-endian bit order) - y component of the point part of the signature
R.y
(in little-endian bit order) - scalar part of the signature
S
(in BIG-endian bit order, don't ask me why)
src/generator.cpp
- produces proving/verifying keys for the circuit for
N = 3
signatures - dumps the proving key to
keys/libsnark/pk
in libsnark format. It is used by libsnark proversrc/proover.cpp
- dumps the proving key to
keys/ethsnarks/vk.json
in ethsnarks format. It is used- to deploy the verifier contract, see
migrations/2_deploy_contracts.js
- to test the verifier contract, see
tests/TestVerifier.js
- to generate Solidity code using
ethsnarks.cli.vk2sol
- to deploy the verifier contract, see
- dumps the verifying key to
keys/libsnark/pk
. It is used by libsnark verifiersrc/verifier.cpp
src/prover.cpp
- reads proving key from
keys/libsnark/pk
- populates the circuit inputs with data from
keys/signature
- dumps the proof to
keys/libsnark/proof
in libsnark format. It can be verified with libsnark verifiersrc/verifier.cpp
- dumps the proof to ethsnarks/proof.json in ethsnarks format. It is used
- to test the verifier contract, see
tests/TestVerifier.js
- to generate Solidity code using
ethsnarks.cli.proof2sol
- to test the verifier contract, see
src/verifier.cpp
- is created to test proofs generated by the prover
- reads:
- the verifying key from
keys/libsnark/vk
- the proof from
keys/libsnark/proof
- the public keys (and median?[TODO]) from
keys/signature
to be used as public inputs
- the verifying key from
- and verifies the proof against the public inputs
TODO items:
- For MVP (n-of-n signature)
ethsnarks: bump solidity version, add proof.json export, and update the submodule- libff doesn't provide inequality operators for field elements, so the easiest way to find the median is to hint the prover with the median index from outside (currently it's hardcoded)
n = 3 is hardcoded in generator/proover/verifier- check that pk and vk match (were generated with the same trapdoor), add n and nonce to key dumps
- Circuit enhancements
- support m-of-n case. For that one should add a flag to eddsa gadget and condition some constraints on that flag
- add timestamps/rounds to the signatures
- improve signature gadget (security, circuit-friendly hash)
- Smart-Contract
- add public key management
- add public inputs packing
- General improvements
- CLI for generating a key pair, signing a particular integer, and verifying a signature
- shell script for an end-2-end test
- describe library dependencies (or better, provide a Docker image)
- introduce CI
- readable signatures file
- DEBUG profile
- document the circuit, measure performance
- measure gas consumption