From 7a64cb52c45d53cd04000e27303a0f602a1f5812 Mon Sep 17 00:00:00 2001 From: "Brandon H. Gomes" Date: Mon, 11 Jul 2022 23:02:05 -0400 Subject: [PATCH] fix: add `take` to powers of tau iterator to prevent infinite allocation Signed-off-by: Brandon H. Gomes --- manta-accounting/Cargo.toml | 2 +- manta-pay/Cargo.toml | 2 +- manta-trusted-setup/src/groth16/kzg.rs | 5 +++++ manta-util/Cargo.toml | 2 +- workspace-hack/Cargo.toml | 8 ++++---- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/manta-accounting/Cargo.toml b/manta-accounting/Cargo.toml index 0e5a85de0..8eab33ddd 100644 --- a/manta-accounting/Cargo.toml +++ b/manta-accounting/Cargo.toml @@ -54,7 +54,7 @@ test = [ [dependencies] bitflags = { version = "1.3.2", optional = true, default-features = false } -cocoon = { version = "0.3.0", optional = true, default-features = false } +cocoon = { version = "0.3.1", optional = true, default-features = false } derivative = { version = "2.2.0", default-features = false, features = ["use_core"] } derive_more = { version = "0.99.16", default-features = false, features = ["add", "add_assign", "display", "from", "sum"] } futures = { version = "0.3.21", optional = true, default-features = false, features = ["alloc"] } diff --git a/manta-pay/Cargo.toml b/manta-pay/Cargo.toml index 4bafc6ea9..5869f192e 100644 --- a/manta-pay/Cargo.toml +++ b/manta-pay/Cargo.toml @@ -117,7 +117,7 @@ ark-std = { version = "0.3.0", optional = true, default-features = false } bip32 = { version = "0.3.0", optional = true, default-features = false, features = ["bip39", "secp256k1"] } blake2 = { version = "0.10.4", default-features = false } bs58 = { version = "0.4.0", optional = true, default-features = false, features = ["alloc"] } -clap = { version = "3.2.8", optional = true, default-features = false, features = ["color", "derive", "std", "suggestions", "unicode", "wrap_help"] } +clap = { version = "3.2.10", optional = true, default-features = false, features = ["color", "derive", "std", "suggestions", "unicode", "wrap_help"] } derivative = { version = "2.2.0", default-features = false, features = ["use_core"] } futures = { version = "0.3.21", optional = true, default-features = false } indexmap = { version = "1.8.2", optional = true, default-features = false } diff --git a/manta-trusted-setup/src/groth16/kzg.rs b/manta-trusted-setup/src/groth16/kzg.rs index 711f484b5..22e22b72e 100644 --- a/manta-trusted-setup/src/groth16/kzg.rs +++ b/manta-trusted-setup/src/groth16/kzg.rs @@ -34,9 +34,13 @@ use rayon::iter::{IndexedParallelIterator, ParallelIterator}; /// KZG Trusted Setup Size pub trait Size { /// Number of G1 Powers to Produce + /// + /// The number of G1 powers must be greater than or equal to the number of G2 powers. const G1_POWERS: usize; /// Number of G2 Powers to Produce + /// + /// The number of G2 powers must be smaller than or equal to the number of G1 powers. const G2_POWERS: usize; } @@ -523,6 +527,7 @@ where pub fn update(&mut self, contribution: &Contribution) { let mut tau_powers = iter::successors(Some(C::Scalar::one()), |x| Some(x.mul(contribution.tau))) + .take(C::G1_POWERS) .collect::>(); let remaining_tau_powers = tau_powers.split_off(C::G2_POWERS); cfg_iter_mut!(self.tau_powers_g1) diff --git a/manta-util/Cargo.toml b/manta-util/Cargo.toml index 12e8ee7b9..1e0df1227 100644 --- a/manta-util/Cargo.toml +++ b/manta-util/Cargo.toml @@ -40,6 +40,6 @@ std = ["alloc"] [dependencies] crossbeam-channel = { version = "0.5.4", optional = true, default-features = false } rayon = { version = "1.5.3", optional = true, default-features = false } -serde = { version = "1.0.138", optional = true, default-features = false, features = ["derive"] } +serde = { version = "1.0.139", optional = true, default-features = false, features = ["derive"] } serde_with = { version = "1.14.0", optional = true, default-features = false, features = ["macros"] } workspace-hack = { version = "0.1.0", path = "../workspace-hack" } diff --git a/workspace-hack/Cargo.toml b/workspace-hack/Cargo.toml index c2549c617..b7d9e3f2e 100644 --- a/workspace-hack/Cargo.toml +++ b/workspace-hack/Cargo.toml @@ -19,7 +19,7 @@ anyhow = { version = "1.0.58", features = ["std"] } bitflags = { version = "1.3.2" } blake3 = { version = "1.3.1", default-features = false, features = ["digest", "std"] } block-buffer = { version = "0.9.0", default-features = false, features = ["block-padding"] } -crypto-common = { version = "0.1.4", default-features = false, features = ["std"] } +crypto-common = { version = "0.1.5", default-features = false, features = ["std"] } digest-93f6ce9d446188ac = { package = "digest", version = "0.10.3", features = ["alloc", "block-buffer", "core-api", "mac", "std", "subtle"] } digest-274715c4dabd11b0 = { package = "digest", version = "0.9.0", default-features = false, features = ["alloc", "std"] } futures = { version = "0.3.21", features = ["alloc", "async-await", "executor", "futures-executor", "std"] } @@ -40,7 +40,7 @@ ppv-lite86 = { version = "0.2.16", default-features = false, features = ["simd", rand = { version = "0.8.5", features = ["alloc", "getrandom", "libc", "rand_chacha", "std", "std_rng"] } rand_chacha = { version = "0.3.1", default-features = false, features = ["std"] } rand_core = { version = "0.6.3", default-features = false, features = ["alloc", "getrandom", "std"] } -serde = { version = "1.0.138", features = ["alloc", "derive", "serde_derive", "std"] } +serde = { version = "1.0.139", features = ["alloc", "derive", "serde_derive", "std"] } serde_json = { version = "1.0.82", features = ["alloc", "std"] } sha2 = { version = "0.9.9", features = ["std"] } standback = { version = "0.2.17", default-features = false, features = ["std"] } @@ -53,12 +53,12 @@ zeroize = { version = "1.5.6", default-features = false, features = ["alloc", "z anyhow = { version = "1.0.58", features = ["std"] } blake3 = { version = "1.3.1", default-features = false, features = ["digest", "std"] } cc = { version = "1.0.73", default-features = false, features = ["jobserver", "parallel"] } -crypto-common = { version = "0.1.4", default-features = false, features = ["std"] } +crypto-common = { version = "0.1.5", default-features = false, features = ["std"] } digest-93f6ce9d446188ac = { package = "digest", version = "0.10.3", features = ["alloc", "block-buffer", "core-api", "mac", "std", "subtle"] } generic-array = { version = "0.14.5", default-features = false, features = ["more_lengths"] } log = { version = "0.4.17", default-features = false, features = ["kv_unstable", "kv_unstable_std", "std", "value-bag"] } num-traits = { version = "0.2.15", features = ["i128", "libm", "std"] } -serde = { version = "1.0.138", features = ["alloc", "derive", "serde_derive", "std"] } +serde = { version = "1.0.139", features = ["alloc", "derive", "serde_derive", "std"] } standback = { version = "0.2.17", default-features = false, features = ["std"] } subtle = { version = "2.4.1", default-features = false, features = ["i128"] } syn = { version = "1.0.98", features = ["clone-impls", "derive", "extra-traits", "fold", "full", "parsing", "printing", "proc-macro", "quote", "visit", "visit-mut"] }