From c3157a8d64b495ca5596d1ba82f2e113b818d540 Mon Sep 17 00:00:00 2001 From: redshiftzero Date: Thu, 20 Apr 2023 16:40:59 -0400 Subject: [PATCH] refactor: remove `ToBytes` and `FromBytes` implementations These traits no longer exist upstream. Instead we should be using the `CanonicalDeserialize` or `CanonicalSerialize` traits: https://github.com/arkworks-rs/algebra/pull/417 --- src/serialize.rs | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/src/serialize.rs b/src/serialize.rs index bd0120b..51a13c0 100644 --- a/src/serialize.rs +++ b/src/serialize.rs @@ -1,47 +1,10 @@ use std::convert::TryInto; -use ark_ff::{FromBytes, ToBytes}; use ark_serialize::{CanonicalDeserialize, CanonicalSerialize}; use ark_std::io::{Read, Result as IoResult, Write}; use crate::{AffineElement, Element, Encoding, FieldExt, Fq}; -impl ToBytes for Element { - #[inline] - fn write(&self, mut writer: W) -> IoResult<()> { - let field_element = self.vartime_compress_to_field(); - let bytes: [u8; 32] = field_element.to_bytes(); - bytes.write(&mut writer) - } -} - -impl FromBytes for Element { - #[inline] - fn read(mut reader: R) -> IoResult { - let field_element = Fq::read(&mut reader)?; - let element = Encoding(field_element.to_bytes()) - .vartime_decompress() - .map_err(|_| std::io::ErrorKind::InvalidData)?; - Ok(element) - } -} - -impl ToBytes for AffineElement { - #[inline] - fn write(&self, mut writer: W) -> IoResult<()> { - let element: Element = self.into(); - element.write(&mut writer) - } -} - -impl FromBytes for AffineElement { - #[inline] - fn read(mut reader: R) -> IoResult { - let element = Element::read(&mut reader)?; - Ok(element.into()) - } -} - impl CanonicalDeserialize for AffineElement { fn deserialize_with_mode( reader: R,