Skip to content

Commit

Permalink
Clarify we compare ProvingKey by circuitId
Browse files Browse the repository at this point in the history
  • Loading branch information
vicsn committed Sep 29, 2023
1 parent a58ab11 commit b601084
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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, Eq)]
pub struct CircuitProvingKey<E: PairingEngine, SM: SNARKMode> {
/// The circuit verifying key.
pub circuit_verifying_key: CircuitVerifyingKey<E>,
Expand Down Expand Up @@ -58,6 +58,12 @@ impl<E: PairingEngine, SM: SNARKMode> FromBytes for CircuitProvingKey<E, SM> {
}
}

impl<E: PairingEngine, SM: SNARKMode> PartialEq for CircuitProvingKey<E, SM> {
fn eq(&self, other: &Self) -> bool {
self.circuit.id == other.circuit.id
}
}

impl<E: PairingEngine, SM: SNARKMode> Ord for CircuitProvingKey<E, SM> {
fn cmp(&self, other: &Self) -> Ordering {
self.circuit.id.cmp(&other.circuit.id)
Expand Down
10 changes: 8 additions & 2 deletions synthesizer/snark/src/proving_key/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ mod serialize;

use std::collections::BTreeMap;

#[derive(Clone, PartialEq, Eq)]
#[derive(Clone, Eq)]
pub struct ProvingKey<N: Network> {
/// The proving key for the function.
proving_key: Arc<varuna::CircuitProvingKey<N::PairingCurve, varuna::VarunaHidingMode>>,
Expand Down Expand Up @@ -92,9 +92,15 @@ impl<N: Network> Deref for ProvingKey<N> {
}
}

impl<N: Network> PartialEq for ProvingKey<N> {
fn eq(&self, other: &Self) -> bool {
self.deref() == other.deref()
}
}

impl<N: Network> Ord for ProvingKey<N> {
fn cmp(&self, other: &Self) -> Ordering {
(&self).cmp(&other)
self.deref().cmp(other.deref())
}
}

Expand Down

0 comments on commit b601084

Please sign in to comment.