@@ -15,9 +15,8 @@ use mithril_common::{
15
15
} ;
16
16
17
17
use crate :: {
18
- database:: provider:: OpenMessageWithSingleSignatures ,
19
- store:: { SingleSignatureStorer , VerificationKeyStorer } ,
20
- ProtocolParametersStore , ProtocolParametersStorer , SingleSignatureStore , VerificationKeyStore ,
18
+ database:: provider:: OpenMessageWithSingleSignatures , store:: VerificationKeyStorer ,
19
+ ProtocolParametersStore , ProtocolParametersStorer , VerificationKeyStore ,
21
20
} ;
22
21
23
22
#[ cfg( test) ]
@@ -185,8 +184,8 @@ pub trait MultiSigner: Sync + Send {
185
184
/// Get signers for the next epoch with their stake
186
185
async fn get_next_signers_with_stake ( & self ) -> Result < Vec < SignerWithStake > , ProtocolError > ;
187
186
188
- /// Registers a single signature
189
- async fn register_single_signature (
187
+ /// Verify a single signature
188
+ async fn verify_single_signature (
190
189
& self ,
191
190
message : & entities:: ProtocolMessage ,
192
191
signatures : & entities:: SingleSignatures ,
@@ -213,9 +212,6 @@ pub struct MultiSignerImpl {
213
212
/// Stake store
214
213
stake_store : Arc < dyn StakeStorer > ,
215
214
216
- /// Single signature store
217
- single_signature_store : Arc < SingleSignatureStore > ,
218
-
219
215
/// Protocol parameters store
220
216
protocol_parameters_store : Arc < ProtocolParametersStore > ,
221
217
}
@@ -225,7 +221,6 @@ impl MultiSignerImpl {
225
221
pub fn new (
226
222
verification_key_store : Arc < VerificationKeyStore > ,
227
223
stake_store : Arc < dyn StakeStorer > ,
228
- single_signature_store : Arc < SingleSignatureStore > ,
229
224
protocol_parameters_store : Arc < ProtocolParametersStore > ,
230
225
) -> Self {
231
226
debug ! ( "New MultiSignerImpl created" ) ;
@@ -234,7 +229,6 @@ impl MultiSignerImpl {
234
229
current_beacon : None ,
235
230
verification_key_store,
236
231
stake_store,
237
- single_signature_store,
238
232
protocol_parameters_store,
239
233
}
240
234
}
@@ -526,14 +520,14 @@ impl MultiSigner for MultiSignerImpl {
526
520
. collect ( ) )
527
521
}
528
522
529
- /// Registers a single signature
530
- async fn register_single_signature (
523
+ /// Verify a single signature
524
+ async fn verify_single_signature (
531
525
& self ,
532
526
message : & entities:: ProtocolMessage ,
533
527
signatures : & entities:: SingleSignatures ,
534
528
) -> Result < ( ) , ProtocolError > {
535
529
debug ! (
536
- "Register single signature from {} at indexes {:?} for message {:?}" ,
530
+ "Verify single signature from {} at indexes {:?} for message {:?}" ,
537
531
signatures. party_id, signatures. won_indexes, message
538
532
) ;
539
533
@@ -570,22 +564,7 @@ impl MultiSigner for MultiSignerImpl {
570
564
)
571
565
. map_err ( |e| ProtocolError :: Core ( e. to_string ( ) ) ) ?;
572
566
573
- // Register single signature
574
- let beacon = self
575
- . current_beacon
576
- . as_ref ( )
577
- . ok_or_else ( ProtocolError :: UnavailableBeacon ) ?;
578
-
579
- return match self
580
- . single_signature_store
581
- . save_single_signatures ( beacon, signatures)
582
- . await ?
583
- {
584
- Some ( _) => Err ( ProtocolError :: ExistingSingleSignature (
585
- signatures. party_id . clone ( ) ,
586
- ) ) ,
587
- None => Ok ( ( ) ) ,
588
- } ;
567
+ Ok ( ( ) )
589
568
}
590
569
591
570
/// Creates a multi signature from single signatures
@@ -633,10 +612,7 @@ impl MultiSigner for MultiSignerImpl {
633
612
#[ cfg( test) ]
634
613
mod tests {
635
614
use super :: * ;
636
- use crate :: {
637
- store:: { SingleSignatureStore , VerificationKeyStore } ,
638
- ProtocolParametersStore ,
639
- } ;
615
+ use crate :: { store:: VerificationKeyStore , ProtocolParametersStore } ;
640
616
use chrono:: Local ;
641
617
use mithril_common:: {
642
618
crypto_helper:: tests_setup:: * ,
@@ -662,16 +638,6 @@ mod tests {
662
638
Box :: new ( MemoryAdapter :: < Epoch , StakeDistribution > :: new ( None ) . unwrap ( ) ) ,
663
639
None ,
664
640
) ;
665
- let single_signature_store = SingleSignatureStore :: new (
666
- Box :: new (
667
- MemoryAdapter :: <
668
- entities:: Beacon ,
669
- HashMap < entities:: PartyId , entities:: SingleSignatures > ,
670
- > :: new ( None )
671
- . unwrap ( ) ,
672
- ) ,
673
- None ,
674
- ) ;
675
641
let protocol_parameters_store = ProtocolParametersStore :: new (
676
642
Box :: new (
677
643
MemoryAdapter :: < Epoch , entities:: ProtocolParameters > :: new ( Some ( vec ! [
@@ -695,7 +661,6 @@ mod tests {
695
661
let mut multi_signer = MultiSignerImpl :: new (
696
662
Arc :: new ( verification_key_store) ,
697
663
Arc :: new ( stake_store) ,
698
- Arc :: new ( single_signature_store) ,
699
664
Arc :: new ( protocol_parameters_store) ,
700
665
) ;
701
666
@@ -879,6 +844,13 @@ mod tests {
879
844
}
880
845
}
881
846
847
+ for signature in & signatures {
848
+ multi_signer
849
+ . verify_single_signature ( & message, signature)
850
+ . await
851
+ . expect ( "single signature should be valid" ) ;
852
+ }
853
+
882
854
let signatures_to_almost_reach_quorum = take_signatures_until_quorum_is_almost_reached (
883
855
& mut signatures,
884
856
protocol_parameters. k as usize ,
0 commit comments