From bd61ce96bac2f2e5c88db3b216576f87380f05d1 Mon Sep 17 00:00:00 2001 From: Michal Nazarewicz Date: Wed, 17 May 2023 02:47:02 +0200 Subject: [PATCH] Update borsh dependency to 0.10 --- Cargo.toml | 4 ++-- src/fields/fp.rs | 6 +++--- src/groups/mod.rs | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index acba81f..eec3473 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,8 +23,8 @@ byteorder = { version = "1.0", features = ["i128"], default-features = false } crunchy = "0.2.1" lazy_static = { version = "1.4.0", features = ["spin_no_std"] } rustc-hex = { version = "2", default-features = false } -borsh = {version = "0.9", default-features = false, optional = true} +borsh = {version = "0.10", default-features = false, optional = true} [dev-dependencies] seq-macro = "0.1.5" -rand = { version = "0.8.3" } \ No newline at end of file +rand = { version = "0.8.3" } diff --git a/src/fields/fp.rs b/src/fields/fp.rs index dfb715b..b74374a 100644 --- a/src/fields/fp.rs +++ b/src/fields/fp.rs @@ -8,7 +8,7 @@ use crate::fields::FieldElement; use borsh::{BorshDeserialize, BorshSerialize}; #[cfg(feature = "borsh")] -use borsh::maybestd::io::{Error, ErrorKind, Write}; +use borsh::maybestd::io::{Error, ErrorKind, Read, Write}; macro_rules! field_impl { ($name:ident, $modulus:expr, $rsquared:expr, $rcubed:expr, $one:expr, $inv:expr) => { @@ -25,8 +25,8 @@ macro_rules! field_impl { #[cfg(feature = "borsh")] impl BorshDeserialize for $name { - fn deserialize(buf: &mut &[u8]) -> Result { - let num = U256::deserialize(buf)?; + fn deserialize_reader(reader: &mut R) -> Result { + let num = U256::deserialize_reader(reader)?; Self::new(num).ok_or_else(|| { Error::new(ErrorKind::InvalidData, "integer is not less than modulus") }) diff --git a/src/groups/mod.rs b/src/groups/mod.rs index b3f888f..32034f6 100644 --- a/src/groups/mod.rs +++ b/src/groups/mod.rs @@ -11,7 +11,7 @@ use crate::fields::{const_fq, fq2_nonresidue, FieldElement, Fq, Fq12, Fq2, Fr}; use borsh::{BorshDeserialize, BorshSerialize}; #[cfg(feature = "borsh")] -use borsh::maybestd::io::{ErrorKind, Write}; +use borsh::maybestd::io::{ErrorKind, Read, Write}; // This is the NAF version of ate_loop_count. Entries are all mod 4, so 3 = -1 // n.b. ate_loop_count = 0x19d797039be763ba8 @@ -148,9 +148,9 @@ impl BorshSerialize for G

{ #[cfg(feature = "borsh")] impl BorshDeserialize for G

{ - fn deserialize(buf: &mut &[u8]) -> Result { - let x = P::Base::deserialize(buf)?; - let y = P::Base::deserialize(buf)?; + fn deserialize_reader(reader: &mut R) -> Result { + let x = P::Base::deserialize_reader(reader)?; + let y = P::Base::deserialize_reader(reader)?; if x.is_zero() && y.is_zero() { Ok(Self::zero()) } else {