Skip to content

Commit

Permalink
Merge pull request #136 from zkcrypto/digest-0.10
Browse files Browse the repository at this point in the history
Migrate to `digest 0.10`
  • Loading branch information
str4d authored Jul 21, 2024
2 parents 2874b5a + 581d70d commit f770b0d
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 82 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.

74 changes: 27 additions & 47 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,67 +1,37 @@
[package]
name = "bls12_381"
version = "0.8.0"
authors = [
"Sean Bowe <[email protected]>",
"Jack Grigg <[email protected]>",
]
edition = "2021"
rust-version = "1.56"
description = "Implementation of the BLS12-381 pairing-friendly elliptic curve construction"
documentation = "https://docs.rs/bls12_381/"
homepage = "https://github.com/zkcrypto/bls12_381"
license = "MIT/Apache-2.0"
name = "bls12_381"
repository = "https://github.com/zkcrypto/bls12_381"
version = "0.8.0"
edition = "2021"
license = "MIT/Apache-2.0"

[package.metadata.docs.rs]
rustdoc-args = [ "--html-in-header", "katex-header.html" ]
rustdoc-args = ["--html-in-header", "katex-header.html"]

[dependencies]
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 }
rand_core = { version = "0.6", default-features = false }
subtle = { version = "2.2.1", default-features = false }
zeroize = { version = "1.4", optional = true, default-features = false }

[dev-dependencies]
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"

[[bench]]
name = "groups"
harness = false
required-features = ["groups"]

[[bench]]
name = "hash_to_curve"
harness = false
required-features = ["experimental"]

[dependencies.digest]
version = "0.9"
optional = true

[dependencies.ff]
version = "0.13"
default-features = false

[dependencies.group]
version = "0.13"
default-features = false
optional = true

[dependencies.pairing]
version = "0.23"
optional = true

[dependencies.rand_core]
version = "0.6"
default-features = false

[dependencies.subtle]
version = "2.2.1"
default-features = false

[dependencies.zeroize]
version = "1.4"
default-features = false
optional = true
sha2 = "0.10"
sha3 = "0.10"

[features]
default = ["groups", "pairings", "alloc", "bits"]
Expand All @@ -83,3 +53,13 @@ required-features = ["experimental"]
[[test]]
name = "hash_to_curve_g2"
required-features = ["experimental"]

[[bench]]
name = "groups"
harness = false
required-features = ["groups"]

[[bench]]
name = "hash_to_curve"
harness = false
required-features = ["experimental"]
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 f770b0d

Please sign in to comment.