|
105 | 105 | //! # } |
106 | 106 | //! ``` |
107 | 107 |
|
| 108 | +use std::collections::{BTreeMap, HashMap, HashSet}; |
| 109 | +use std::convert::{From, TryFrom, TryInto}; |
| 110 | + |
| 111 | +use blake2::digest::{Digest, FixedOutput}; |
| 112 | +use serde::{Deserialize, Serialize}; |
| 113 | + |
108 | 114 | use crate::bls_multi_signature::{Signature, VerificationKey}; |
109 | 115 | use crate::error::{ |
110 | 116 | AggregationError, CoreVerifierError, RegisterError, StmAggregateSignatureError, |
111 | | - StmSignatureError, |
112 | 117 | }; |
113 | 118 | use crate::key_reg::{ClosedKeyReg, RegParty}; |
114 | 119 | use crate::merkle_tree::{BatchPath, MTLeaf, MerkleTreeCommitmentBatchCompat}; |
115 | 120 | use crate::participant::{StmSigner, StmVerificationKey}; |
116 | | -use crate::single_signature::StmSig; |
117 | | -use blake2::digest::{Digest, FixedOutput}; |
118 | | -use serde::ser::SerializeTuple; |
119 | | -use serde::{Deserialize, Serialize, Serializer}; |
120 | | -use std::collections::{BTreeMap, HashMap, HashSet}; |
121 | | -use std::convert::{From, TryFrom, TryInto}; |
122 | | -use std::hash::Hash; |
| 121 | +use crate::single_signature::{StmSig, StmSigRegParty}; |
123 | 122 |
|
124 | 123 | /// The quantity of stake held by a party, represented as a `u64`. |
125 | 124 | pub type Stake = u64; |
@@ -218,50 +217,6 @@ impl<D: Clone + Digest + FixedOutput> From<&ClosedKeyReg<D>> for StmAggrVerifica |
218 | 217 | } |
219 | 218 | } |
220 | 219 |
|
221 | | -/// Signature with its registered party. |
222 | | -#[derive(Debug, Clone, Hash, Deserialize, Eq, PartialEq, Ord, PartialOrd)] |
223 | | -pub struct StmSigRegParty { |
224 | | - /// Stm signature |
225 | | - pub sig: StmSig, |
226 | | - /// Registered party |
227 | | - pub reg_party: RegParty, |
228 | | -} |
229 | | - |
230 | | -impl StmSigRegParty { |
231 | | - /// Convert StmSigRegParty to bytes |
232 | | - /// # Layout |
233 | | - /// * RegParty |
234 | | - /// * Signature |
235 | | - pub fn to_bytes(&self) -> Vec<u8> { |
236 | | - let mut out = Vec::new(); |
237 | | - out.extend_from_slice(&self.reg_party.to_bytes()); |
238 | | - out.extend_from_slice(&self.sig.to_bytes()); |
239 | | - |
240 | | - out |
241 | | - } |
242 | | - ///Extract a `StmSigRegParty` from a byte slice. |
243 | | - pub fn from_bytes<D: Digest + Clone + FixedOutput>( |
244 | | - bytes: &[u8], |
245 | | - ) -> Result<StmSigRegParty, StmSignatureError> { |
246 | | - let reg_party = RegParty::from_bytes(&bytes[0..104])?; |
247 | | - let sig = StmSig::from_bytes::<D>(&bytes[104..])?; |
248 | | - |
249 | | - Ok(StmSigRegParty { sig, reg_party }) |
250 | | - } |
251 | | -} |
252 | | - |
253 | | -impl Serialize for StmSigRegParty { |
254 | | - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> |
255 | | - where |
256 | | - S: Serializer, |
257 | | - { |
258 | | - let mut tuple = serializer.serialize_tuple(2)?; |
259 | | - tuple.serialize_element(&self.sig)?; |
260 | | - tuple.serialize_element(&self.reg_party)?; |
261 | | - tuple.end() |
262 | | - } |
263 | | -} |
264 | | - |
265 | 220 | /// `StmClerk` can verify and aggregate `StmSig`s and verify `StmMultiSig`s. |
266 | 221 | /// Clerks can only be generated with the registration closed. |
267 | 222 | /// This avoids that a Merkle Tree is computed before all parties have registered. |
|
0 commit comments