mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-09 09:13:09 +00:00
FIRST UNIT TEST PASSED!
This commit is contained in:
parent
24606decce
commit
41ce8e94b9
@ -99,7 +99,7 @@ mix:
|
||||
SWAP1
|
||||
// stack: VR, RD, o0, o1, o2, o3, o4
|
||||
POP
|
||||
// stack: RD, o0, o1, o2, o3, o4
|
||||
// stack: RD, o0, o1, o2, o3, o4
|
||||
JUMP
|
||||
|
||||
|
||||
|
||||
@ -59,10 +59,11 @@ ripemd_2:
|
||||
global process:
|
||||
// stack: a , b, c, d, e, count, length, virt
|
||||
%reverse_bytes_u32
|
||||
%shl_const(128)
|
||||
// stack: a', b, c, d, e, VARS
|
||||
SWAP1
|
||||
%reverse_bytes_u32
|
||||
%shl_const(32)
|
||||
%shl_const(96)
|
||||
OR
|
||||
// stack: b' a', c, d, e, VARS
|
||||
SWAP1
|
||||
@ -72,12 +73,11 @@ global process:
|
||||
// stack: c' b' a', d, e, VARS
|
||||
SWAP1
|
||||
%reverse_bytes_u32
|
||||
%shl_const(96)
|
||||
%shl_const(32)
|
||||
OR
|
||||
// stack: d' c' b' a', e, VARS
|
||||
SWAP1
|
||||
%reverse_bytes_u32
|
||||
%shl_const(96)
|
||||
OR
|
||||
// stack: e' d' c' b' a', VARS
|
||||
%stack (result, VARS: 3) -> (0xdeadbeef, result)
|
||||
|
||||
@ -35,7 +35,7 @@ global ripemd_update:
|
||||
ISZERO
|
||||
// stack: Q, STATE, 0, shift, need, have, count, length, virt, retdest
|
||||
%stack (Q, STATE: 5, i, shift, need, have) -> (have, Q, Q, STATE, i, shift, need, have)
|
||||
%eq_const(0)
|
||||
%gt_const(0)
|
||||
AND
|
||||
// stack: P, Q, STATE, 0, shift, need, have, count, length, virt, retdest
|
||||
%jumpi(update_1)
|
||||
@ -91,8 +91,8 @@ update_1a:
|
||||
/// cond -= 64
|
||||
|
||||
update_2:
|
||||
// stack: STATE, 0, shift, need, have, count, length, virt, retdest
|
||||
%stack (STATE: 5, i, shift, need, have, count, length) -> (length, shift, STATE, shift, need, have, count, length)
|
||||
// stack: STATE, shift, need, have, count, length, virt, retdest
|
||||
%stack (STATE: 5, shift, need, have, count, length) -> (length, shift, STATE, shift, need, have, count, length)
|
||||
SUB
|
||||
%ge_const(64)
|
||||
// stack: cond, STATE, shift, need, have, count, length, virt, retdest
|
||||
|
||||
@ -258,44 +258,38 @@
|
||||
DUP1
|
||||
%and_const(0xFF)
|
||||
// stack: d, abcd
|
||||
PUSH 0xFF
|
||||
DUP1
|
||||
SWAP2
|
||||
// stack: abcd, d, 0xFF, d
|
||||
%stack (d, abcd) -> (abcd, d, 0x100, d)
|
||||
// stack: abcd, d, 0x100, d
|
||||
SUB
|
||||
DIV
|
||||
// stack: abc, d
|
||||
DUP1
|
||||
%and_const(0xFF)
|
||||
// stack: c, abcd, d
|
||||
PUSH 0xFF
|
||||
DUP1
|
||||
SWAP2
|
||||
// stack: abc, c, 0xFF, c, d
|
||||
// stack: c, abc, d
|
||||
%stack (c, abc) -> (abc, c, 0x100, c)
|
||||
// stack: abc, c, 0x100, c, d
|
||||
SUB
|
||||
DIV
|
||||
// stack: ab, c, d
|
||||
DUP1
|
||||
%and_const(0xFF)
|
||||
// stack: b, ab, c, d
|
||||
PUSH 0xFF
|
||||
DUP1
|
||||
SWAP2
|
||||
// stack: ab, b, 0xFF, b, c, d
|
||||
%stack (b, ab) -> (ab, b, 0x100, b)
|
||||
// stack: ab, b, 0x100, b, c, d
|
||||
SUB
|
||||
DIV
|
||||
// stack: a, b, c, d
|
||||
SWAP1
|
||||
%mul_const(0x100)
|
||||
ADD
|
||||
%shl_const(8)
|
||||
OR
|
||||
// stack: ba, c, d
|
||||
SWAP1
|
||||
%mul_const(0x10000)
|
||||
ADD
|
||||
%shl_const(16)
|
||||
OR
|
||||
// stack: cba, d
|
||||
SWAP1
|
||||
%mul_const(0x1000000)
|
||||
ADD
|
||||
%shl_const(24)
|
||||
OR
|
||||
// stack: dcba
|
||||
%endmacro
|
||||
|
||||
|
||||
@ -6,11 +6,8 @@ use crate::cpu::kernel::interpreter::run_with_kernel;
|
||||
|
||||
#[test]
|
||||
fn test_ripemd() -> Result<()> {
|
||||
let expected = "0xf71c27109c692c1b56bbdceb5b9d2865b3708dbc";
|
||||
// let expected: Vec<&str> = vec!["10271CF7", "1B2C699C", "EBDCBB56", "65289D5B", "BC8D70B3"];
|
||||
println!("{:#?}", expected);
|
||||
|
||||
// let input: Vec<u32> = vec![0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0, 0, 0xdeadbeef];
|
||||
let expected = "f71c27109c692c1b56bbdceb5b9d2865b3708dbc";
|
||||
println!("{:#}", expected);
|
||||
|
||||
let input: Vec<u32> = vec![
|
||||
26, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e,
|
||||
@ -23,7 +20,7 @@ fn test_ripemd() -> Result<()> {
|
||||
let actual: Vec<String> = stack_output
|
||||
.stack()
|
||||
.iter()
|
||||
.map(|&x| format!("{:X}", x))
|
||||
.map(|&x| format!("{:x}", x))
|
||||
.rev()
|
||||
.collect();
|
||||
println!("{:#?}", actual);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user