From d8d75af91209899f82b277a278cf46b5b1849073 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Sun, 21 Jul 2024 22:51:26 +0000 Subject: [PATCH 1/2] Clean up Cargo.toml --- Cargo.toml | 70 +++++++++++++++++++----------------------------------- 1 file changed, 25 insertions(+), 45 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 31ca30f9..234955c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,19 +1,29 @@ [package] +name = "bls12_381" +version = "0.8.0" authors = [ "Sean Bowe ", "Jack Grigg ", ] +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.9", 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 @@ -23,46 +33,6 @@ 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 - [features] default = ["groups", "pairings", "alloc", "bits"] bits = ["ff/bits"] @@ -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"] From 581d70da0dee0e2530e27539ff25f0cd559f53fb Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Sun, 21 Jul 2024 23:00:10 +0000 Subject: [PATCH 2/2] Migrate to `digest 0.10` Closes zkcrypto/bls12_381#102. --- Cargo.lock | 50 +++++++++++++++------------------ Cargo.toml | 6 ++-- RELEASES.md | 2 ++ src/hash_to_curve/expand_msg.rs | 15 +++++----- 4 files changed, 35 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9932b17b..5f5b81c0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -39,20 +39,13 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.9.0" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ - "block-padding", "generic-array", ] -[[package]] -name = "block-padding" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" - [[package]] name = "bls12_381" version = "0.8.0" @@ -201,6 +194,16 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + [[package]] name = "csv" version = "1.1.6" @@ -225,11 +228,12 @@ dependencies = [ [[package]] name = "digest" -version = "0.9.0" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "generic-array", + "block-buffer", + "crypto-common", ] [[package]] @@ -338,9 +342,9 @@ dependencies = [ [[package]] name = "keccak" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3afef3b6eff9ce9d8ff9b3601125eec7f0c8cbac7abd14f355d053fa56c98768" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" dependencies = [ "cpufeatures", ] @@ -412,12 +416,6 @@ version = "11.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - [[package]] name = "pairing" version = "0.23.0" @@ -598,27 +596,23 @@ dependencies = [ [[package]] name = "sha2" -version = "0.9.9" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ - "block-buffer", "cfg-if", "cpufeatures", "digest", - "opaque-debug", ] [[package]] name = "sha3" -version = "0.9.1" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f81199417d4e5de3f04b1e871023acea7389672c4135918f05aa9cbf2f2fa809" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" dependencies = [ - "block-buffer", "digest", "keccak", - "opaque-debug", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 234955c9..75754571 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 } @@ -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"] diff --git a/RELEASES.md b/RELEASES.md index e753d301..438ae3bb 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,4 +1,6 @@ # Unreleased +## Changed +- Bumped dependencies to `digest 0.10`. # 0.8.0 ## Changed diff --git a/src/hash_to_curve/expand_msg.rs b/src/hash_to_curve/expand_msg.rs index 129c7f3f..7c7c83d1 100644 --- a/src/hash_to_curve/expand_msg.rs +++ b/src/hash_to_curve/expand_msg.rs @@ -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::{ @@ -47,7 +48,7 @@ impl ExpandMsgDst { /// is used when handling DST values longer than 255 bytes. fn for_xof(dst: &[u8]) -> Self where - H: Default + Update + ExtendableOutput, + H: Default + ExtendableOutput, L: ArrayLength + IsLess, { let input_len = dst.len(); @@ -72,7 +73,7 @@ impl ExpandMsgDst { /// reduce domain separation tags that are longer than 255 bytes. fn for_xmd(dst: &[u8]) -> Self where - H: Default + FixedOutput + Update, + H: Default + FixedOutput, H::OutputSize: IsLess, { let input_len = dst.len(); @@ -178,7 +179,7 @@ impl Debug for ExpandMsgXof { impl ExpandMessage for ExpandMsgXof where - H: Default + ExtendableOutput + Update, + H: Default + ExtendableOutput, { fn init_expand(message: M, dst: &[u8], len_in_bytes: usize) -> Self where @@ -245,7 +246,7 @@ impl Debug for ExpandMsgXmd { impl ExpandMessage for ExpandMsgXmd where - H: Default + BlockInput + FixedOutput + Update, + H: Default + BlockSizeUser + FixedOutput, H::OutputSize: IsLess, { fn init_expand(message: M, dst: &[u8], len_in_bytes: usize) -> Self @@ -253,7 +254,7 @@ where M: Message, L: ArrayLength + IsLess, { - let hash_size = ::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"); @@ -264,7 +265,7 @@ where let dst = ExpandMsgDst::for_xmd::(dst); let mut hash_b_0 = - H::default().chain(GenericArray::::BlockSize>::default()); + H::default().chain(GenericArray::::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())