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