Skip to content

Commit

Permalink
Migrate to digest 0.10
Browse files Browse the repository at this point in the history
Closes #102.
  • Loading branch information
str4d committed Jul 21, 2024
1 parent d8d75af commit 581d70d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 38 deletions.
50 changes: 22 additions & 28 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ license = "MIT/Apache-2.0"
rustdoc-args = ["--html-in-header", "katex-header.html"]

[dependencies]
digest = { version = "0.9", optional = true }
digest = { version = "0.10", optional = true }
ff = { version = "0.13", default-features = false }
group = { version = "0.13", optional = true, default-features = false }
pairing = { version = "0.23", optional = true }
Expand All @@ -30,8 +30,8 @@ csv = ">= 1.0, < 1.2" # csv 1.2 has MSRV 1.60
criterion = "0.3"
hex-literal = "0.3"
rand_xorshift = "0.3"
sha2 = "0.9"
sha3 = "0.9"
sha2 = "0.10"
sha3 = "0.10"

[features]
default = ["groups", "pairings", "alloc", "bits"]
Expand Down
2 changes: 2 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Unreleased
## Changed
- Bumped dependencies to `digest 0.10`.

# 0.8.0
## Changed
Expand Down
15 changes: 8 additions & 7 deletions src/hash_to_curve/expand_msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
use core::fmt::{self, Debug, Formatter};

use digest::{
generic_array::typenum::IsLess, BlockInput, ExtendableOutput, FixedOutput, Update, XofReader,
core_api::BlockSizeUser, generic_array::typenum::IsLess, ExtendableOutput, FixedOutput,
XofReader,
};

use crate::generic_array::{
Expand Down Expand Up @@ -47,7 +48,7 @@ impl ExpandMsgDst {
/// is used when handling DST values longer than 255 bytes.
fn for_xof<H, L>(dst: &[u8]) -> Self
where
H: Default + Update + ExtendableOutput,
H: Default + ExtendableOutput,
L: ArrayLength<u8> + IsLess<U256>,
{
let input_len = dst.len();
Expand All @@ -72,7 +73,7 @@ impl ExpandMsgDst {
/// reduce domain separation tags that are longer than 255 bytes.
fn for_xmd<H>(dst: &[u8]) -> Self
where
H: Default + FixedOutput + Update,
H: Default + FixedOutput,
H::OutputSize: IsLess<U256>,
{
let input_len = dst.len();
Expand Down Expand Up @@ -178,7 +179,7 @@ impl<H: ExtendableOutput> Debug for ExpandMsgXof<H> {

impl<H> ExpandMessage for ExpandMsgXof<H>
where
H: Default + ExtendableOutput + Update,
H: Default + ExtendableOutput,
{
fn init_expand<M, L>(message: M, dst: &[u8], len_in_bytes: usize) -> Self
where
Expand Down Expand Up @@ -245,15 +246,15 @@ impl<H: FixedOutput> Debug for ExpandMsgXmd<H> {

impl<H> ExpandMessage for ExpandMsgXmd<H>
where
H: Default + BlockInput + FixedOutput + Update,
H: Default + BlockSizeUser + FixedOutput,
H::OutputSize: IsLess<U256>,
{
fn init_expand<M, L>(message: M, dst: &[u8], len_in_bytes: usize) -> Self
where
M: Message,
L: ArrayLength<u8> + IsLess<U256>,
{
let hash_size = <H as FixedOutput>::OutputSize::to_usize();
let hash_size = H::OutputSize::to_usize();
let ell = (len_in_bytes + hash_size - 1) / hash_size;
if ell > 255 {
panic!("Invalid ExpandMsgXmd usage: ell > 255");
Expand All @@ -264,7 +265,7 @@ where

let dst = ExpandMsgDst::for_xmd::<H>(dst);
let mut hash_b_0 =
H::default().chain(GenericArray::<u8, <H as BlockInput>::BlockSize>::default());
H::default().chain(GenericArray::<u8, <H as BlockSizeUser>::BlockSize>::default());
message.input_message(|m| hash_b_0.update(m));
let b_0 = hash_b_0
.chain((len_in_bytes as u16).to_be_bytes())
Expand Down

0 comments on commit 581d70d

Please sign in to comment.