Skip to content

Commit be4d2d8

Browse files
shuklaayushbranch-rebase-bot[bot]
authored andcommitted
chore: revert old keccak example
1 parent bf08d6a commit be4d2d8

File tree

5 files changed

+27
-20
lines changed

5 files changed

+27
-20
lines changed

crates/toolchain/transpiler/src/extension.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ pub trait TranspilerExtension<F> {
1414
fn process_custom(&self, instruction_stream: &[u32]) -> Option<TranspilerOutput<F>>;
1515
}
1616

17-
#[derive(Debug)]
1817
pub struct TranspilerOutput<F> {
1918
pub instructions: Vec<Option<Instruction<F>>>,
2019
pub used_u32s: usize,

examples/keccak/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ openvm = { git = "https://github.com/openvm-org/openvm.git", features = [
1212
] }
1313
openvm-keccak256 = { git = "https://github.com/openvm-org/openvm.git" }
1414
hex = { version = "0.4.3" }
15-
tiny-keccak = { git = "https://github.com/openvm-org/tiny-keccak.git", features = ["keccak"] }
16-
openvm-new-keccak256-guest = { path = "../../extensions/new-keccak256/guest" }
1715

1816
[features]
1917
default = []
@@ -22,4 +20,3 @@ default = []
2220
[patch."https://github.com/openvm-org/openvm.git"]
2321
openvm = { path = "../../crates/toolchain/openvm" }
2422
openvm-keccak256 = { path = "../../guest-libs/keccak256" }
25-

examples/keccak/openvm.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[app_vm_config.rv32i]
22
[app_vm_config.rv32m]
33
[app_vm_config.io]
4-
[app_vm_config.new_keccak]
4+
[app_vm_config.keccak]

examples/keccak/src/main.rs

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
// [!region imports]
2+
use core::hint::black_box;
3+
4+
use hex::FromHex;
25
use openvm as _;
6+
use openvm_keccak256::keccak256;
37
// [!endregion imports]
48

59
// [!region main]
6-
7-
// todo: call the forked tiny keccak library once that is updated instead of directly calling the
8-
// keccak256_guest native functions
910
pub fn main() {
10-
#[cfg(target_os = "zkvm")]
11-
{
12-
let mut buffer = [1u8; 200];
13-
let input = [2u8; 136];
14-
let output = [3u8; 136];
15-
let len: usize = 136;
16-
openvm_new_keccak256_guest::native_xorin(buffer.as_mut_ptr(), input.as_ptr(), len);
17-
assert_eq!(buffer[..136], output);
18-
openvm_new_keccak256_guest::native_keccakf(buffer.as_mut_ptr());
11+
let test_vectors = [
12+
(
13+
"",
14+
"C5D2460186F7233C927E7DB2DCC703C0E500B653CA82273B7BFAD8045D85A470",
15+
),
16+
(
17+
"CC",
18+
"EEAD6DBFC7340A56CAEDC044696A168870549A6A7F6F56961E84A54BD9970B8A",
19+
),
20+
];
21+
for (input, expected_output) in test_vectors.iter() {
22+
let input = Vec::from_hex(input).unwrap();
23+
let expected_output = Vec::from_hex(expected_output).unwrap();
24+
let output = keccak256(&black_box(input));
25+
if output != *expected_output {
26+
panic!();
27+
}
1928
}
2029
}
2130
// [!endregion main]

examples/new-keccak/src/main.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
// [!region imports]
22
use hex_literal::hex;
3-
use tiny_keccak::{Hasher, Keccak};
4-
53
#[cfg(target_os = "zkvm")]
64
use openvm as _;
5+
use tiny_keccak::{Hasher, Keccak};
76
// [!endregion imports]
87

98
// [!region main]
@@ -161,6 +160,9 @@ pub fn main() {
161160
assert_eq!(output, expected);
162161
}
163162

164-
println!("All {} keccak256 test cases passed!", KECCAK_TEST_CASES.len());
163+
println!(
164+
"All {} keccak256 test cases passed!",
165+
KECCAK_TEST_CASES.len()
166+
);
165167
}
166168
// [!endregion main]

0 commit comments

Comments
 (0)