mithril_stm/protocol/aggregate_signature/
aggregate_key.rs

1use crate::{
2    ClosedKeyRegistration, MembershipDigest, proof_system::AggregateVerificationKeyForConcatenation,
3};
4
5/// Aggregate verification key
6#[derive(Debug, Clone)]
7pub struct AggregateVerificationKey<D: MembershipDigest> {
8    /// Concatenation aggregate verification key.
9    concatenation_aggregate_verification_key: AggregateVerificationKeyForConcatenation<D>,
10}
11
12impl<D: MembershipDigest> AggregateVerificationKey<D> {
13    pub fn new(
14        concatenation_aggregate_verification_key: AggregateVerificationKeyForConcatenation<D>,
15    ) -> Self {
16        Self {
17            concatenation_aggregate_verification_key,
18        }
19    }
20
21    /// Returns the concatenation aggregate verification key
22    pub fn to_concatenation_aggregate_verification_key(
23        &self,
24    ) -> &AggregateVerificationKeyForConcatenation<D> {
25        &self.concatenation_aggregate_verification_key
26    }
27}
28
29impl<D: MembershipDigest> PartialEq for AggregateVerificationKey<D> {
30    fn eq(&self, other: &Self) -> bool {
31        self.to_concatenation_aggregate_verification_key()
32            == other.to_concatenation_aggregate_verification_key()
33    }
34}
35
36impl<D: MembershipDigest> Eq for AggregateVerificationKey<D> {}
37
38impl<D: MembershipDigest> From<&ClosedKeyRegistration> for AggregateVerificationKey<D> {
39    fn from(reg: &ClosedKeyRegistration) -> Self {
40        AggregateVerificationKey {
41            concatenation_aggregate_verification_key:
42                AggregateVerificationKeyForConcatenation::from(reg),
43        }
44    }
45}