feat(common): encode the SNARK aggregate signature as bytes in the certificate message - #3437
feat(common): encode the SNARK aggregate signature as bytes in the certificate message#3437jpraynaud wants to merge 3 commits into
Conversation
Test Results 5 files ± 0 209 suites ±0 2h 18m 1s ⏱️ - 53m 49s Results for commit a37adb3. ± Comparison against base commit bc9d8c1. This pull request removes 35 and adds 3 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
6981ddd to
897008f
Compare
Encode the multi-signature by type through the ProtocolKey codec: JSON-hex for concatenation (backward compatible), bytes-hex for SNARK and IVC proofs.
…codec The record now encodes the certificate crypto fields via the ProtocolKey codec, so the served SNARK multi-signature is bytes-hex instead of JSON-hex.
Serialize the aggregate signature and proof byte vectors as byte strings instead of arrays of integers, which halves their encoded size at each nesting level.
897008f to
a37adb3
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates how certificate-related cryptographic payloads are encoded so that SNARK/IVC proofs use a more compact byte-string CBOR representation (and bytes-hex on the wire where applicable), while keeping concatenation proofs backward compatible via JSON-hex encoding. This aligns certificate message/record serialization with the ProtocolKey codec to ensure consistent encoding decisions by aggregate signature type.
Changes:
- Emit CBOR byte strings for proof byte vectors by using
serde_bytesfor SNARK/IVC proof fields and the aggregate signature CBOR envelope. - Route certificate message and DB record encoding through
String::try_from(&ProtocolKey<...>)to centralize encoding decisions in theProtocolKeyCodec. - Introduce a custom
ProtocolKeyCodecforAggregateSignaturethat encodes concatenation as JSON-hex and (when enabled) SNARK/IVC as bytes-hex.
Reviewed changes
Copilot reviewed 6 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| mithril-stm/src/protocol/aggregate_signature/signature.rs | Encodes CBOR envelope proof_bytes as a CBOR byte string and updates golden CBOR fixtures accordingly. |
| mithril-stm/src/proof_system/halo2_snark/proof.rs | Serializes SNARK circuit_proof with serde_bytes for compact CBOR bytes. |
| mithril-stm/src/circuits/halo2_ivc/types.rs | Serializes IVC proof byte wrapper with serde_bytes for compact CBOR bytes. |
| mithril-stm/Cargo.toml | Adds serde_bytes dependency (and ignores it for cargo-machete). |
| mithril-common/src/messages/certificate.rs | Uses ProtocolKey codec (String::try_from) for certificate crypto fields; adds tests for multi-signature encoding by type. |
| mithril-common/src/crypto_helper/types/wrappers.rs | Implements custom ProtocolKeyCodec for AggregateSignature to encode by signature type (JSON-hex vs bytes-hex). |
| mithril-aggregator/src/database/record/certificate.rs | Stores certificate signatures/keys via ProtocolKey codec (String::try_from) and adds a test for SNARK multi-signature storage encoding. |
| Cargo.lock | Locks the new serde_bytes dependency. |
Content
This PR includes the encoding of the certificate message aggregate signature by type, so SNARK and IVC proofs use the compact bytes-hex encoding while concatenation proofs remain backward compatible:
multi_signaturefield by aggregate signature type: JSON-hex for concatenation proofs (backward compatible with all deployed clients) and bytes-hex for SNARK and IVC proofs.ProtocolKeycodec (String::try_from) instead of an explicit bytes-hex call.Pre-submit checklist
Issue(s)
Closes #3379