Skip to content

Commit

Permalink
chore: Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
storojs72 committed Sep 24, 2024
1 parent 35085fb commit 430087a
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 72 deletions.
54 changes: 27 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ getrandom = "=0.2.14" # 0.2.15 depends on yanked libc 0.2.154
hashbrown = { version = "0.14.5", features = ["serde"] }
hex = "0.4.3"
home = "0.5.9"
hybrid-array = "0.2.0-rc.9"
hybrid-array = "0.2.0-rc"
indicatif = "0.17.8"
itertools = "0.12.1"
k256 = "0.13.3"
Expand Down
5 changes: 3 additions & 2 deletions core/src/stark/air.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ impl<F: PrimeField32> RiscvAir<F> {
chips.push(RiscvAir::Bls12381Fp2Op(bls12381_fp2_op));
let bls12381_g1_decompress = Bls12381G1DecompressChip::new();
chips.push(RiscvAir::Bls12381G1Decompress(bls12381_g1_decompress));
let blake_2s_round = Blake2sRoundChip::new();
chips.push(RiscvAir::Blake2sRound(blake_2s_round));

let div_rem = DivRemChip;
chips.push(RiscvAir::DivRem(div_rem));

Expand All @@ -184,8 +187,6 @@ impl<F: PrimeField32> RiscvAir<F> {
chips.push(RiscvAir::ProgramMemory(program_memory_init));
let byte = ByteChip::default();
chips.push(RiscvAir::ByteLookup(byte));
let blake_2s_round = Blake2sRoundChip::new();
chips.push(RiscvAir::Blake2sRound(blake_2s_round));

chips
}
Expand Down
2 changes: 0 additions & 2 deletions core/src/syscall/precompiles/blake2s/air.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,6 @@ where
);
}

self.constrain_shuffled_indices(builder, &local.shuffled_indices, local.is_real);

for i in 0..4usize {
// 3x

Expand Down
2 changes: 0 additions & 2 deletions core/src/syscall/precompiles/blake2s/columns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ pub struct Blake2sRoundCols<T> {
pub a_ptr: T,
pub b_ptr: T,

pub shuffled_indices: [T; 16],

/// Memory layout:
/// a: v0[0] || v0[1] || v0[2] || v0[3] ||
/// v1[0] || v1[1] || v1[2] || v1[3] ||
Expand Down
20 changes: 0 additions & 20 deletions core/src/syscall/precompiles/blake2s/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ mod trace;
pub use columns::*;

use crate::runtime::{MemoryReadRecord, MemoryWriteRecord};
use crate::stark::SphinxAirBuilder;
use p3_air::AirBuilder;
use p3_field::AbstractField;
use serde::Deserialize;
use serde::Serialize;

Expand All @@ -31,23 +28,6 @@ impl Blake2sRoundChip {
pub fn new() -> Self {
Blake2sRoundChip
}
pub fn constrain_shuffled_indices<AB: SphinxAirBuilder>(
&self,
builder: &mut AB,
indices: &[AB::Var],
is_real: AB::Var,
) {
for index in 0..4 {
builder
.when(is_real)
.assert_eq(indices[index], AB::F::from_canonical_usize(0));
}
for index in 4..indices.len() {
builder
.when(is_real)
.assert_eq(indices[index], AB::F::from_canonical_usize(1));
}
}
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down
4 changes: 0 additions & 4 deletions core/src/syscall/precompiles/blake2s/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,6 @@ impl<F: PrimeField32> MachineAir<F> for Blake2sRoundChip {

// 3x (m2, R1, R2)
for i in 0..4usize {
cols.shuffled_indices[i + 4] = F::from_canonical_u32(1);
cols.shuffled_indices[i + 8] = F::from_canonical_u32(1);
cols.shuffled_indices[i + 12] = F::from_canonical_u32(1);

let v0 = v0_outer[i];
let v1 = v1_outer[i];
let v2 = v2_outer[i];
Expand Down
10 changes: 5 additions & 5 deletions core/src/utils/prove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,11 +356,11 @@ where
OpeningProof<SC>: Send + Sync,
ShardMainData<SC>: Serialize + DeserializeOwned,
{
//#[cfg(debug_assertions)]
//{
let record_clone = record.clone();
machine.debug_constraints(pk, record_clone);
//}
#[cfg(debug_assertions)]
{
let record_clone = record.clone();
machine.debug_constraints(pk, record_clone);
}
let stats = record.stats().clone();
let cycles = stats.get("cpu_events").unwrap();

Expand Down
10 changes: 1 addition & 9 deletions zkvm/precompiles/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,5 @@ extern "C" {
pub fn sys_alloc_aligned(bytes: usize, align: usize) -> *mut u8;
pub fn syscall_bls12381_g2_add(p: *mut u32, q: *const u32);
pub fn syscall_bls12381_g2_double(p: *mut u32);
pub fn syscall_blake2s_xor_rotate_16(w: *mut u32);

pub fn syscall_blake2s_add_2(left: *mut u32, right: *const u32);
pub fn syscall_blake2s_add_3(left: *mut u32, right: *const u32);
pub fn syscall_blake2s_xor_rotate_right_16(left: *mut u32, right: *const u32);
pub fn syscall_blake2s_xor_rotate_right_12(left: *mut u32, right: *const u32);
pub fn syscall_blake2s_xor_rotate_right_8(left: *mut u32, right: *const u32);
pub fn syscall_blake2s_xor_rotate_right_7(left: *mut u32, right: *const u32);
pub fn syscall_blake2s_quarter_round(left: *mut u32, right: *const u32);
pub fn syscall_blake2s_round(left: *mut u32, right: *const u32);
}

0 comments on commit 430087a

Please sign in to comment.