Skip to content

Commit

Permalink
Update Hyrax with the shared state
Browse files Browse the repository at this point in the history
  • Loading branch information
autquis committed Nov 15, 2023
1 parent 8803c52 commit 2ac0e33
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
10 changes: 6 additions & 4 deletions poly-commit/src/hyrax/data_structures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ use ark_ff::PrimeField;
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
use ark_std::{rand::RngCore, vec::Vec};

use crate::{PCCommitment, PCCommitmentState, PCCommitterKey, PCUniversalParams, PCVerifierKey};
use crate::{
utils::Matrix, PCCommitment, PCCommitmentState, PCCommitterKey, PCUniversalParams,
PCVerifierKey,
};

/// `UniversalParams` amounts to a Pederson commitment key of sufficient length
#[derive(Derivative, CanonicalSerialize, CanonicalDeserialize)]
Expand Down Expand Up @@ -87,9 +90,8 @@ pub struct HyraxCommitmentState<F>
where
F: PrimeField,
{
/// blah blah blah blah
/// blah blah blah blah
pub randomness: HyraxRandomness<F>,
pub(crate) randomness: HyraxRandomness<F>,
pub(crate) mat: Matrix<F>,
}

/// A vector of scalars, each of which multiplies the distinguished group
Expand Down
8 changes: 4 additions & 4 deletions poly-commit/src/hyrax/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ impl<G: AffineRepr, P: MultilinearExtension<G::ScalarField>>
coms.push(l_comm);
states.push(HyraxCommitmentState {
randomness: com_rands,
mat: Matrix::new_from_rows(m),
});
}

Expand Down Expand Up @@ -307,7 +308,7 @@ impl<G: AffineRepr, P: MultilinearExtension<G::ScalarField>>
G::ScalarField,
PoseidonSponge<G::ScalarField>,
>,
rands: impl IntoIterator<Item = &'a Self::CommitmentState>,
states: impl IntoIterator<Item = &'a Self::CommitmentState>,
rng: Option<&mut dyn RngCore>,
) -> Result<Self::Proof, Self::Error>
where
Expand Down Expand Up @@ -343,7 +344,7 @@ impl<G: AffineRepr, P: MultilinearExtension<G::ScalarField>>

for (l_poly, (l_com, state)) in labeled_polynomials
.into_iter()
.zip(commitments.into_iter().zip(rands.into_iter()))
.zip(commitments.into_iter().zip(states.into_iter()))
{
let label = l_poly.label();
if label != l_com.label() {
Expand Down Expand Up @@ -376,8 +377,7 @@ impl<G: AffineRepr, P: MultilinearExtension<G::ScalarField>>
transcript.append_serializable_element(b"point", point)?;

// Commiting to the matrix formed by the polynomial coefficients
let t_aux = flat_to_matrix_column_major(&poly.to_evaluations(), dim, dim);
let t = Matrix::new_from_rows(t_aux);
let t = &state.mat;

let lt = t.row_mul(&l);

Expand Down
5 changes: 3 additions & 2 deletions poly-commit/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use rayon::{
};

use ark_ff::{Field, PrimeField};
use ark_serialize::CanonicalSerialize;
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
use ark_std::vec::Vec;
use merlin::Transcript;

Expand All @@ -31,7 +31,8 @@ pub(crate) fn ceil_div(x: usize, y: usize) -> usize {
(x + y - 1) / y
}

#[derive(Debug)]
#[derive(Derivative, CanonicalSerialize, CanonicalDeserialize)]
#[derivative(Default(bound = ""), Clone(bound = ""), Debug(bound = ""))]
pub(crate) struct Matrix<F: Field> {
pub(crate) n: usize,
pub(crate) m: usize,
Expand Down

0 comments on commit 2ac0e33

Please sign in to comment.