mithril
mithril copied to clipboard
Single signature without merkle path
Single Signatures without Merkle Path
Individual Signature - StmSig
An individual signature StmSig does not contain the Merkle path; instead, it holds the signer's merkle tree index.
Pathremoved.- The list
mt_index_pathwas added; it holds the indexes of the path values for the signer. - The index of the signer
signer_indexwas added.
Sign Function - StmSigner::sign
Signer does not call get_path, instead it calls get_mt_index_path.
MerkleTree::get_mt_index_path: This function returns a vector that holds the Merkle tree indexes of the nodes that belongs to the path for the current signer.
Verify Function - StmSig::verify
The verification of a single signature is done without checking the Merkle tree path.
Aggregation - StmClerk::aggregate
The aggregator gets the path (the new path consists of values and indices) for each signature. Single signatures now contain the index of the signer so that the aggregator can get the path with the knowledge of the Merkle tree. The aggregator collects the unique Merkle tree nodes as a proof list.
-
Proof List:
- Proof list is a struct in
merkle_tree.rsincludingvalues: Vec<Vec<u8>>,indexes: Vec<usize>, andhasher: PhantomData<D>. - It implements
create,match_val_ind,to_bytes, andfrom_bytes.
- Proof list is a struct in
-
A new parameter of type
ProofListis added to the structStmAggrSig. -
Aggregator calls
generate_proof_listfor each signer. This function is similar toget_path, except it also holds the index of the value. -
Only unique path values are collected in
proof_list. -
The aggregated signature is generated after getting the
proof_listandunique_sigs.
Verify Aggregate - StmAggrSig::verify
- The verifier reconstructs the Merkle path for each signer.
- It matches the
mt_index_pathofStmSigwithproof_listofStmAggrSigand obtains the path.
ToDo:
- [x] The signer should not include index path when generating the signature; the aggregator should do that.
- [x] Proof list of the aggregator should be updated as in ATMS.
Update:
Due to the breaking changes on the main branch, a load of conflicts occurred between the main and signature-without-path, and most of the CI checks failed. So, we decided to rebase the main and handle batch-proof implementations without affecting the rest of the project. The following describes the changes:
mithril-coreis restored from main, so that the batch compatibility can be tested only in core.- Batch compatibility is implemented in
stm_batch_compat.rs. - To handle the required changes,
merkle_tree.rsis updated. - Tests and benches are created for batch compatibility.
- stm_batch_compat.rs
This module inherits from stm and provides the batch compatibility. It overwrites the structs and functions of stm only where required by batch-compat.
-
Individual signature:
- The struct
StmSigBatchCompatis modified fromStmSigwhere the path is removed, and the signer index is added. StmSignerBatchCompat::sign()generates a signature without computing the merkle path.StmSigBatchCompat::verify()does not check the merkle path.
- The struct
-
Aggregation:
- The batch proof is added to struct
StmAggrSigBatchCompat. - The type
StmClerkBatchCompactis derived fromStmClerk. StmClerkBatchCompact::aggregate_batch_compat()aggregates the signature and generates a batch proof forStmAggrSigBatchCompat.
- The batch proof is added to struct
-
Verification:
- Aggregated signature is verified by checking the
batch_proofinStmAggrSigBatchCompat::verify().
- Aggregated signature is verified by checking the
- merkle_tree.rs
- The struct
BatchPathincludes the indices and the values of the nodes in the path. - In order to get the batch path, the number of leaves in the merkle tree is required. So, a new commitment structure
MerkleTreeCommitmentBatchCompatthat includesnr_leavesbesides theroot. - Batch path is computed in
MerkleTree::get_batched_path()and checked inMerkleTreeCommitmentBatchCompat::check_batched()with the method used in ATMS.
ToDo:
- [x] Tests for
MerkleTreeCommitmentBatchCompatandBatchPath. - [x] Handle batch features in
stm.rs - [x] Documentation of batch compat in
stm.rs - [ ] Simplify
check_batchedinmerkle_tree.rs- [x] Update doc for merkle tree batch compact.
- [x] Revisit integration.
- [x] Revisit bench tests.
Open questions:
- [ ] Is there a way to reduce the lines of code in
stm_batch_compat.rs? - [ ] How can we generate batch path without including
nr_leavesinMerkleTreeCommitment? The change in the commitment structure seems to be the reason that we have conflicts with the rest of the project.
This closes #161
Unit Test Results
3 files 28 suites 2m 42s :stopwatch: 326 tests 326 :heavy_check_mark: 0 :zzz: 0 :x: 379 runs 379 :heavy_check_mark: 0 :zzz: 0 :x:
Results for commit a3cad9b7.
:recycle: This comment has been updated with latest results.