From 2c2eb01d6b9ab094ec37fef75498667bfa10fad9 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Mon, 4 Dec 2023 13:46:47 +0100 Subject: [PATCH 1/4] cleanup: thin out the derives of CommitterKey Signed-off-by: ljedrz --- algorithms/src/polycommit/sonic_pc/data_structures.rs | 2 +- .../varuna/data_structures/circuit_proving_key.rs | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/algorithms/src/polycommit/sonic_pc/data_structures.rs b/algorithms/src/polycommit/sonic_pc/data_structures.rs index 25fbbd8292..6ef7c58b83 100644 --- a/algorithms/src/polycommit/sonic_pc/data_structures.rs +++ b/algorithms/src/polycommit/sonic_pc/data_structures.rs @@ -36,7 +36,7 @@ pub type Randomness = kzg10::KZGRandomness; pub type Commitment = kzg10::KZGCommitment; /// `CommitterKey` is used to commit to, and create evaluation proofs for, a given polynomial. -#[derive(Clone, Debug, Default, Hash, CanonicalSerialize, CanonicalDeserialize, PartialEq, Eq)] +#[derive(Debug)] pub struct CommitterKey { /// The key used to commit to polynomials. pub powers_of_beta_g: Vec, diff --git a/algorithms/src/snark/varuna/data_structures/circuit_proving_key.rs b/algorithms/src/snark/varuna/data_structures/circuit_proving_key.rs index 1adb86b2c8..5848743d0f 100644 --- a/algorithms/src/snark/varuna/data_structures/circuit_proving_key.rs +++ b/algorithms/src/snark/varuna/data_structures/circuit_proving_key.rs @@ -27,7 +27,7 @@ use snarkvm_utilities::{ use std::{cmp::Ordering, sync::Arc}; /// Proving key for a specific circuit (i.e., R1CS matrices). -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug)] pub struct CircuitProvingKey { /// The circuit verifying key. pub circuit_verifying_key: CircuitVerifyingKey, @@ -58,6 +58,14 @@ impl FromBytes for CircuitProvingKey { } } +impl PartialEq for CircuitProvingKey { + fn eq(&self, other: &Self) -> bool { + self.circuit.id == other.circuit.id + } +} + +impl Eq for CircuitProvingKey {} + impl Ord for CircuitProvingKey { fn cmp(&self, other: &Self) -> Ordering { self.circuit.id.cmp(&other.circuit.id) From cb6f6c56ba13631ba3dc146cc1121fdccbcf9188 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Tue, 5 Dec 2023 12:20:52 +0100 Subject: [PATCH 2/4] perf: make sure PowersOfBetaG doesn't get deep-cloned Signed-off-by: ljedrz --- parameters/src/testnet3/powers.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parameters/src/testnet3/powers.rs b/parameters/src/testnet3/powers.rs index 6559a18c83..8c36656266 100644 --- a/parameters/src/testnet3/powers.rs +++ b/parameters/src/testnet3/powers.rs @@ -57,7 +57,7 @@ lazy_static::lazy_static! { } /// A vector of powers of beta G. -#[derive(Debug, Clone)] +#[derive(Debug)] pub struct PowersOfG { /// The powers of beta G. powers_of_beta_g: PowersOfBetaG, @@ -224,7 +224,7 @@ impl ToBytes for PowersOfG { } } -#[derive(Debug, Clone, CanonicalSerialize, CanonicalDeserialize)] +#[derive(Debug, CanonicalSerialize, CanonicalDeserialize)] pub struct PowersOfBetaG { /// Group elements of form `[G, \beta * G, \beta^2 * G, ..., \beta^d G]`. powers_of_beta_g: Vec, From fcd4c1e7f043a8edd2e89ee2e71d4afb0a1c21e8 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Sat, 2 Dec 2023 21:55:03 +0100 Subject: [PATCH 3/4] perf: make sure MatrixEvals doesn't get deep-cloned Signed-off-by: ljedrz --- algorithms/src/snark/varuna/ahp/indexer/circuit.rs | 2 +- algorithms/src/snark/varuna/ahp/matrices.rs | 2 +- utilities/src/serialize/impls.rs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/algorithms/src/snark/varuna/ahp/indexer/circuit.rs b/algorithms/src/snark/varuna/ahp/indexer/circuit.rs index 5bb6fae41b..1aeb368e34 100644 --- a/algorithms/src/snark/varuna/ahp/indexer/circuit.rs +++ b/algorithms/src/snark/varuna/ahp/indexer/circuit.rs @@ -62,7 +62,7 @@ impl CircuitId { /// public input /// 2) `{a,b,c}` are the matrices defining the R1CS instance /// 3) `{a,b,c}_arith` are structs containing information about the arithmetized matrices -#[derive(Clone, Debug)] +#[derive(Debug)] pub struct Circuit { /// Information about the indexed circuit. pub index_info: CircuitInfo, diff --git a/algorithms/src/snark/varuna/ahp/matrices.rs b/algorithms/src/snark/varuna/ahp/matrices.rs index 2f998f556b..567768183b 100644 --- a/algorithms/src/snark/varuna/ahp/matrices.rs +++ b/algorithms/src/snark/varuna/ahp/matrices.rs @@ -93,7 +93,7 @@ pub(crate) fn pad_input_for_indexer_and_prover { /// Evaluations of the `row` polynomial. pub row: EvaluationsOnDomain, diff --git a/utilities/src/serialize/impls.rs b/utilities/src/serialize/impls.rs index b82d668167..dccc02981e 100644 --- a/utilities/src/serialize/impls.rs +++ b/utilities/src/serialize/impls.rs @@ -306,7 +306,7 @@ impl CanonicalSerialize for Rc { // } // } -impl CanonicalSerialize for Arc { +impl CanonicalSerialize for Arc { #[inline] fn serialize_with_mode(&self, mut writer: W, compress: Compress) -> Result<(), SerializationError> { self.as_ref().serialize_with_mode(&mut writer, compress) @@ -334,7 +334,7 @@ impl Valid for Arc { } } -impl CanonicalDeserialize for Arc { +impl CanonicalDeserialize for Arc { #[inline] fn deserialize_with_mode( reader: R, From c08cd37383ff19321964a2b5d58d87643f668c8b Mon Sep 17 00:00:00 2001 From: ljedrz Date: Tue, 5 Dec 2023 14:44:20 +0100 Subject: [PATCH 4/4] cleanup: thin out the derives of CommitterUnionKey Signed-off-by: ljedrz --- algorithms/src/polycommit/sonic_pc/data_structures.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/algorithms/src/polycommit/sonic_pc/data_structures.rs b/algorithms/src/polycommit/sonic_pc/data_structures.rs index 6ef7c58b83..6504d198fa 100644 --- a/algorithms/src/polycommit/sonic_pc/data_structures.rs +++ b/algorithms/src/polycommit/sonic_pc/data_structures.rs @@ -271,7 +271,7 @@ impl CommitterKey { } /// `CommitterUnionKey` is a union of `CommitterKey`s, useful for multi-circuit batch proofs. -#[derive(Clone, Debug, Hash, PartialEq, Eq)] +#[derive(Debug)] pub struct CommitterUnionKey<'a, E: PairingEngine> { /// The key used to commit to polynomials. pub powers_of_beta_g: Option<&'a Vec>,