mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-08-10 16:43:24 +00:00
fixes
This commit is contained in:
parent
c24af37288
commit
6a31a4b7ec
@ -6,6 +6,8 @@ global sha2_store:
|
|||||||
push 0
|
push 0
|
||||||
// stack: addr=0, num_bytes, num_bytes, x[0], x[1], ..., x[num_bytes - 1], retdest
|
// stack: addr=0, num_bytes, num_bytes, x[0], x[1], ..., x[num_bytes - 1], retdest
|
||||||
%mstore_kernel_general
|
%mstore_kernel_general
|
||||||
|
// stack: num_bytes, x[0], x[1], ..., x[num_bytes - 1], retdest
|
||||||
|
dup1
|
||||||
// stack: num_bytes, num_bytes, x[0], x[1], ..., x[num_bytes - 1], retdest
|
// stack: num_bytes, num_bytes, x[0], x[1], ..., x[num_bytes - 1], retdest
|
||||||
push 1
|
push 1
|
||||||
// stack: addr=1, counter=num_bytes, x[0], x[1], x[2], ... , x[num_bytes-1], retdest
|
// stack: addr=1, counter=num_bytes, x[0], x[1], x[2], ... , x[num_bytes-1], retdest
|
||||||
@ -21,8 +23,6 @@ sha2_store_loop:
|
|||||||
%mstore_kernel_general
|
%mstore_kernel_general
|
||||||
// stack: counter, addr, ... , x[num_bytes-1], retdest
|
// stack: counter, addr, ... , x[num_bytes-1], retdest
|
||||||
dup1
|
dup1
|
||||||
%eq_const(6)
|
|
||||||
%jumpi(sha2_stop)
|
|
||||||
%decrement
|
%decrement
|
||||||
// stack: counter-1, addr, ... , x[num_bytes-1], retdest
|
// stack: counter-1, addr, ... , x[num_bytes-1], retdest
|
||||||
iszero
|
iszero
|
||||||
@ -36,6 +36,7 @@ sha2_store_end:
|
|||||||
JUMPDEST
|
JUMPDEST
|
||||||
// stack: counter=0, addr, retdest
|
// stack: counter=0, addr, retdest
|
||||||
%pop2
|
%pop2
|
||||||
|
STOP
|
||||||
JUMP
|
JUMP
|
||||||
sha2_stop:
|
sha2_stop:
|
||||||
JUMPDEST
|
JUMPDEST
|
||||||
|
|||||||
@ -242,8 +242,7 @@
|
|||||||
|
|
||||||
%macro increment
|
%macro increment
|
||||||
push 1
|
push 1
|
||||||
swap1
|
add
|
||||||
sub
|
|
||||||
%endmacro
|
%endmacro
|
||||||
|
|
||||||
%macro decrement
|
%macro decrement
|
||||||
|
|||||||
@ -13,7 +13,7 @@ fn test_sha2_store() -> Result<()> {
|
|||||||
let kernel = combined_kernel();
|
let kernel = combined_kernel();
|
||||||
let sha2_store = kernel.global_labels["sha2_store"];
|
let sha2_store = kernel.global_labels["sha2_store"];
|
||||||
let mut rng = thread_rng();
|
let mut rng = thread_rng();
|
||||||
let num_bytes = rng.gen_range(0..20);
|
let num_bytes = rng.gen_range(1..17);
|
||||||
let mut bytes: Vec<U256> = Vec::with_capacity(num_bytes);
|
let mut bytes: Vec<U256> = Vec::with_capacity(num_bytes);
|
||||||
for _ in 0..num_bytes {
|
for _ in 0..num_bytes {
|
||||||
let byte: u8 = rng.gen();
|
let byte: u8 = rng.gen();
|
||||||
@ -28,6 +28,7 @@ fn test_sha2_store() -> Result<()> {
|
|||||||
|
|
||||||
let mut initial_stack = vec![U256::from(num_bytes)];
|
let mut initial_stack = vec![U256::from(num_bytes)];
|
||||||
initial_stack.extend(bytes);
|
initial_stack.extend(bytes);
|
||||||
|
initial_stack.push(U256::from_str("0xdeadbeef").unwrap());
|
||||||
dbg!(initial_stack.clone());
|
dbg!(initial_stack.clone());
|
||||||
let stack_with_kernel = run(&kernel.code, sha2_store, initial_stack)?.stack;
|
let stack_with_kernel = run(&kernel.code, sha2_store, initial_stack)?.stack;
|
||||||
dbg!(stack_with_kernel);
|
dbg!(stack_with_kernel);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user