mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-04-28 22:33:10 +00:00
formatting
This commit is contained in:
parent
64e9f6f0fb
commit
cf80668ce3
@ -2,27 +2,31 @@
|
|||||||
/// return (u32(x << n)) | (x >> (32 - n))
|
/// return (u32(x << n)) | (x >> (32 - n))
|
||||||
|
|
||||||
global rol:
|
global rol:
|
||||||
jumpdest
|
JUMPDEST
|
||||||
// stack: n, x, retdest
|
// stack: n, x, retdest
|
||||||
swap1 dup1 dup3
|
SWAP1
|
||||||
|
DUP1
|
||||||
|
DUP3
|
||||||
// stack: n, x, x, n, retdest
|
// stack: n, x, x, n, retdest
|
||||||
push 32 sub
|
PUSH 32
|
||||||
|
SUB
|
||||||
// stack: 32-n, x, x, n, retdest
|
// stack: 32-n, x, x, n, retdest
|
||||||
shr
|
SHR
|
||||||
// stack: x >> (32-n), x, n, retdest
|
// stack: x >> (32-n), x, n, retdest
|
||||||
swap2
|
SWAP2
|
||||||
// stack: n, x, x >> (32-n), retdest
|
// stack: n, x, x >> (32-n), retdest
|
||||||
shl
|
SHL
|
||||||
// stack: x << n, x >> (32-n), retdest
|
// stack: x << n, x >> (32-n), retdest
|
||||||
%u32
|
%u32
|
||||||
// stack: u32(x << n), x >> (32-n), retdest
|
// stack: u32(x << n), x >> (32-n), retdest
|
||||||
or
|
OR
|
||||||
// stack: u32(x << n) | (x >> (32-n)), retdest
|
// stack: u32(x << n) | (x >> (32-n)), retdest
|
||||||
swap1 jump
|
SWAP1
|
||||||
|
JUMP
|
||||||
|
|
||||||
|
|
||||||
%macro push_F:
|
%macro PUSH_F
|
||||||
push 0
|
PUSH 0
|
||||||
%this_F(0,F0)
|
%this_F(0,F0)
|
||||||
%this_F(1,F1)
|
%this_F(1,F1)
|
||||||
%this_F(2,F2)
|
%this_F(2,F2)
|
||||||
@ -38,14 +42,14 @@ global rol:
|
|||||||
|
|
||||||
%macro this_F(i, F)
|
%macro this_F(i, F)
|
||||||
// stack: acc, rnd
|
// stack: acc, rnd
|
||||||
dup2
|
DUP2
|
||||||
// stack: rnd, acc, rnd
|
// stack: rnd, acc, rnd
|
||||||
%eq_const(i)
|
%eq_const(i)
|
||||||
// stack: rnd==i, acc, j
|
// stack: rnd==i, acc, j
|
||||||
%mul_const(F)
|
%mul_const(F)
|
||||||
// stack: (rnd==i)*F, acc, rnd
|
// stack: (rnd==i)*F, acc, rnd
|
||||||
add
|
ADD
|
||||||
acc + (rnd==j)*F, rnd
|
// stack: acc + (rnd==j)*F, rnd
|
||||||
%endmacro
|
%endmacro
|
||||||
|
|
||||||
|
|
||||||
@ -53,90 +57,95 @@ global rol:
|
|||||||
/// return x ^ y ^ z
|
/// return x ^ y ^ z
|
||||||
|
|
||||||
global F0:
|
global F0:
|
||||||
jumpdest
|
JUMPDEST
|
||||||
// stack: x , y , z, retdest
|
// stack: x , y , z, retdest
|
||||||
xor
|
XOR
|
||||||
// stack: x ^ y , z, retdest
|
// stack: x ^ y , z, retdest
|
||||||
xor
|
XOR
|
||||||
// stack: x ^ y ^ z, retdest
|
// stack: x ^ y ^ z, retdest
|
||||||
swap1 jump
|
SWAP1
|
||||||
|
JUMP
|
||||||
|
|
||||||
|
|
||||||
/// def F1(x, y, z):
|
/// def F1(x, y, z):
|
||||||
/// return (x & y) | (u32(~x) & z)
|
/// return (x & y) | (u32(~x) & z)
|
||||||
|
|
||||||
global F1:
|
global F1:
|
||||||
jumpdest
|
JUMPDEST
|
||||||
// stack: x, y, z, retdest
|
// stack: x, y, z, retdest
|
||||||
dup1
|
DUP1
|
||||||
// stack: x, x, y, z, retdest
|
// stack: x, x, y, z, retdest
|
||||||
swap2
|
SWAP2
|
||||||
// stack: y, x, x, z, retdest
|
// stack: y, x, x, z, retdest
|
||||||
and
|
AND
|
||||||
// stack: y & x, x, z, retdest
|
// stack: y & x, x, z, retdest
|
||||||
swap2
|
SWAP2
|
||||||
// stack: z, x, y & x, retdest
|
// stack: z, x, y & x, retdest
|
||||||
swap1
|
SWAP1
|
||||||
// stack: x, z, y & x, retdest
|
// stack: x, z, y & x, retdest
|
||||||
%not_32
|
%not_32
|
||||||
// stack: ~x, z, y & x, retdest
|
// stack: ~x, z, y & x, retdest
|
||||||
and
|
AND
|
||||||
// stack: ~x & z, y & x, retdest
|
// stack: ~x & z, y & x, retdest
|
||||||
or
|
OR
|
||||||
// stack: (~x & z) | (y & x), retdest
|
// stack: (~x & z) | (y & x), retdest
|
||||||
swap1 jump
|
SWAP1
|
||||||
|
JUMP
|
||||||
|
|
||||||
|
|
||||||
/// def F2(x, y, z):
|
/// def F2(x, y, z):
|
||||||
/// return (x | u32(~y)) ^ z
|
/// return (x | u32(~y)) ^ z
|
||||||
|
|
||||||
global F2:
|
global F2:
|
||||||
jumpdest
|
JUMPDEST
|
||||||
// stack: x, y, z, retdest
|
// stack: x, y, z, retdest
|
||||||
swap1
|
SWAP1
|
||||||
// stack: y, x, z, retdest
|
// stack: y, x, z, retdest
|
||||||
%not_32
|
%not_32
|
||||||
// stack: ~y, x, z, retdest
|
// stack: ~y, x, z, retdest
|
||||||
or
|
OR
|
||||||
// stack: ~y | x, z, retdest
|
// stack: ~y | x, z, retdest
|
||||||
xor
|
XOR
|
||||||
// stack: (~y | x) ^ z, retdest
|
// stack: (~y | x) ^ z, retdest
|
||||||
swap1 jump
|
SWAP1
|
||||||
|
JUMP
|
||||||
|
|
||||||
|
|
||||||
/// def F3(x, y, z):
|
/// def F3(x, y, z):
|
||||||
/// return (x & z) | (u32(~z) & y)
|
/// return (x & z) | (u32(~z) & y)
|
||||||
|
|
||||||
global F3:
|
global F3:
|
||||||
jumpdest
|
JUMPDEST
|
||||||
// stack: x, y, z, retdest
|
// stack: x, y, z, retdest
|
||||||
dup3
|
DUP3
|
||||||
// stack: z, x, y, z, retdest
|
// stack: z, x, y, z, retdest
|
||||||
and
|
AND
|
||||||
// stack: z & x, y, z, retdest
|
// stack: z & x, y, z, retdest
|
||||||
swap2
|
SWAP2
|
||||||
// stack: z, y, z & x, retdest
|
// stack: z, y, z & x, retdest
|
||||||
%not_32
|
%not_32
|
||||||
// stack: ~z, y, z & x, retdest
|
// stack: ~z, y, z & x, retdest
|
||||||
and
|
AND
|
||||||
// stack: ~z & y, z & x, retdest
|
// stack: ~z & y, z & x, retdest
|
||||||
or
|
OR
|
||||||
// stack: (~z & y) | (z & x), retdest
|
// stack: (~z & y) | (z & x), retdest
|
||||||
swap1 jump
|
SWAP1
|
||||||
|
JUMP
|
||||||
|
|
||||||
|
|
||||||
/// def F4(x, y, z):
|
/// def F4(x, y, z):
|
||||||
/// return x ^ (y | u32(~z))
|
/// return x ^ (y | u32(~z))
|
||||||
|
|
||||||
global F4:
|
global F4:
|
||||||
jumpdest
|
JUMPDEST
|
||||||
// stack: x, y, z, retdest
|
// stack: x, y, z, retdest
|
||||||
swap2
|
SWAP2
|
||||||
// stack: z, y, x, retdest
|
// stack: z, y, x, retdest
|
||||||
%not_32
|
%not_32
|
||||||
// stack: ~z, y, x, retdest
|
// stack: ~z, y, x, retdest
|
||||||
or
|
OR
|
||||||
// stack: ~z | y, x, retdest
|
// stack: ~z | y, x, retdest
|
||||||
xor
|
XOR
|
||||||
// stack: (~z | y) ^ x, retdest
|
// stack: (~z | y) ^ x, retdest
|
||||||
swap1 jump
|
SWAP1
|
||||||
|
JUMP
|
||||||
|
|||||||
@ -218,25 +218,25 @@
|
|||||||
|
|
||||||
%macro u32
|
%macro u32
|
||||||
// stack: x
|
// stack: x
|
||||||
push 0xffffffff
|
PUSH 0xffffffff
|
||||||
// stack: 0xffffffff, x
|
// stack: 0xffffffff, x
|
||||||
and
|
AND
|
||||||
// stack: 0xffffffff & x
|
// stack: 0xffffffff & x
|
||||||
%endmacro
|
%endmacro
|
||||||
|
|
||||||
%macro not_32
|
%macro not_32
|
||||||
// stack: x
|
// stack: x
|
||||||
push 0xffffffff
|
PUSH 0xffffffff
|
||||||
// stack: 0xffffffff, x
|
// stack: 0xffffffff, x
|
||||||
sub
|
SUB
|
||||||
// stack: 0xffffffff - x
|
// stack: 0xffffffff - x
|
||||||
%endmacro
|
%endmacro
|
||||||
|
|
||||||
%macro add3_32
|
%macro add3_32
|
||||||
// stack: x, y, z
|
// stack: x, y, z
|
||||||
add
|
ADD
|
||||||
// stack: x+y, z
|
// stack: x+y, z
|
||||||
add
|
ADD
|
||||||
// stack: x+y+z
|
// stack: x+y+z
|
||||||
%u32
|
%u32
|
||||||
%endmacro
|
%endmacro
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user