remove sha2 storage

This commit is contained in:
Dmitry Vagner 2023-02-15 19:00:52 -08:00
parent abc762f7b4
commit 77a7af76c2
2 changed files with 8 additions and 39 deletions

View File

@ -1,39 +1,8 @@
global sha2:
%jump(sha2_store)
global sha2_store:
// 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
PUSH 0
// stack: addr=0, num_bytes, num_bytes, x[0], x[1], ..., x[num_bytes - 1], retdest
%mstore_kernel_general
// stack: num_bytes, x[0], x[1], ..., x[num_bytes - 1], retdest
PUSH 1
// stack: addr=1, counter=num_bytes, x[0], x[1], x[2], ... , x[num_bytes-1], retdest
store_loop:
// stack: addr, counter, x[num_bytes-counter], ... , x[num_bytes-1], retdest
DUP2
// stack: counter, addr, counter, x[num_bytes-counter], ... , x[num_bytes-1], retdest
ISZERO
%jumpi(store_end)
// stack: addr, counter, x[num_bytes-counter], ... , x[num_bytes-1], retdest
%stack (addr, counter, val) -> (addr, val, counter, addr)
// stack: addr, x[num_bytes-counter], counter, addr, ... , x[num_bytes-1], retdest
%mstore_kernel_general
// stack: counter, addr, ... , x[num_bytes-1], retdest
%decrement
// stack: counter-1, addr, ... , x[num_bytes-1], retdest
SWAP1
// stack: addr, counter-1, ... , x[num_bytes-1], retdest
%increment
// stack: addr+1, counter-1, ... , x[num_bytes-1], retdest
%jump(store_loop)
store_end:
// stack: addr, counter, retdest
%pop2
// stack: retdest
%jump(sha2_pad)
// stack: virt, length
POP
// stack: length
%mstore_kernel_general(0)
// Precodition: input is in memory, starting at 0 of kernel general segment, of the form
// num_bytes, x[0], x[1], ..., x[num_bytes - 1]

View File

@ -124,7 +124,7 @@ fn test_ripemd() -> Result<()> {
test_hash_256("ripemd", 200, &ripemd)
}
// #[test]
// fn test_sha2() -> Result<()> {
// test_hash_256("sha2", 1, &sha2)
// }
#[test]
fn test_sha2() -> Result<()> {
test_hash_256("sha2", 1, &sha2)
}