Skip to content

Commit

Permalink
Address review
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpedda committed Jan 17, 2022
1 parent c5c5f53 commit 0d6db2f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion elliptic-curve/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ zeroize = { version = "1.5", default-features = false }

# optional dependencies
base64ct = { version = "1", optional = true, default-features = false }
digest = { version = "0.10", optional = true, default-features = false, features = ["core-api"] }
digest = { version = "0.10", optional = true }
ff = { version = "0.11", optional = true, default-features = false }
group = { version = "0.11", optional = true, default-features = false }
hex-literal = { version = "0.3", optional = true }
Expand Down
12 changes: 6 additions & 6 deletions elliptic-curve/src/hash2field/expand_msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ where
X: Digest<OutputSize = L>,
{
if dst.len() > MAX_DST_LEN {
Self::Hashed(
X::new()
.chain_update(OVERSIZE_DST_SALT)
.chain_update(dst)
.finalize(),
)
Self::Hashed({
let mut hash = X::new();
hash.update(OVERSIZE_DST_SALT);
hash.update(dst);
hash.finalize()
})
} else {
Self::Array(dst)
}
Expand Down
40 changes: 20 additions & 20 deletions elliptic-curve/src/hash2field/expand_msg/xmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,25 @@ where
let ell = u8::try_from((len_in_bytes + b_in_bytes - 1) / b_in_bytes).map_err(|_| Error)?;

let domain = Domain::xmd::<HashT>(dst);
let mut b_0 = HashT::new().chain_update(GenericArray::<u8, HashT::BlockSize>::default());
let mut b_0 = HashT::new();
b_0.update(GenericArray::<u8, HashT::BlockSize>::default());

for msg in msgs {
b_0 = b_0.chain_update(msg);
b_0.update(msg);
}

let b_0 = b_0
.chain_update(len_in_bytes_u16.to_be_bytes())
.chain_update([0])
.chain_update(domain.data())
.chain_update([domain.len()])
.finalize();
b_0.update(len_in_bytes_u16.to_be_bytes());
b_0.update([0]);
b_0.update(domain.data());
b_0.update([domain.len()]);
let b_0 = b_0.finalize();

let b_vals = HashT::new()
.chain_update(&b_0[..])
.chain_update([1u8])
.chain_update(domain.data())
.chain_update([domain.len()])
.finalize();
let mut b_vals = HashT::new();
b_vals.update(&b_0[..]);
b_vals.update([1u8]);
b_vals.update(domain.data());
b_vals.update([domain.len()]);
let b_vals = b_vals.finalize();

Ok(ExpanderXmd {
b_0,
Expand Down Expand Up @@ -117,12 +117,12 @@ where
.zip(&self.b_vals[..])
.enumerate()
.for_each(|(j, (b0val, bi1val))| tmp[j] = b0val ^ bi1val);
self.b_vals = HashT::new()
.chain_update(tmp)
.chain_update([self.index])
.chain_update(self.domain.data())
.chain_update([self.domain.len()])
.finalize();
let mut b_vals = HashT::new();
b_vals.update(tmp);
b_vals.update([self.index]);
b_vals.update(self.domain.data());
b_vals.update([self.domain.len()]);
self.b_vals = b_vals.finalize();
true
} else {
false
Expand Down

0 comments on commit 0d6db2f

Please sign in to comment.