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;
10
11#[derive(
12    Derivative, Clone, Copy, Debug, PartialEq, Eq, CanonicalSerialize, CanonicalDeserialize,
13)]
14#[derivative(Default, Hash)]
15/// A commitment is an Affine point.
16pub struct Commitment<E: Pairing>(
17    /// the actual commitment is an affine point.
18    pub E::G1Affine,
19);
20
21/// Allow generic creation from `AffineRepr`
22impl<T, E> From<T> for Commitment<E>
23where
24    T: AffineRepr,
25    E: Pairing<G1Affine = T>,
26{
27    fn from(value: T) -> Self {
28        Self(value)
29    }
30}
31
32/// Allow generic access to the underlying `AffineRepr`
33impl<T, E> AsRef<T> for Commitment<E>
34where
35    T: AffineRepr,
36    E: Pairing<G1Affine = T>,
37{
38    fn as_ref(&self) -> &T {
39        &self.0
40    }
41}