From 9774b74b90a5b7a14bcbd22ea57b24f94746db32 Mon Sep 17 00:00:00 2001 From: Nicholas Ward Date: Tue, 15 Nov 2022 15:36:15 -0800 Subject: [PATCH] Blake progress --- .../cpu/kernel/asm/hash/blake/compression.asm | 3 ++- evm/src/cpu/kernel/tests/hash.rs | 16 +++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/evm/src/cpu/kernel/asm/hash/blake/compression.asm b/evm/src/cpu/kernel/asm/hash/blake/compression.asm index 8903f8e3..a0303aa4 100644 --- a/evm/src/cpu/kernel/asm/hash/blake/compression.asm +++ b/evm/src/cpu/kernel/asm/hash/blake/compression.asm @@ -216,4 +216,5 @@ compression_loop: %blake_generate_new_hash_value(1) %blake_generate_new_hash_value(0) // stack: h_0', h_1', h_2', h_3', h_4', h_5', h_6', h_7', retdest - STOP \ No newline at end of file + %stack (hash: 8, retdest) -> (retdest, hash) + JUMP \ No newline at end of file diff --git a/evm/src/cpu/kernel/tests/hash.rs b/evm/src/cpu/kernel/tests/hash.rs index 4a4cf42e..68efaa27 100644 --- a/evm/src/cpu/kernel/tests/hash.rs +++ b/evm/src/cpu/kernel/tests/hash.rs @@ -59,38 +59,36 @@ fn make_input_stack(message: Vec) -> Vec { fn test_hash(hash_fn_label: &str, standard_implementation: &dyn Fn(Vec) -> U256) -> Result<()> { // Make the input. let message_random = make_random_input(); - // let message_custom = make_custom_input(); + let message_custom = make_custom_input(); dbg!(message_random.clone()); // Hash the message using a standard implementation. - // let expected_random = standard_implementation(message_random.clone()); - // let expected_custom = standard_implementation(message_custom.clone()); + let expected_random = standard_implementation(message_random.clone()); + let expected_custom = standard_implementation(message_custom.clone()); // Load the message onto the stack. let initial_stack_random = make_input_stack(message_random); - // let initial_stack_custom = make_input_stack(message_custom); + let initial_stack_custom = make_input_stack(message_custom); dbg!(initial_stack_random.clone()); // Make the kernel. let kernel_function = KERNEL.global_labels[hash_fn_label]; - dbg!("HERE"); - // Run the kernel code. let result_random = run_interpreter(kernel_function, initial_stack_random)?; - // let result_custom = run_interpreter(kernel_function, initial_stack_custom)?; + let result_custom = run_interpreter(kernel_function, initial_stack_custom)?; dbg!(result_random.stack()); // Extract the final output. let actual_random = result_random.stack()[0]; - // let actual_custom = result_custom.stack()[0]; + let actual_custom = result_custom.stack()[0]; // Check that the result is correct. // assert_eq!(expected_random, actual_random); - // assert_eq!(expected_custom, actual_custom); + assert_eq!(expected_custom, actual_custom); Ok(()) }