group: Remove EncodedPoint::from_affine
The EncodedPoint trait is replaced by explicit bounds on the CurveAffine::{Uncompressed, Compressed} associated types.
This commit is contained in:
parent
180e54d4b3
commit
392a107b31
|
@ -2,7 +2,7 @@
|
|||
//!
|
||||
//! [Groth16]: https://eprint.iacr.org/2016/260
|
||||
|
||||
use group::{CurveAffine, EncodedPoint};
|
||||
use group::CurveAffine;
|
||||
use pairing::{Engine, PairingCurveAffine};
|
||||
|
||||
use crate::SynthesisError;
|
||||
|
@ -47,7 +47,7 @@ impl<E: Engine> Proof<E> {
|
|||
|
||||
pub fn read<R: Read>(mut reader: R) -> io::Result<Self> {
|
||||
let read_g1 = |reader: &mut R| -> io::Result<E::G1Affine> {
|
||||
let mut g1_repr = <E::G1Affine as CurveAffine>::Compressed::empty();
|
||||
let mut g1_repr = <E::G1Affine as CurveAffine>::Compressed::default();
|
||||
reader.read_exact(g1_repr.as_mut())?;
|
||||
|
||||
let affine = E::G1Affine::from_compressed(&g1_repr);
|
||||
|
@ -70,7 +70,7 @@ impl<E: Engine> Proof<E> {
|
|||
};
|
||||
|
||||
let read_g2 = |reader: &mut R| -> io::Result<E::G2Affine> {
|
||||
let mut g2_repr = <E::G2Affine as CurveAffine>::Compressed::empty();
|
||||
let mut g2_repr = <E::G2Affine as CurveAffine>::Compressed::default();
|
||||
reader.read_exact(g2_repr.as_mut())?;
|
||||
|
||||
let affine = E::G2Affine::from_compressed(&g2_repr);
|
||||
|
@ -158,7 +158,7 @@ impl<E: Engine> VerifyingKey<E> {
|
|||
|
||||
pub fn read<R: Read>(mut reader: R) -> io::Result<Self> {
|
||||
let read_g1 = |reader: &mut R| -> io::Result<E::G1Affine> {
|
||||
let mut g1_repr = <E::G1Affine as CurveAffine>::Uncompressed::empty();
|
||||
let mut g1_repr = <E::G1Affine as CurveAffine>::Uncompressed::default();
|
||||
reader.read_exact(g1_repr.as_mut())?;
|
||||
|
||||
let affine = E::G1Affine::from_uncompressed(&g1_repr);
|
||||
|
@ -170,7 +170,7 @@ impl<E: Engine> VerifyingKey<E> {
|
|||
};
|
||||
|
||||
let read_g2 = |reader: &mut R| -> io::Result<E::G2Affine> {
|
||||
let mut g2_repr = <E::G2Affine as CurveAffine>::Uncompressed::empty();
|
||||
let mut g2_repr = <E::G2Affine as CurveAffine>::Uncompressed::default();
|
||||
reader.read_exact(g2_repr.as_mut())?;
|
||||
|
||||
let affine = E::G2Affine::from_uncompressed(&g2_repr);
|
||||
|
@ -289,7 +289,7 @@ impl<E: Engine> Parameters<E> {
|
|||
|
||||
pub fn read<R: Read>(mut reader: R, checked: bool) -> io::Result<Self> {
|
||||
let read_g1 = |reader: &mut R| -> io::Result<E::G1Affine> {
|
||||
let mut repr = <E::G1Affine as CurveAffine>::Uncompressed::empty();
|
||||
let mut repr = <E::G1Affine as CurveAffine>::Uncompressed::default();
|
||||
reader.read_exact(repr.as_mut())?;
|
||||
|
||||
let affine = if checked {
|
||||
|
@ -317,7 +317,7 @@ impl<E: Engine> Parameters<E> {
|
|||
};
|
||||
|
||||
let read_g2 = |reader: &mut R| -> io::Result<E::G2Affine> {
|
||||
let mut repr = <E::G2Affine as CurveAffine>::Uncompressed::empty();
|
||||
let mut repr = <E::G2Affine as CurveAffine>::Uncompressed::default();
|
||||
reader.read_exact(repr.as_mut())?;
|
||||
|
||||
let affine = if checked {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use ff::{Field, PrimeField, ScalarEngine};
|
||||
use group::{CurveAffine, CurveProjective, EncodedPoint, Group, PrimeGroup};
|
||||
use group::{CurveAffine, CurveProjective, Group, PrimeGroup};
|
||||
use pairing::{Engine, PairingCurveAffine};
|
||||
|
||||
use rand_core::RngCore;
|
||||
|
@ -417,7 +417,7 @@ impl CurveProjective for Fr {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Copy, Clone, Default)]
|
||||
pub struct FakePoint;
|
||||
|
||||
impl AsMut<[u8]> for FakePoint {
|
||||
|
@ -432,22 +432,6 @@ impl AsRef<[u8]> for FakePoint {
|
|||
}
|
||||
}
|
||||
|
||||
impl EncodedPoint for FakePoint {
|
||||
type Affine = Fr;
|
||||
|
||||
fn empty() -> Self {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn size() -> usize {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn from_affine(_: Self::Affine) -> Self {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
impl CurveAffine for Fr {
|
||||
type Compressed = FakePoint;
|
||||
type Uncompressed = FakePoint;
|
||||
|
@ -479,6 +463,10 @@ impl CurveAffine for Fr {
|
|||
unimplemented!()
|
||||
}
|
||||
|
||||
fn into_compressed(&self) -> Self::Compressed {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn from_uncompressed(_bytes: &Self::Uncompressed) -> CtOption<Self> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
@ -486,6 +474,10 @@ impl CurveAffine for Fr {
|
|||
fn from_uncompressed_unchecked(_bytes: &Self::Uncompressed) -> CtOption<Self> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn into_uncompressed(&self) -> Self::Uncompressed {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
impl PairingCurveAffine for Fr {
|
||||
|
|
Loading…
Reference in New Issue