Repository navigation
feat(stm): Signer and Signature for SNARK Proof System - #3009
Conversation
1c17dc2 to
f7ebfd3
Compare
b15c64b to
3b20205
Compare
There was a problem hiding this comment.
Pull request overview
This PR implements SNARK proof system primitives for single signatures in the Mithril STM library, specifically adding a new SnarkProofSigner that generates Schnorr signatures with lottery checking, and integrating it into the existing Signer flow alongside the concatenation proof system.
Changes:
- Added
SnarkProofSigner<D>that generates unique Schnorr signatures over[merkle_root, message]and validates lottery eligibility (with placeholder lottery logic) - Extended
SingleSignatureto include optionalSingleSignatureForSnarkwhen thefuture_snarkfeature is enabled, with full serialization support (bytes and JSON) - Updated
Signer,Initializer, andAggregateVerificationKeyto support SNARK signing alongside concatenation, all gated behind thefuture_snarkfeature flag - Added deterministic golden tests for
SingleSignatureandSingleSignatureWithRegisteredPartycovering both proof systems
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| mithril-stm/src/proof_system/halo2_snark/signer.rs | New SnarkProofSigner implementation with signature creation and lottery checking (placeholder logic) |
| mithril-stm/src/proof_system/halo2_snark/single_signature.rs | SingleSignatureForSnark with verification logic against SNARK AVK |
| mithril-stm/src/proof_system/halo2_snark/aggregate_key.rs | AggregateVerificationKeyForSnark implementation using Merkle tree commitment |
| mithril-stm/src/protocol/participant/signer.rs | Extended Signer to optionally hold and use SnarkProofSigner when creating signatures |
| mithril-stm/src/protocol/participant/initializer.rs | Updated to generate Schnorr key pairs and create both concatenation and SNARK signers |
| mithril-stm/src/protocol/single_signature/signature.rs | Added optional snark_signature field with verification, serialization, and golden tests |
| mithril-stm/src/protocol/aggregate_signature/aggregate_key.rs | Added optional SNARK AVK field with getter method |
| mithril-stm/src/membership_commitment/merkle_tree/commitment.rs | Added build_snark_message to convert message and root to BaseFieldElement array |
| mithril-stm/tests/test_extensions/protocol_phase.rs | Updated verification calls to pass None for SNARK registration entry |
| mithril-stm/README.md | Updated example to include new None parameter in verify call |
| mithril-signer/src/services/single_signer.rs | Updated test to pass None for SNARK registration entry |
| mithril-common/src/protocol/multi_signer.rs | Updated verification to pass None for SNARK registration entry |
| mithril-common/src/entities/certificate.rs | Updated AVK construction to pass None for SNARK AVK |
Comments suppressed due to low confidence (2)
mithril-stm/src/proof_system/halo2_snark/aggregate_key.rs:16
- The
#[allow(dead_code)]attribute is not permitted in production code. This code is used when creating the aggregate verification key fromClosedKeyRegistration, so this directive should be removed.
// TODO: remove this allow dead_code directive when function is called or future_snark is activated
#[allow(dead_code)]
impl<D: MembershipDigest> AggregateVerificationKeyForSnark<D> {
mithril-stm/src/protocol/aggregate_signature/aggregate_key.rs:54
- The
PartialEqimplementation only compares theconcatenation_aggregate_verification_keyfield and does not compare thesnark_aggregate_verification_keyfield when thefuture_snarkfeature is enabled. This means twoAggregateVerificationKeyinstances with different SNARK AVKs would be considered equal, which is incorrect.
The implementation should compare both fields when future_snark is enabled to ensure correct equality semantics.
impl<D: MembershipDigest> PartialEq for AggregateVerificationKey<D> {
fn eq(&self, other: &Self) -> bool {
self.to_concatenation_aggregate_verification_key()
== other.to_concatenation_aggregate_verification_key()
}
}
dd26acf to
3ea16ac
Compare
hjeljeli32
left a comment
There was a problem hiding this comment.
The structure looks good and the design is clean. I left a few comments around alignment between STM and circuit:
- Merkle root encoding in build_snark_message
- DST usage and lottery verification
- Lottery index bound semantics (< m vs <= m)
damrobi
left a comment
There was a problem hiding this comment.
It looks good to me overall, I left a few comments on some compatibility problems we might have with the circuit currently.
78cf185 to
e232869
Compare
e232869 to
e642516
Compare
e642516 to
f07fec2
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 36 out of 36 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
mithril-stm/src/signature_scheme/unique_schnorr_signature/jubjub/poseidon_digest.rs:20
DOMAIN_SEPARATION_TAG_LOTTERYis annotated with#[allow(dead_code)]and a TODO. Since it is only used underfuture_snark, consider gating the constant with#[cfg(feature = "future_snark")](or otherwise ensuring it is referenced) so the allow + TODO can be removed and dead-code warnings still stay clean.
hjeljeli32
left a comment
There was a problem hiding this comment.
LGTM. I just left 2 minor comments about error handling.
Content
This PR includes:
SnarkProofSigner<D>) that generates unique Schnorr signatures and checks the lotterySingleSignatureForSnarktoSingleSignature, gated behindfuture_snarkfeature, with full serialization (bytes + JSON) supportSignerflow:create_single_signaturenow produces both concatenation and SNARK signatures whenfuture_snarkis enabledSchnorrSigningKey, VerificationKeyForSnark)AggregateVerificationKeyto include a SNARK aggregate key built from the SNARK Merkle tree commitmentSingleSignature::verifyto validate the SNARK signature against the SNARK AVK when presentSingleSignatureandSingleSignatureWithRegisteredPartycoveringfuture_snarkPre-submit checklist
Comments
From<(RegistrationEntry, Stake)> for ClosedRegistrationEntryis updated to setmodulus - 1to the target value instead of 1.Issue(s)
Closes #2943