mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-10 17:53:06 +00:00
fixes
This commit is contained in:
parent
2166a407ed
commit
d30a95f7d5
@ -3,7 +3,7 @@ global blake_compression:
|
||||
PUSH 0
|
||||
// stack: cur_block = 0, retdest
|
||||
%blake_initial_hash_value
|
||||
blake_compression_loop:
|
||||
compression_loop:
|
||||
// stack: h_0, ..., h_7, cur_block, retdest
|
||||
%blake_hash_value_addr
|
||||
// stack: addr, h_0, ..., h_7, cur_block, retdest
|
||||
@ -211,9 +211,9 @@ blake_compression_loop:
|
||||
// stack: num_blocks, cur_block + 1, h_0', h_1', h_2', h_3', h_4', h_5', h_6', h_7', cur_block + 1, retdest
|
||||
EQ
|
||||
// stack: last_block, h_0', h_1', h_2', h_3', h_4', h_5', h_6', h_7', cur_block + 1, retdest
|
||||
%jumpi(blake_compression_end)
|
||||
%jump(blake_compression_loop)
|
||||
blake_compression_end:
|
||||
%jumpi(compression_end)
|
||||
%jump(compression_loop)
|
||||
compression_end:
|
||||
// stack: h_0', h_1', h_2', h_3', h_4', h_5', h_6', h_7', cur_block + 1, retdest
|
||||
PUSH 0
|
||||
// stack: dummy=0, h_0', h_1', h_2', h_3', h_4', h_5', h_6', h_7', cur_block + 1, retdest
|
||||
@ -260,5 +260,4 @@ blake_compression_end:
|
||||
// stack: hash_second = h_4' || h_5' || h_6' || h_7', hash_first = h_0' || h_1' || h_2' || h_3', retdest
|
||||
%stack (second, first, ret) -> (ret, second, first)
|
||||
// stack: retdest, hash_first, hash_second
|
||||
STOP
|
||||
JUMP
|
||||
@ -15,47 +15,33 @@
|
||||
// stack: (hi << 32) | lo
|
||||
%endmacro
|
||||
|
||||
%macro invert_bytes_blake_word
|
||||
// stack: word, ...
|
||||
DUP1
|
||||
%and_const(0xff)
|
||||
%shl_const(56)
|
||||
SWAP1
|
||||
// stack: word, first_byte, ...
|
||||
DUP1
|
||||
%shr_const(8)
|
||||
%and_const(0xff)
|
||||
%shl_const(48)
|
||||
SWAP1
|
||||
// stack: word, second_byte, first_byte, ...
|
||||
DUP1
|
||||
%shr_const(16)
|
||||
%and_const(0xff)
|
||||
%shl_const(40)
|
||||
SWAP1
|
||||
DUP1
|
||||
%shr_const(24)
|
||||
%and_const(0xff)
|
||||
%shl_const(32)
|
||||
SWAP1
|
||||
DUP1
|
||||
%shr_const(32)
|
||||
%and_const(0xff)
|
||||
%shl_const(24)
|
||||
SWAP1
|
||||
DUP1
|
||||
%shr_const(40)
|
||||
%and_const(0xff)
|
||||
%shl_const(16)
|
||||
SWAP1
|
||||
DUP1
|
||||
%shr_const(48)
|
||||
%and_const(0xff)
|
||||
%shl_const(8)
|
||||
SWAP1
|
||||
%shr_const(56)
|
||||
%and_const(0xff)
|
||||
%rep 7
|
||||
OR
|
||||
%endrep
|
||||
// Invert the order of the four bytes in a word.
|
||||
%macro invert_four_byte_word
|
||||
// stack: word
|
||||
%mul_const(0x1000000010000000100)
|
||||
%and_const(0xff0000ff00ff00000000ff0000)
|
||||
%mod_const(0xffffffffffff)
|
||||
// stack: word_inverted
|
||||
%endmacro
|
||||
|
||||
// Invert the order of the eight bytes in a Blake word.
|
||||
%macro invert_bytes_blake_word
|
||||
// stack: word
|
||||
DUP1
|
||||
// stack: word, word
|
||||
%and_const(0xffffffff)
|
||||
// stack: word_lo, word
|
||||
SWAP1
|
||||
// stack: word, word_lo
|
||||
%shr_const(32)
|
||||
// stack: word_hi, word_lo
|
||||
%invert_four_byte_word
|
||||
// stack: word_hi_inverted, word_lo
|
||||
SWAP1
|
||||
// stack: word_lo, word_hi_inverted
|
||||
%invert_four_byte_word
|
||||
// stack: word_lo_inverted, word_hi_inverted
|
||||
%shl_const(32)
|
||||
OR
|
||||
// stack: word_inverted
|
||||
%endmacro
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user