This commit is contained in:
Dmitry Vagner 2022-09-21 16:40:27 -07:00
parent 98d9e6cae2
commit 94390c3cc7
2 changed files with 14 additions and 26 deletions

View File

@ -16,8 +16,6 @@ global ripemd_alt:
// stack: length, INPUT
%stack (length) -> (64, length, 0x80, 63, length, length)
// stack: 64, length, 0x80, 63, length, length, INPUT
%jump(0xdeadbeef)
%jump(ripemd_storage) // stores the following into memory
// init _buffer at virt 0 [consumes 64]
// store _size at virt 64 [consumes length]
@ -61,29 +59,30 @@ ripemd_2:
process:
// stack: a , b, c, d, e, count, length, virt
%flip_bytes_u32
// stack: a', b, c, d, e, *vars
// stack: a', b, c, d, e, VARS
SWAP1
%flip_bytes_u32
%shl_const(32)
OR
// stack: b' a', c, d, e, *vars
// stack: b' a', c, d, e, VARS
SWAP1
%flip_bytes_u32
%shl_const(64)
OR
// stack: c' b' a', d, e, *vars
// stack: c' b' a', d, e, VARS
SWAP1
%flip_bytes_u32
%shl_const(96)
OR
// stack: d' c' b' a', e, *vars
// stack: d' c' b' a', e, VARS
SWAP1
%flip_bytes_u32
%shl_const(96)
OR
// stack: e' d' c' b' a', *vars
%stack (result, x, y, z) -> (result)
// stack: result
// stack: e' d' c' b' a', VARS
%stack (result, VARS: 3) -> (0xdeadbeef, result)
// stack: 0xdeadbeef, result
JUMP
/// def padlength(length):

View File

@ -1,4 +1,3 @@
// use std::env;
use anyhow::Result;
use ethereum_types::U256;
@ -7,11 +6,8 @@ use crate::cpu::kernel::interpreter::run;
#[test]
fn test_ripemd() -> Result<()> {
// env::set_var("RUST_BACKTRACE", "1");
// let expected = "0xf71c27109c692c1b56bbdceb5b9d2865b3708dbc";
// println!("{}", expected);
let expected = "0xf71c27109c692c1b56bbdceb5b9d2865b3708dbc";
println!("{}", expected);
let kernel = combined_kernel();
@ -32,17 +28,10 @@ fn test_ripemd() -> Result<()> {
stack_init,
&kernel.prover_inputs
)?;
let result = stack_result.stack();
for term in input {
println!("{:X}", term);
}
for term in result {
println!("{:X}", term);
}
// assert_eq!(expected, actual);
let result = stack_result.stack()[1];
let actual = format!("{}", result);
println!("{}", actual);
assert_eq!(expected, actual);
Ok(())
}