ark_models_ext/models/bw6/
g1.rs

1use crate::{
2    bw6::BW6Config,
3    short_weierstrass::{Affine, Projective},
4    AffineRepr, CurveGroup,
5};
6use ark_serialize::*;
7use ark_std::vec::Vec;
8use derivative::Derivative;
9
10pub type G1Affine<P> = Affine<<P as BW6Config>::G1Config>;
11pub type G1Projective<P> = Projective<<P as BW6Config>::G1Config>;
12
13#[derive(Derivative, CanonicalSerialize, CanonicalDeserialize)]
14#[derivative(
15    Copy(bound = "P: BW6Config"),
16    Clone(bound = "P: BW6Config"),
17    PartialEq(bound = "P: BW6Config"),
18    Eq(bound = "P: BW6Config"),
19    Debug(bound = "P: BW6Config")
20)]
21pub struct G1Prepared<P: BW6Config>(pub G1Affine<P>);
22
23impl<P: BW6Config> From<G1Affine<P>> for G1Prepared<P> {
24    fn from(other: G1Affine<P>) -> Self {
25        G1Prepared(other)
26    }
27}
28
29impl<P: BW6Config> From<G1Projective<P>> for G1Prepared<P> {
30    fn from(q: G1Projective<P>) -> Self {
31        q.into_affine().into()
32    }
33}
34
35impl<'a, P: BW6Config> From<&'a G1Affine<P>> for G1Prepared<P> {
36    fn from(other: &'a G1Affine<P>) -> Self {
37        G1Prepared(*other)
38    }
39}
40
41impl<'a, P: BW6Config> From<&'a G1Projective<P>> for G1Prepared<P> {
42    fn from(q: &'a G1Projective<P>) -> Self {
43        q.into_affine().into()
44    }
45}
46
47impl<P: BW6Config> G1Prepared<P> {
48    pub fn is_zero(&self) -> bool {
49        self.0.infinity
50    }
51}
52
53impl<P: BW6Config> Default for G1Prepared<P> {
54    fn default() -> Self {
55        G1Prepared(G1Affine::<P>::generator())
56    }
57}