From 9149d48afc69be2ed1e976ac43b49fdfe6e4e3e3 Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Thu, 3 Jun 2021 20:25:10 -0600 Subject: [PATCH] Apply suggestions from code review Co-authored-by: str4d --- zcash_primitives/src/transaction/components/sapling.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/zcash_primitives/src/transaction/components/sapling.rs b/zcash_primitives/src/transaction/components/sapling.rs index 2e567a236..745bfee1c 100644 --- a/zcash_primitives/src/transaction/components/sapling.rs +++ b/zcash_primitives/src/transaction/components/sapling.rs @@ -129,7 +129,7 @@ pub fn read_point(mut reader: R, field: &str) -> io::Result(mut reader: R, field: &str) -> io::Result(mut reader: R, field: &str) -> io::Result { +pub fn read_base(mut reader: R, field: &str) -> io::Result { let mut f = [0u8; 32]; reader.read_exact(&mut f)?; bls12_381::Scalar::from_repr(f).ok_or_else(|| { io::Error::new( io::ErrorKind::InvalidInput, - field.to_owned() + " not in field", + format!("{} not in field", field), ) }) } @@ -190,7 +190,7 @@ impl SpendDescription { let cv = read_point(&mut reader, "cv")?; // Consensus rules (§7.3) & (§7.4): // - Canonical encoding is enforced here - let anchor = read_scalar(&mut reader, "anchor")?; + let anchor = read_base(&mut reader, "anchor")?; let nullifier = Self::read_nullifier(&mut reader)?; let rk = Self::read_rk(&mut reader)?; let zkproof = read_zkproof(&mut reader)?;