Skip to content

Commit

Permalink
Rename mix_nonce -> mix_u64 (#828)
Browse files Browse the repository at this point in the history
  • Loading branch information
alonh5 authored Sep 9, 2024
1 parent 2abcb2b commit 215b1cd
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion crates/prover/src/core/backend/cpu/grind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ impl<C: Channel> GrindOps<C> for CpuBackend {
let mut nonce = 0;
loop {
let mut channel = channel.clone();
channel.mix_nonce(nonce);
channel.mix_u64(nonce);
if channel.trailing_zeros() >= pow_bits {
return nonce;
}
Expand Down
2 changes: 1 addition & 1 deletion crates/prover/src/core/backend/simd/grind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl GrindOps<Poseidon252Channel> for SimdBackend {
let mut nonce = 0;
loop {
let mut channel = channel.clone();
channel.mix_nonce(nonce);
channel.mix_u64(nonce);
if channel.trailing_zeros() >= pow_bits {
return nonce;
}
Expand Down
2 changes: 1 addition & 1 deletion crates/prover/src/core/channel/blake2s.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl Channel for Blake2sChannel {
self.update_digest(hasher.finalize());
}

fn mix_nonce(&mut self, nonce: u64) {
fn mix_u64(&mut self, nonce: u64) {
let digest: [u32; 8] = unsafe { std::mem::transmute(self.digest) };
let mut msg = [0; 16];
msg[0] = nonce as u32;
Expand Down
2 changes: 1 addition & 1 deletion crates/prover/src/core/channel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub trait Channel: Default + Clone {

// Mix functions.
fn mix_felts(&mut self, felts: &[SecureField]);
fn mix_nonce(&mut self, nonce: u64);
fn mix_u64(&mut self, value: u64);

// Draw functions.
fn draw_felt(&mut self) -> SecureField;
Expand Down
2 changes: 1 addition & 1 deletion crates/prover/src/core/channel/poseidon252.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl Channel for Poseidon252Channel {
self.update_digest(poseidon_hash_many(&res));
}

fn mix_nonce(&mut self, nonce: u64) {
fn mix_u64(&mut self, nonce: u64) {
self.update_digest(poseidon_hash(self.digest, nonce.into()));
}

Expand Down
2 changes: 1 addition & 1 deletion crates/prover/src/core/pcs/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl<'a, B: BackendForChannel<MC>, MC: MerkleChannel> CommitmentSchemeProver<'a,
let span1 = span!(Level::INFO, "Grind").entered();
let proof_of_work = B::grind(channel, self.config.pow_bits);
span1.exit();
channel.mix_nonce(proof_of_work);
channel.mix_u64(proof_of_work);

// FRI decommitment phase.
let (fri_proof, fri_query_domains) = fri_prover.decommit(channel);
Expand Down
2 changes: 1 addition & 1 deletion crates/prover/src/core/pcs/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl<MC: MerkleChannel> CommitmentSchemeVerifier<MC> {
FriVerifier::<MC>::commit(channel, self.config.fri_config, proof.fri_proof, bounds)?;

// Verify proof of work.
channel.mix_nonce(proof.proof_of_work);
channel.mix_u64(proof.proof_of_work);
if channel.trailing_zeros() < self.config.pow_bits {
return Err(VerificationError::ProofOfWork);
}
Expand Down
3 changes: 1 addition & 2 deletions crates/prover/src/examples/blake/air.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ impl BlakeStatement0 {
TreeVec::concat_cols(sizes.into_iter())
}
fn mix_into(&self, channel: &mut impl Channel) {
// TODO(spapini): Do this better.
channel.mix_nonce(self.log_size as u64);
channel.mix_u64(self.log_size as u64);
}
}

Expand Down

0 comments on commit 215b1cd

Please sign in to comment.