Skip to content

Optimize single signature in Mithril Aggregator/Signer/Core #296

Closed
@jpraynaud

Description

@jpraynaud

We need to make some optimizations in the registration process of the single signatures in the Aggregator:

1. Single Signature Model

  • Assumption: The single signature is the same for each won lottery index
  • This means we could update the model of the SingleSignature, which will save bandwidth and storage
  • The current model is to use a list/vec of SingleSignature:
pub struct SingleSignature {
    pub party_id: PartyId,
    pub index: LotteryIndex,
    pub signature: String,
}
  • The updated model would be to use instead a SingleSignatures:
pub struct SingleSignatures {
    pub party_id: PartyId,
    pub won_indexes: Vec<LotteryIndex>,
    pub signature: String,
}
  • Tasks:
  • Validate if the model of the signature should be updated
  • Adapt OpenApi specification
  • Adapt Mithil Common entities
  • Adapt Mithril Aggregator
  • Adapt Mithril Signer

2. Split multi signer single signature registration process

  • Issue: The handling of the RwLock must be optimized (the multi_signer is write locked at times where it could be read)
  • Solution: The register_single_signatures method of the multi_signer should be split in:
    • check_registered: checks that none of the incoming single signatures are already stored in the Aggregator (read lock during this step)
    • verify: verify the validity of the single signatures with the mithril-core library (this is the operation that supposedly takes time) (read lock during this step)
    • store: store all the single signatures at once (write lock during this step)
  • Tasks:
  • Adapt the MultiSigner trait and its implementation with the new methods
  • Adapt the http_server register_signatures route so that it interacts with the new methods of the multi signer and handle the locks on it
  • Adapt the SingleSignatureStore to use save_single_signatures (input is multiple single signatures) instead of save_single_signature (input is one single signature)

3. Implement batch single signature verification in Mithril Core

  • Issue: The last stage of the optimization is to verify the single signature once in the mithril-core library
  • Solution: This means that the mithril-core library should provide a verification method that takes a single signature and a list of won lottery and batch the verification of the singe signatures
  • Tasks:
  • Add the batch method in Mithril Core
  • Update the multi signer underlying call to Mithril Core with this new method
  • Update if needed the protocol demo (which might not compile anymore depending on how the batch method is implemented)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions