jf_pcs/
structs.rs

1// Copyright (c) 2022 Espresso Systems (espressosys.com)
2// This file is part of the Jellyfish library.
3
4// You should have received a copy of the MIT License
5// along with the Jellyfish library. If not, see <https://mit-license.org/>.
6
7use ark_ec::{pairing::Pairing, AffineRepr};
8use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
9use ark_std::vec::Vec;
10use derive_where::derive_where;
11
12#[derive(Clone, Copy, Debug, PartialEq, Eq, CanonicalSerialize, CanonicalDeserialize)]
13#[derive_where(Default, Hash)]
14/// A commitment is an Affine point.
15pub struct Commitment<E: Pairing>(
16    /// the actual commitment is an affine point.
17    pub E::G1Affine,
18);
19
20/// Allow generic creation from `AffineRepr`
21impl<T, E> From<T> for Commitment<E>
22where
23    T: AffineRepr,
24    E: Pairing<G1Affine = T>,
25{
26    fn from(value: T) -> Self {
27        Self(value)
28    }
29}
30
31/// Allow generic access to the underlying `AffineRepr`
32impl<T, E> AsRef<T> for Commitment<E>
33where
34    T: AffineRepr,
35    E: Pairing<G1Affine = T>,
36{
37    fn as_ref(&self) -> &T {
38        &self.0
39    }
40}