Inquiry Regarding Implementation of the EdDSA Gadget in Circuit Design #1098
-
Greetings Community, I am currently grappling with the integration of the EdDSA gadget into our circuit design and would greatly appreciate some expert guidance on resolving a couple of challenges I have encountered. Firstly, I am inquiring about the most efficient method to extract a subarray representing the public key from a certificate. Specifically, I am looking to incorporate a certificate byte into the circuit as an array of frontend variables. Despite possessing the index at which the public key begins, I am struggling to efficiently retrieve the subarray required for EdDSA signature verification. Any insights or best practices on how to address this issue would be invaluable. Secondly, assuming the successful resolution of the first challenge, I am faced with the task of converting an array of frontend variables into a format compatible with the EdDSA gadget. Below is a snippet illustrating the attempted solution for reference: `func extractPublicKey(certificate []byte, SubjectPublicKeyStart, SubjectPublicKeyEnd int) gnark_eddsa.PublicKey {
}` would be immensely grateful for any expert advice and guidance on these matters. Thank you in advance for your support and insights. Best regards, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi, Regarding 1), the approach could be either to use a lookup table or a mux for retrieving the public key based on some query variable. Have a look at the
You can have a look at a hackathon project I did a few years ago: https://github.com/ritave/eIDAS-bridge/tree/main/snark (particularly here), but adapting to EdDSA public key format. |
Beta Was this translation helpful? Give feedback.
You are right - this obvious compression would indeed allow to find several inputs which "hash" to the same frontend.Variable. A solution is to use a more secure hash function - either a binary hash (a la sha2/keccak) or algebraic hash (MiMC, Poseidon etc.). But keep in mind that algebraic hashes takes as inputs also
frontend.Variable
so you should split your long certificates into smaller chunks (32 bytes etc depending on the scalar field).With binary hash it is a little simpler (as it is quite similar to what is done natively without ZKs), see https://github.com/ritave/eIDAS-bridge/blob/main/snark/circuits/circuit.go#L149-L170 for the in-circuit implementation and https://github.com/ri…