group: Remove "compressed" notion from GroupEncoding

A generic group has a single encoding; for elliptic curves, this
happens to be the compressed encoding.
This commit is contained in:
Jack Grigg 2020-05-29 20:58:54 +12:00
parent 9397e78789
commit 8142ece846
2 changed files with 11 additions and 11 deletions

View File

@ -38,19 +38,19 @@ impl<E: Engine> PartialEq for Proof<E> {
impl<E: Engine> Proof<E> {
pub fn write<W: Write>(&self, mut writer: W) -> io::Result<()> {
writer.write_all(self.a.to_compressed().as_ref())?;
writer.write_all(self.b.to_compressed().as_ref())?;
writer.write_all(self.c.to_compressed().as_ref())?;
writer.write_all(self.a.to_bytes().as_ref())?;
writer.write_all(self.b.to_bytes().as_ref())?;
writer.write_all(self.c.to_bytes().as_ref())?;
Ok(())
}
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 GroupEncoding>::Compressed::default();
let mut g1_repr = <E::G1Affine as GroupEncoding>::Repr::default();
reader.read_exact(g1_repr.as_mut())?;
let affine = E::G1Affine::from_compressed(&g1_repr);
let affine = E::G1Affine::from_bytes(&g1_repr);
let affine = if affine.is_some().into() {
Ok(affine.unwrap())
} else {
@ -70,10 +70,10 @@ impl<E: Engine> Proof<E> {
};
let read_g2 = |reader: &mut R| -> io::Result<E::G2Affine> {
let mut g2_repr = <E::G2Affine as GroupEncoding>::Compressed::default();
let mut g2_repr = <E::G2Affine as GroupEncoding>::Repr::default();
reader.read_exact(g2_repr.as_mut())?;
let affine = E::G2Affine::from_compressed(&g2_repr);
let affine = E::G2Affine::from_bytes(&g2_repr);
let affine = if affine.is_some().into() {
Ok(affine.unwrap())
} else {

View File

@ -446,17 +446,17 @@ impl CurveAffine for Fr {
}
impl GroupEncoding for Fr {
type Compressed = FakePoint;
type Repr = FakePoint;
fn from_compressed(_bytes: &Self::Compressed) -> CtOption<Self> {
fn from_bytes(_bytes: &Self::Repr) -> CtOption<Self> {
unimplemented!()
}
fn from_compressed_unchecked(_bytes: &Self::Compressed) -> CtOption<Self> {
fn from_bytes_unchecked(_bytes: &Self::Repr) -> CtOption<Self> {
unimplemented!()
}
fn to_compressed(&self) -> Self::Compressed {
fn to_bytes(&self) -> Self::Repr {
unimplemented!()
}
}