mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-05 07:13:08 +00:00
label name simplification
This commit is contained in:
parent
1e03c438e0
commit
9f49521e22
@ -45,7 +45,7 @@ global sha2_compression:
|
||||
PUSH sha2_constants_h
|
||||
%mload_kernel_code_u32
|
||||
// stack: a[0], b[0], c[0], d[0], e[0], f[0], g[0], h[0], num_blocks, scratch_space_addr, message_schedule_addr, i=0, retdest
|
||||
sha2_compression_start_block:
|
||||
compression_start_block:
|
||||
// Store the current values of the working variables, as the "initial values" to be added back in at the end of this block.
|
||||
DUP10
|
||||
// stack: scratch_space_addr, a[0], b[0], c[0], d[0], e[0], f[0], g[0], h[0], num_blocks, scratch_space_addr, message_schedule_addr, i=0, retdest
|
||||
@ -113,7 +113,7 @@ sha2_compression_start_block:
|
||||
// stack: scratch_space_addr+28, a[0], b[0], c[0], d[0], e[0], f[0], g[0], h[0], num_blocks, scratch_space_addr, message_schedule_addr, i=0, retdest
|
||||
POP
|
||||
// stack: a[0], b[0], c[0], d[0], e[0], f[0], g[0], h[0], num_blocks, scratch_space_addr, message_schedule_addr, i=0, retdest
|
||||
sha2_compression_loop:
|
||||
compression_loop:
|
||||
// Update the eight working variables, using the next constant K[i] and the next message schedule chunk W[i].
|
||||
// stack: a[i], b[i], c[i], d[i], e[i], f[i], g[i], h[i], num_blocks, scratch_space_addr, message_schedule_addr, i, retdest
|
||||
DUP11
|
||||
@ -194,9 +194,9 @@ sha2_compression_loop:
|
||||
DUP12
|
||||
// stack: (i+1)%64, a[i+1], b[i+1], c[i+1], d[i+1], e[i+1], f[i+1], g[i+1], h[i+1], num_blocks new, scratch_space_addr, message_schedule_addr new, (i+1)%64, retdest
|
||||
ISZERO
|
||||
%jumpi(sha2_compression_end_block)
|
||||
%jump(sha2_compression_loop)
|
||||
sha2_compression_end_block:
|
||||
%jumpi(compression_end_block)
|
||||
%jump(compression_loop)
|
||||
compression_end_block:
|
||||
// Add the initial values of the eight working variables (from the start of this block's compression) back into them.
|
||||
// stack: a[64], b[64], c[64], d[64], e[64], f[64], g[64], h[64], num_blocks, scratch_space_addr, message_schedule_addr, i, retdest
|
||||
DUP10
|
||||
@ -267,11 +267,11 @@ sha2_compression_end_block:
|
||||
// stack: num_blocks, num_blocks, a[0]+a[64], b[0]+b[64], c[0]+c[64], d[0]+d[64], e[0]+e[64], f[0]+f[64], g[0]+g[64], h[0]+h[64], scratch_space_addr, message_schedule_addr, i, retdest
|
||||
ISZERO
|
||||
// In this case, we've finished all the blocks.
|
||||
%jumpi(sha2_compression_end)
|
||||
%jumpi(compression_end)
|
||||
// stack: num_blocks, a[0]+a[64], b[0]+b[64], c[0]+c[64], d[0]+d[64], e[0]+e[64], f[0]+f[64], g[0]+g[64], h[0]+h[64], scratch_space_addr, message_schedule_addr, i, retdest
|
||||
%stack (num_blocks, working: 8) -> (working, num_blocks)
|
||||
%jump(sha2_compression_start_block)
|
||||
sha2_compression_end:
|
||||
%jump(compression_start_block)
|
||||
compression_end:
|
||||
// stack: num_blocks, a[0]+a[64], b[0]+b[64], c[0]+c[64], d[0]+d[64], e[0]+e[64], f[0]+f[64], g[0]+g[64], h[0]+h[64], scratch_space_addr, message_schedule_addr, i, retdest
|
||||
POP
|
||||
// stack: a[0]+a[64], b[0]+b[64], c[0]+c[64], d[0]+d[64], e[0]+e[64], f[0]+f[64], g[0]+g[64], h[0]+h[64], scratch_space_addr, message_schedule_addr, i, retdest
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// Precodition: stack contains address of one message block, followed by output address
|
||||
// Postcondition: 256 bytes starting at given output address contain the 64 32-bit chunks
|
||||
// of message schedule (in four-byte increments)
|
||||
global sha2_gen_message_schedule_from_block:
|
||||
gen_message_schedule_from_block:
|
||||
// stack: block_addr, output_addr, retdest
|
||||
DUP1
|
||||
// stack: block_addr, block_addr, output_addr, retdest
|
||||
@ -20,8 +20,8 @@ global sha2_gen_message_schedule_from_block:
|
||||
%add_const(28)
|
||||
PUSH 8
|
||||
// stack: counter=8, output_addr + 28, block[0], block[1], retdest
|
||||
%jump(sha2_gen_message_schedule_from_block_0_loop)
|
||||
sha2_gen_message_schedule_from_block_0_loop:
|
||||
%jump(gen_message_schedule_from_block_0_loop)
|
||||
gen_message_schedule_from_block_0_loop:
|
||||
// Split the first half (256 bits) of the block into the first eight (32-bit) chunks of the message sdchedule.
|
||||
// stack: counter, output_addr, block[0], block[1], retdest
|
||||
SWAP2
|
||||
@ -49,9 +49,9 @@ sha2_gen_message_schedule_from_block_0_loop:
|
||||
%decrement
|
||||
DUP1
|
||||
ISZERO
|
||||
%jumpi(sha2_gen_message_schedule_from_block_0_end)
|
||||
%jump(sha2_gen_message_schedule_from_block_0_loop)
|
||||
sha2_gen_message_schedule_from_block_0_end:
|
||||
%jumpi(gen_message_schedule_from_block_0_end)
|
||||
%jump(gen_message_schedule_from_block_0_loop)
|
||||
gen_message_schedule_from_block_0_end:
|
||||
// stack: old counter=0, output_addr, block[0], block[1], retdest
|
||||
POP
|
||||
PUSH 8
|
||||
@ -62,7 +62,7 @@ sha2_gen_message_schedule_from_block_0_end:
|
||||
// stack: output_addr + 64, counter, block[1], block[0], retdest
|
||||
SWAP1
|
||||
// stack: counter, output_addr + 64, block[1], block[0], retdest
|
||||
sha2_gen_message_schedule_from_block_1_loop:
|
||||
gen_message_schedule_from_block_1_loop:
|
||||
// Split the second half (256 bits) of the block into the next eight (32-bit) chunks of the message sdchedule.
|
||||
// stack: counter, output_addr, block[1], block[0], retdest
|
||||
SWAP2
|
||||
@ -90,9 +90,9 @@ sha2_gen_message_schedule_from_block_1_loop:
|
||||
%decrement
|
||||
DUP1
|
||||
ISZERO
|
||||
%jumpi(sha2_gen_message_schedule_from_block_1_end)
|
||||
%jump(sha2_gen_message_schedule_from_block_1_loop)
|
||||
sha2_gen_message_schedule_from_block_1_end:
|
||||
%jumpi(gen_message_schedule_from_block_1_end)
|
||||
%jump(gen_message_schedule_from_block_1_loop)
|
||||
gen_message_schedule_from_block_1_end:
|
||||
// stack: old counter=0, output_addr, block[1], block[0], retdest
|
||||
POP
|
||||
// stack: output_addr, block[0], block[1], retdest
|
||||
@ -104,7 +104,7 @@ sha2_gen_message_schedule_from_block_1_end:
|
||||
// stack: output_addr + 36, counter, block[0], block[1], retdest
|
||||
SWAP1
|
||||
// stack: counter, output_addr + 36, block[0], block[1], retdest
|
||||
sha2_gen_message_schedule_remaining_loop:
|
||||
gen_message_schedule_remaining_loop:
|
||||
// Generate the next 48 chunks of the message schedule, one at a time, from prior chunks.
|
||||
// stack: counter, output_addr, block[0], block[1], retdest
|
||||
SWAP1
|
||||
@ -179,9 +179,9 @@ sha2_gen_message_schedule_remaining_loop:
|
||||
// stack: counter - 1, output_addr + 4, block[0], block[1], retdest
|
||||
DUP1
|
||||
ISZERO
|
||||
%jumpi(sha2_gen_message_schedule_remaining_end)
|
||||
%jump(sha2_gen_message_schedule_remaining_loop)
|
||||
sha2_gen_message_schedule_remaining_end:
|
||||
%jumpi(gen_message_schedule_remaining_end)
|
||||
%jump(gen_message_schedule_remaining_loop)
|
||||
gen_message_schedule_remaining_end:
|
||||
// stack: counter=0, output_addr, block[0], block[1], retdest
|
||||
%pop4
|
||||
JUMP
|
||||
@ -200,16 +200,16 @@ global sha2_gen_all_message_schedules:
|
||||
// stack: num_blocks, output_addr, output_addr, retdest
|
||||
PUSH 1
|
||||
// stack: cur_addr = 1, counter = num_blocks, output_addr, output_addr, retdest
|
||||
sha2_gen_all_message_schedules_loop:
|
||||
gen_all_message_schedules_loop:
|
||||
// stack: cur_addr, counter, cur_output_addr, output_addr, retdest
|
||||
PUSH sha2_gen_all_message_schedules_loop_end
|
||||
// stack: new_retdest = sha2_gen_all_message_schedules_loop_end, cur_addr, counter, cur_output_addr, output_addr, retdest
|
||||
PUSH gen_all_message_schedules_loop_end
|
||||
// stack: new_retdest = gen_all_message_schedules_loop_end, cur_addr, counter, cur_output_addr, output_addr, retdest
|
||||
DUP4
|
||||
// stack: cur_output_addr, new_retdest, cur_addr, counter, cur_output_addr, output_addr, retdest
|
||||
DUP3
|
||||
// stack: cur_addr, cur_output_addr, new_retdest, cur_addr, counter, cur_output_addr, output_addr, retdest
|
||||
%jump(sha2_gen_message_schedule_from_block)
|
||||
sha2_gen_all_message_schedules_loop_end:
|
||||
%jump(gen_message_schedule_from_block)
|
||||
gen_all_message_schedules_loop_end:
|
||||
// stack: cur_addr, counter, cur_output_addr, output_addr, retdest
|
||||
%add_const(64)
|
||||
// stack: cur_addr + 64, counter, cur_output_addr, output_addr, retdest
|
||||
@ -224,9 +224,9 @@ sha2_gen_all_message_schedules_loop_end:
|
||||
DUP2
|
||||
// stack: counter - 1, cur_addr + 64, counter - 1, cur_output_addr + 256, output_addr, retdest
|
||||
ISZERO
|
||||
%jumpi(sha2_gen_all_message_schedules_end)
|
||||
%jump(sha2_gen_all_message_schedules_loop)
|
||||
sha2_gen_all_message_schedules_end:
|
||||
%jumpi(gen_all_message_schedules_end)
|
||||
%jump(gen_all_message_schedules_loop)
|
||||
gen_all_message_schedules_end:
|
||||
// stack: cur_addr + 64, counter - 1, cur_output_addr + 256, output_addr, retdest
|
||||
%pop3
|
||||
// stack: output_addr, retdest
|
||||
|
||||
@ -8,12 +8,12 @@ global sha2_store:
|
||||
// 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
|
||||
sha2_store_loop:
|
||||
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(sha2_store_end)
|
||||
%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
|
||||
@ -25,8 +25,8 @@ sha2_store_loop:
|
||||
// stack: addr, counter-1, ... , x[num_bytes-1], retdest
|
||||
%increment
|
||||
// stack: addr+1, counter-1, ... , x[num_bytes-1], retdest
|
||||
%jump(sha2_store_loop)
|
||||
sha2_store_end:
|
||||
%jump(store_loop)
|
||||
store_end:
|
||||
// stack: addr, counter, retdest
|
||||
%pop2
|
||||
// stack: retdest
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user