Skip to content

Commit

Permalink
Keccakf fixed generator fully working
Browse files Browse the repository at this point in the history
  • Loading branch information
hecmas committed Jan 23, 2025
1 parent 601b448 commit ded4962
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
Binary file added precompiles/keccakf/src/keccakf_fixed_21.bin
Binary file not shown.
36 changes: 18 additions & 18 deletions precompiles/keccakf/src/keccakf_fixed_gen.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use std::{env, error::Error, fs};

use p3_field::{AbstractField, PrimeField64};
use p3_field::AbstractField;
use p3_goldilocks::Goldilocks;
use serde::de::DeserializeOwned;

use proofman_common::{write_fixed_cols_bin, FixedColsInfo};

Check failure on line 7 in precompiles/keccakf/src/keccakf_fixed_gen.rs

View workflow job for this annotation

GitHub Actions / Docker Risc Oficial Tests Check

unresolved imports `proofman_common::write_fixed_cols_bin`, `proofman_common::FixedColsInfo`

Check failure on line 7 in precompiles/keccakf/src/keccakf_fixed_gen.rs

View workflow job for this annotation

GitHub Actions / Test on x86_64

unresolved imports `proofman_common::write_fixed_cols_bin`, `proofman_common::FixedColsInfo`

mod goldilocks_constants;
mod keccakf_types;

Expand Down Expand Up @@ -35,24 +37,22 @@ fn main() -> Result<(), Box<dyn Error>> {
let (conn_a, conn_b, conn_c, gate_op) =
cols_gen(n, subgroup_gen, cosets_gen, connections, script);

// Serialize the columns
// TODO: N, Name, Pos (if array) and Values
let mut data = Vec::new();
data.extend(conn_a.iter().flat_map(|f| f.as_canonical_u64().to_le_bytes()));
data.extend(conn_b.iter().flat_map(|f| f.as_canonical_u64().to_le_bytes()));
data.extend(conn_c.iter().flat_map(|f| f.as_canonical_u64().to_le_bytes()));
data.extend(gate_op.iter().flat_map(|f| f.as_canonical_u64().to_le_bytes()));

// Write to binary
let output_file = "precompiles/keccakf/src/keccakf_fixed.bin";
write_binary(output_file, &data)?;
println!("Fixed columns written to {}", output_file);

Ok(())
}
// Serialize the columns and write them to a binary file
let conn_a = FixedColsInfo::new("Keccakf.CONN_A", None, conn_a);
let conn_b = FixedColsInfo::new("Keccakf.CONN_B", None, conn_b);
let conn_c = FixedColsInfo::new("Keccakf.CONN_C", None, conn_c);
let gate_op = FixedColsInfo::new("Keccakf.GATE_OP", None, gate_op);

let output_file = format!("precompiles/keccakf/src/keccakf_fixed_{}.bin", bits);
write_fixed_cols_bin(
&output_file,
"Zisk",
"Keccakf",
n as u64,
&mut [conn_a, conn_b, conn_c, gate_op],
);
println!("CONN_A, CONN_B, CONN_C and GATE_OP columns written to {}", output_file);

fn write_binary(file_path: &str, data: &[u8]) -> Result<(), Box<dyn Error>> {
fs::write(file_path, data)?;
Ok(())
}

Expand Down
4 changes: 2 additions & 2 deletions precompiles/zisk_precompiles/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use std::{collections::HashMap, sync::Arc};

use precomp_keccakf::KECCAK_OPCODE;
// use precomp_keccakf::KECCAK_OPCODE;
use precompiles_common::{PrecompileCall, PrecompileCode};

pub fn precompiles_map() -> HashMap<PrecompileCode, Arc<dyn PrecompileCall>> {
let mut registry = HashMap::new();

Check warning on line 7 in precompiles/zisk_precompiles/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test on x86_64

variable does not need to be mutable

registry.insert(KECCAK_OPCODE.into(), Arc::new(Keccak256Precompile::new()));
// registry.insert(KECCAK_OPCODE.into(), Arc::new(Keccak256Precompile::new()));

registry
}

0 comments on commit ded4962

Please sign in to comment.