Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Faster ECDSA verification #24

Open
Tracked by #23
Stentonian opened this issue Mar 5, 2024 · 3 comments
Open
Tracked by #23

Faster ECDSA verification #24

Stentonian opened this issue Mar 5, 2024 · 3 comments
Labels
priority:high Task is important and needs to get done asap research Involves reading up on stuff

Comments

@Stentonian
Copy link
Contributor

Stentonian commented Mar 5, 2024

https://hackmd.io/juvO0SxlSqWa2pTYDKCOcw?view=#Better-ECDSA-verification

@Stentonian Stentonian changed the title Faster ECDSA verification Research faster ECDSA verification Mar 5, 2024
@Stentonian Stentonian changed the title Research faster ECDSA verification Faster ECDSA verification Mar 5, 2024
@Stentonian Stentonian added research Involves reading up on stuff priority:high Task is important and needs to get done asap labels Mar 5, 2024
@Stentonian
Copy link
Contributor Author

Stentonian commented Jun 27, 2024

Research notes

There are 2 libraries to research: efficient-ecdsa & spartan-ecdsa

Here is a nice overview of ZK ECDSA, which mentions the above 2 libraries.

Efficient ECDSA

~160k R1CS constraints to verify a signature.

These guys use efficient-ecdsa https://github.com/bankisan/zkShield

Links:

Spartan ECDSA

Current best ECDSA verification perf, ~8k R1CS constraints.

These guys are using spartan-ecdsa: https://github.com/dmpierre/nova-browser-ecdsa

Links:

Other

Some good circom circuits for ecdsa & merkle tree things to do set membership (and non-membership) check: anonklub

ZKAttest: Ring and Group Signatures for existing ECDSA keys https://eprint.iacr.org/2021/1183.pdf

Aggregating secp256k1 ECDSA with Nova: https://hackmd.io/mArMuUx5TC2LEcYecc741Q

@Stentonian
Copy link
Contributor Author

Changing PoA to using spartan-ecdsa is going to be a lot of work because it is a different proving system. If we want to be able to snark recursion then we may have to do a lot of work because verifying a Spartan proof is not simple.

Using the older efficient-ecdsa circuits is a much simpler change. All we need to do is import the circuits and switch over, no need to change the proving system or main parallel/recursive workflow design. One potential issue is the large number of public inputs to the circuit (the pre-computes), which would make the g16 verifier inside layer 2 have an enormous number of constraints. But we can get around this my hashing the public inputs, having the hash be the public input, and then making the pre-computes be private inputs.

@Stentonian
Copy link
Contributor Author

Stentonian commented Jul 5, 2024

It doesn't make sense to use efficient-ecdsa circuits..

The circuits require pre-computing some values, and having those values be public inputs to the snark. They have to be public inputs so that they can be checked by the verifier.

We have to keep the number of public inputs small so that the recursion into layer 2 is still possible (many pub inputs => very large circuit size for verifying g16 proofs). The number of pre-computed values needed per signature is ~65k, so we absolutely cannot have these as public inputs. We could get around this by having them as private inputs, and then computing their hash inside the circuit. But unfortunately, this gives us more constraints than the original circuit, because there are so many values to hash.

See here for changes: https://github.com/silversixpence-crypto/zk-proof-of-assets/tree/stent/efficient-ecdsa

Number of constraints for 1 signature for layer 1 circuit:

  • Original circuit: ~1.5M
  • efficient-ecdsa + hashing of precomputes: ~2.7M

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority:high Task is important and needs to get done asap research Involves reading up on stuff
Projects
None yet
Development

No branches or pull requests

1 participant