Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update borsh dependency to 0.10 #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
rand = { version = "0.8.3" }
6 changes: 3 additions & 3 deletions src/fields/fp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -25,8 +25,8 @@ macro_rules! field_impl {

#[cfg(feature = "borsh")]
impl BorshDeserialize for $name {
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error> {
let num = U256::deserialize(buf)?;
fn deserialize_reader<R: Read>(reader: &mut R) -> Result<Self, Error> {
let num = U256::deserialize_reader(reader)?;
Self::new(num).ok_or_else(|| {
Error::new(ErrorKind::InvalidData, "integer is not less than modulus")
})
Expand Down
8 changes: 4 additions & 4 deletions src/groups/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -148,9 +148,9 @@ impl<P: GroupParams> BorshSerialize for G<P> {

#[cfg(feature = "borsh")]
impl<P: GroupParams> BorshDeserialize for G<P> {
fn deserialize(buf: &mut &[u8]) -> Result<Self, borsh::maybestd::io::Error> {
let x = P::Base::deserialize(buf)?;
let y = P::Base::deserialize(buf)?;
fn deserialize_reader<R: Read>(reader: &mut R) -> Result<Self, borsh::maybestd::io::Error> {
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 {
Expand Down