remove blake storage

This commit is contained in:
Dmitry Vagner 2023-02-15 19:11:22 -08:00
parent 77a7af76c2
commit 53ab0ada11
6 changed files with 20 additions and 60 deletions

View File

@ -49,9 +49,9 @@ pub(crate) fn combined_kernel() -> Kernel {
include_str!("asm/hash/blake2b/g_functions.asm"),
include_str!("asm/hash/blake2b/hash.asm"),
include_str!("asm/hash/blake2b/iv.asm"),
include_str!("asm/hash/blake2b/main.asm"),
include_str!("asm/hash/blake2b/ops.asm"),
include_str!("asm/hash/blake2b/permutations.asm"),
include_str!("asm/hash/blake2b/store.asm"),
include_str!("asm/hash/ripemd/box.asm"),
include_str!("asm/hash/ripemd/compression.asm"),
include_str!("asm/hash/ripemd/constants.asm"),
@ -60,9 +60,9 @@ pub(crate) fn combined_kernel() -> Kernel {
include_str!("asm/hash/ripemd/update.asm"),
include_str!("asm/hash/sha2/compression.asm"),
include_str!("asm/hash/sha2/constants.asm"),
include_str!("asm/hash/sha2/main.asm"),
include_str!("asm/hash/sha2/message_schedule.asm"),
include_str!("asm/hash/sha2/ops.asm"),
include_str!("asm/hash/sha2/store_pad.asm"),
include_str!("asm/hash/sha2/temp_words.asm"),
include_str!("asm/hash/sha2/write_length.asm"),
include_str!("asm/main.asm"),

View File

@ -0,0 +1,14 @@
global blake2b:
// stack: virt, num_bytes, retdest
POP
// stack: num_bytes, retdest
DUP1
// stack: num_bytes, num_bytes, retdest
%add_const(127)
%div_const(128)
// stack: num_blocks = ceil(num_bytes / 128), num_bytes, retdest
%mstore_kernel_general(0)
// stack: num_bytes, retdest
%mstore_kernel_general(1)
// stack: retdest
%jump(blake2b_compression)

View File

@ -1,45 +0,0 @@
global blake2b:
%jump(blake2b_store)
global blake2b_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
%add_const(127)
%div_const(128)
// stack: num_blocks = ceil(num_bytes / 128), num_bytes, x[0], x[1], ..., x[num_bytes - 1], retdest
PUSH 0
// stack: addr=0, num_blocks, 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
DUP1
// stack: num_bytes, num_bytes, x[0], x[1], ..., x[num_bytes - 1], retdest
PUSH 1
// stack: 1, 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 2
// stack: addr=2, 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(blake2b_compression)

View File

@ -249,15 +249,6 @@ impl<'a> Interpreter<'a> {
.content
}
pub fn extract_kernel_memory(self, locs: Vec<MemoryAddress>) -> Vec<U256> {
let mut output: Vec<U256> = vec![];
for loc in locs {
let term = self.generation_state.memory.get(loc);
output.push(term);
}
output
}
pub(crate) fn push(&mut self, x: U256) {
self.stack_mut().push(x);
self.generation_state.registers.stack_len += 1;

View File

@ -114,10 +114,10 @@ fn test_hash_512(
Ok(())
}
// #[test]
// fn test_blake2b() -> Result<()> {
// test_hash_512("blake2b", &blake2b)
// }
#[test]
fn test_blake2b() -> Result<()> {
test_hash_512("blake2b", 2, &blake2b)
}
#[test]
fn test_ripemd() -> Result<()> {