Skip to content

Commit

Permalink
Merge pull request #2581 from ProvableHQ/do_not_hardcode_hiding_mode
Browse files Browse the repository at this point in the history
Nit: Do not hardcode the hiding mode
  • Loading branch information
zosorock authored Dec 11, 2024
2 parents b0c901d + accd1bf commit be48f30
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion algorithms/src/snark/varuna/ahp/indexer/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl<F: PrimeField, SM: SNARKMode> Circuit<F, SM> {
pub fn interpolate_matrix_evals(&self) -> Result<impl Iterator<Item = LabeledPolynomial<F>>> {
let mut iters = Vec::with_capacity(3);
for (label, evals) in [("a", &self.a_arith), ("b", &self.b_arith), ("c", &self.c_arith)] {
iters.push(MatrixArithmetization::new(&self.id, label, evals)?.into_iter());
iters.push(MatrixArithmetization::new::<SM>(&self.id, label, evals)?.into_iter());
}
Ok(iters.into_iter().flatten())
}
Expand Down
14 changes: 9 additions & 5 deletions algorithms/src/snark/varuna/ahp/matrices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::{
polycommit::sonic_pc::LabeledPolynomial,
r1cs::{ConstraintSystem, Index as VarIndex},
snark::varuna::{
VarunaHidingMode,
SNARKMode,
ahp::{AHPForR1CS, CircuitId, indexer::Matrix},
},
};
Expand Down Expand Up @@ -210,7 +210,11 @@ pub struct MatrixArithmetization<F: PrimeField> {

impl<F: PrimeField> MatrixArithmetization<F> {
/// Create a new MatrixArithmetization
pub fn new(id: &CircuitId, label: &str, matrix_evals: &MatrixEvals<F>) -> Result<MatrixArithmetization<F>> {
pub fn new<SM: SNARKMode>(
id: &CircuitId,
label: &str,
matrix_evals: &MatrixEvals<F>,
) -> Result<MatrixArithmetization<F>> {
let interpolate_time = start_timer!(|| "Interpolating on K");
let non_zero_domain = matrix_evals.domain()?;
let row = matrix_evals.row.clone().interpolate();
Expand All @@ -228,7 +232,7 @@ impl<F: PrimeField> MatrixArithmetization<F> {
let row_col_val = matrix_evals.row_col_val.clone().interpolate();
end_timer!(interpolate_time);

let mut labels = AHPForR1CS::<F, VarunaHidingMode>::index_polynomial_labels_single(label, id);
let mut labels = AHPForR1CS::<F, SM>::index_polynomial_labels_single(label, id);
ensure!(labels.len() == 4);

Ok(MatrixArithmetization {
Expand Down Expand Up @@ -266,7 +270,7 @@ pub(crate) fn transpose<F: PrimeField>(
#[cfg(test)]
mod tests {
use super::*;
use crate::snark::varuna::num_non_zero;
use crate::snark::varuna::{VarunaHidingMode, num_non_zero};
use snarkvm_curves::bls12_377::Fr as F;
use snarkvm_fields::{One, Zero};
use std::{borrow::Cow, collections::HashMap};
Expand Down Expand Up @@ -332,7 +336,7 @@ mod tests {
)
.unwrap();
let dummy_id = CircuitId([0; 32]);
let arith = MatrixArithmetization::new(&dummy_id, label, &evals).unwrap();
let arith = MatrixArithmetization::new::<VarunaHidingMode>(&dummy_id, label, &evals).unwrap();

for (k_index, k) in interpolation_domain.elements().enumerate() {
let row_val = arith.row.evaluate(k);
Expand Down

0 comments on commit be48f30

Please sign in to comment.