Skip to content

Commit a4fef92

Browse files
committed
Apply suggestions from review
1 parent e50ae7c commit a4fef92

File tree

3 files changed

+36
-34
lines changed

3 files changed

+36
-34
lines changed

mithril-aggregator/src/multi_signer.rs

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ pub enum ProtocolError {
3636
#[error("signer already registered")]
3737
ExistingSigner(),
3838

39+
/// Signer was not registered.
40+
#[error("signer did not register")]
41+
UnregisteredParty(),
42+
3943
/// Signer registration failed.
4044
#[error("signer registration failed")]
4145
FailedSignerRegistration(#[from] ProtocolRegistrationError),
@@ -710,40 +714,35 @@ impl MultiSigner for MultiSignerImpl {
710714

711715
// If there is no reg_party, then we simply received a signature from a non-registered
712716
// party, and we can ignore the request.
713-
if let Some((vk, stake)) = clerk.get_reg_party(&signature.signer_index) {
714-
signature
715-
.verify(
716-
&protocol_parameters,
717-
&vk,
718-
&stake,
719-
&avk,
720-
message.compute_hash().as_bytes(),
721-
)
722-
.map_err(|e| ProtocolError::Core(e.to_string()))?;
717+
let (vk, stake) = clerk
718+
.get_reg_party(&signature.signer_index)
719+
.ok_or_else(ProtocolError::UnregisteredParty)?;
720+
signature
721+
.verify(
722+
&protocol_parameters,
723+
&vk,
724+
&stake,
725+
&avk,
726+
message.compute_hash().as_bytes(),
727+
)
728+
.map_err(|e| ProtocolError::Core(e.to_string()))?;
723729

724-
// Register single signature
725-
let beacon = self
726-
.current_beacon
727-
.as_ref()
728-
.ok_or_else(ProtocolError::UnavailableBeacon)?;
729-
730-
match self
731-
.single_signature_store
732-
.save_single_signatures(beacon, signatures)
733-
.await?
734-
{
735-
Some(_) => {
736-
return Err(ProtocolError::ExistingSingleSignature(
737-
signatures.party_id.clone(),
738-
));
739-
}
740-
None => {
741-
return Ok(());
742-
}
743-
}
744-
}
730+
// Register single signature
731+
let beacon = self
732+
.current_beacon
733+
.as_ref()
734+
.ok_or_else(ProtocolError::UnavailableBeacon)?;
745735

746-
Ok(())
736+
return match self
737+
.single_signature_store
738+
.save_single_signatures(beacon, signatures)
739+
.await?
740+
{
741+
Some(_) => Err(ProtocolError::ExistingSingleSignature(
742+
signatures.party_id.clone(),
743+
)),
744+
None => Ok(()),
745+
};
747746
}
748747

749748
/// Retrieves a multi signature from a message

mithril-stm/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ fn main() {
143143

144144
Here we give the benchmark results of STM for size and time. We run the benchmarks on macOS 12.6 on an Apple M1 Pro machine with 16 GB of RAM.
145145

146-
Note that the size of an individual signature with one valid index is **176 bytes** and increases linearly in the length of valid indices (where an index is 8 bytes).
146+
Note that the size of an individual signature with one valid index is **72 bytes** (48 bytes from `sigma`, 8 bytes from `party_index`, 8 bytes for the `length` of winning indices and at least 8 bytes for a single winning `index`) and increases linearly in the length of valid indices (where an index is 8 bytes).
147147

148148
```shell
149149
+----------------------+

mithril-stm/src/stm.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,10 @@ impl<D: Digest + Clone + FixedOutput> StmClerk<D> {
558558

559559
/// Get the (VK, stake) of a party given its index.
560560
pub fn get_reg_party(&self, party_index: &Index) -> Option<(StmVerificationKey, Stake)> {
561-
self.closed_reg.reg_parties.get(*party_index as usize).map(|r| r.into())
561+
self.closed_reg
562+
.reg_parties
563+
.get(*party_index as usize)
564+
.map(|&r| r.into())
562565
}
563566
}
564567

0 commit comments

Comments
 (0)