Skip to content

Commit

Permalink
feat: reproducible secp failure
Browse files Browse the repository at this point in the history
  • Loading branch information
ratankaliani committed Sep 30, 2024
1 parent 9eebf51 commit ae59666
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
Binary file modified elf/range-elf
Binary file not shown.
5 changes: 3 additions & 2 deletions scripts/prove/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,14 @@ fn build_zkvm_program(program: &str) {
}

fn main() {
let programs = vec!["fault-proof", "range"];
// let programs = vec!["fault-proof", "range"];
let programs = vec!["range"];

for program in programs {
// Note: Don't comment this out, because the Docker program depends on the native program
// for range being built.
build_native_program(program);
// build_zkvm_program(program);
build_zkvm_program(program);
}

// build_zkvm_program("aggregation");
Expand Down
21 changes: 18 additions & 3 deletions utils/client/src/precompiles/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,23 @@ pub(crate) const ANNOTATED_KZG_EVAL: PrecompileWithAddress = create_annotated_pr
revm::precompile::kzg_point_evaluation::POINT_EVALUATION,
"kzg-eval"
);
// pub(crate) const ANNOTATED_EC_RECOVER: PrecompileWithAddress =
// create_annotated_precompile!(secp256k1::ECRECOVER, "ec-recover");
pub(crate) const ANNOTATED_EC_RECOVER: PrecompileWithAddress = PrecompileWithAddress(
revm::precompile::secp256k1::ECRECOVER.0,
Precompile::Standard(|input: &Bytes, gas_limit: u64| -> PrecompileResult {
let precompile = revm::precompile::secp256k1::ECRECOVER.precompile();
match precompile {
Precompile::Standard(precompile) => {
println!("signature: {:?}", input);

println!(concat!("cycle-tracker-report-start: precompile-ec-recover"));
let result = precompile(input, gas_limit);
println!(concat!("cycle-tracker-report-end: precompile-ec-recover"));
result
}
_ => panic!("Annotated precompile must be a standard precompile."),
}
}),
);

// Source: https://github.com/anton-rs/kona/blob/main/bin/client/src/fault/handler/mod.rs#L20-L42
pub fn zkvm_handle_register<F, H>(handler: &mut EvmHandler<'_, (), &mut State<&mut TrieDB<F, H>>>)
Expand All @@ -69,7 +84,7 @@ where
ANNOTATED_BN_PAIR,
ANNOTATED_KZG_EVAL,
// Note: Removed annotations for the ec-recover precompile as it's not a large contributor to cycle count.
// ANNOTATED_EC_RECOVER,
ANNOTATED_EC_RECOVER,
];
ctx_precompiles.extend(override_precompiles);

Expand Down

0 comments on commit ae59666

Please sign in to comment.