fp -> fp254

This commit is contained in:
Dmitry Vagner 2023-02-05 17:43:31 -08:00
parent 61ac0eff46
commit 1c73e23824
6 changed files with 200 additions and 200 deletions

View File

@ -26,7 +26,7 @@ global bn254_final_exp:
// stack: val, retdest
%stack (val) -> (val, 300, val)
// stack: val, 300, val, retdest
%move_fp12
%move_fp254_12
// stack: 300, val, retdest
%stack () -> (1, 1, 1)
// stack: 1, 1, 1, 300, val, retdest

View File

@ -31,7 +31,7 @@ global bn254_miller:
// stack: out, 1, ptr, out, retdest
%mstore_kernel_general
// stack: ptr, out, retdest
%load_fp6
%load_fp254_6
// stack: P, Q, out, retdest
%stack (P: 2) -> (0, 53, P, P)
// stack: 0, 53, O, P, Q, out, retdest

View File

@ -4,7 +4,7 @@
/// cost: 1063
/// fp6 functions:
/// fp254_6 functions:
/// fn | num | ops | cost
/// -------------------------
/// load | 8 | 40 | 320
@ -46,92 +46,92 @@
global mul_fp254_12:
// stack: inA, inB, out
DUP1
%offset_fp6
%offset_fp254_6
// stack: inA', inA, inB, out
%load_fp6
%load_fp254_6
// stack: f', inA, inB, out
DUP8
%offset_fp6
%offset_fp254_6
// stack: inB', f', inA, inB, out
%load_fp6
%load_fp254_6
// stack: g', f', inA, inB, out
PUSH mul_fp12_1
// stack: mul_fp12_1, g', f', inA, inB, out
%dup_fp6_7
// stack: f', mul_fp12_1, g', f', inA, inB, out
%dup_fp6_7
// stack: g', f', mul_fp12_1, g', f', inA, inB, out
PUSH mul_fp254_12_1
// stack: mul_fp254_12_1, g', f', inA, inB, out
%dup_fp254_6_7
// stack: f', mul_fp254_12_1, g', f', inA, inB, out
%dup_fp254_6_7
// stack: g', f', mul_fp254_12_1, g', f', inA, inB, out
%jump(mul_fp254_6)
mul_fp12_1:
mul_fp254_12_1:
// stack: f'g', g' , f', inA, inB, out
%dup_fp6_0
%dup_fp254_6_0
// stack: f'g', f'g', g' , f', inA, inB, out
%store_fp6_sh(0)
%store_fp254_6_sh(0)
// stack: f'g', g' , f', inA, inB, out {0: sh(f'g')}
%store_fp6(6)
%store_fp254_6(6)
// stack: g' , f', inA, inB, out {0: sh(f'g'), 6: f'g'}
DUP13
// stack: inA, g' , f', inA, inB, out {0: sh(f'g'), 6: f'g'}
DUP15
// stack: inB, inA, g' , f', inA, inB, out {0: sh(f'g'), 6: f'g'}
%load_fp6
%load_fp254_6
// stack: g , inA, g' , f', inA, inB, out {0: sh(f'g'), 6: f'g'}
%swap_fp6_hole
%swap_fp254_6_hole
// stack: g', inA, g , f', inA, inB, out {0: sh(f'g'), 6: f'g'}
%dup_fp6_7
%dup_fp254_6_7
// stack: g,g', inA, g , f', inA, inB, out {0: sh(f'g'), 6: f'g'}
%add_fp6
%add_fp254_6
// stack: g+g', inA, g , f', inA, inB, out {0: sh(f'g'), 6: f'g'}
%swap_fp6_hole
%swap_fp254_6_hole
// stack: g, inA, g+g', f', inA, inB, out {0: sh(f'g'), 6: f'g'}
PUSH mul_fp12_2
// stack: mul_fp12_2, g, inA, g+g', f', inA, inB, out {0: sh(f'g'), 6: f'g'}
PUSH mul_fp254_12_2
// stack: mul_fp254_12_2, g, inA, g+g', f', inA, inB, out {0: sh(f'g'), 6: f'g'}
SWAP7
// stack: inA, g, mul_fp12_2, g+g', f', inA, inB, out {0: sh(f'g'), 6: f'g'}
%load_fp6
// stack: f, g, mul_fp12_2, g+g', f', inA, inB, out {0: sh(f'g'), 6: f'g'}
// stack: inA, g, mul_fp254_12_2, g+g', f', inA, inB, out {0: sh(f'g'), 6: f'g'}
%load_fp254_6
// stack: f, g, mul_fp254_12_2, g+g', f', inA, inB, out {0: sh(f'g'), 6: f'g'}
%jump(mul_fp254_6)
mul_fp12_2:
mul_fp254_12_2:
// stack: fg, g+g', f', inA, inB, out {0: sh(f'g'), 6: f'g'}
%store_fp6(12)
%store_fp254_6(12)
// stack: g+g', f', inA, inB, out {0: sh(f'g'), 6: f'g', 12: fg}
%swap_fp6
%swap_fp254_6
// stack: f', g+g', inA, inB, out {0: sh(f'g'), 6: f'g', 12: fg}
PUSH mul_fp12_3
// stack: mul_fp12_3, f', g+g', inA, inB, out {0: sh(f'g'), 6: f'g', 12: fg}
PUSH mul_fp254_12_3
// stack: mul_fp254_12_3, f', g+g', inA, inB, out {0: sh(f'g'), 6: f'g', 12: fg}
SWAP13
// stack: inA, f', g+g', mul_fp12_3, inB, out {0: sh(f'g'), 6: f'g', 12: fg}
%load_fp6
// stack: f,f', g+g', mul_fp12_3, inB, out {0: sh(f'g'), 6: f'g', 12: fg}
%add_fp6
// stack: f+f', g+g', mul_fp12_3, inB, out {0: sh(f'g'), 6: f'g', 12: fg}
// stack: inA, f', g+g', mul_fp254_12_3, inB, out {0: sh(f'g'), 6: f'g', 12: fg}
%load_fp254_6
// stack: f,f', g+g', mul_fp254_12_3, inB, out {0: sh(f'g'), 6: f'g', 12: fg}
%add_fp254_6
// stack: f+f', g+g', mul_fp254_12_3, inB, out {0: sh(f'g'), 6: f'g', 12: fg}
%jump(mul_fp254_6)
mul_fp12_3:
mul_fp254_12_3:
// stack: (f+f')(g+g'), inB, out {0: sh(f'g'), 6: f'g', 12: fg}
%load_fp6(12)
%load_fp254_6(12)
// stack: fg, (f+f')(g+g'), inB, out {0: sh(f'g'), 6: f'g', 12: fg}
%swap_fp6
%swap_fp254_6
// stack: (f+f')(g+g'), fg, inB, out {0: sh(f'g'), 6: f'g', 12: fg}
%dup_fp6_6
%dup_fp254_6_6
// stack: fg, (f+f')(g+g'), fg, inB, out {0: sh(f'g'), 6: f'g', 12: fg}
%load_fp6(6)
%load_fp254_6(6)
// stack: f'g',fg, (f+f')(g+g'), fg, inB, out {0: sh(f'g'), 6: f'g', 12: fg}
%add_fp6
%add_fp254_6
// stack: f'g'+fg, (f+f')(g+g'), fg, inB, out {0: sh(f'g'), 6: f'g', 12: fg}
%subr_fp6
%subr_fp254_6
// stack: (f+f')(g+g') - (f'g'+fg), fg, inB, out {0: sh(f'g'), 6: f'g', 12: fg}
DUP14
%offset_fp6
%offset_fp254_6
// stack: out', (f+f')(g+g') - (f'g'+fg), fg, inB, out {0: sh(f'g'), 6: f'g', 12: fg}
%store_fp6
%store_fp254_6
// stack: fg, inB, out {0: sh(f'g'), 6: f'g', 12: fg}
%load_fp6(0)
%load_fp254_6(0)
// stack: sh(f'g') , fg, inB, out {0: sh(f'g'), 6: f'g', 12: fg}
%add_fp6
%add_fp254_6
// stack: sh(f'g') + fg, inB, out {0: sh(f'g'), 6: f'g', 12: fg}
DUP8
// stack: out, sh(f'g') + fg, inB, out {0: sh(f'g'), 6: f'g', 12: fg}
%store_fp6
%store_fp254_6
// stack: inB, out {0: sh(f'g'), 6: f'g', 12: fg}
%pop2
JUMP
@ -143,7 +143,7 @@ mul_fp12_3:
/// cost: 645
/// fp6 functions:
/// fp254_6 functions:
/// fn | num | ops | cost
/// ---------------------------
/// load | 2 | 40 | 80
@ -151,8 +151,8 @@ mul_fp12_3:
/// dup | 4 | 6 | 24
/// swap | 4 | 16 | 64
/// add | 4 | 16 | 64
/// mul_fp | 2 | 21 | 42
/// mul_fp2 | 4 | 59 | 236
/// mul_fp254_ | 2 | 21 | 42
/// mul_fp254_2 | 4 | 59 | 236
///
/// lone stack operations:
/// op | num
@ -183,91 +183,91 @@ mul_fp12_3:
global mul_fp254_12_sparse:
// stack: inA, inB, out
DUP1
%offset_fp6
%offset_fp254_6
// stack: inA', inA, inB, out
%load_fp6
%load_fp254_6
// stack: f', inA, inB, out
DUP8
// stack: inB, f', inA, inB, out
DUP8
// stack: inA, inB, f', inA, inB, out
%load_fp6
%load_fp254_6
// stack: f, inB, f', inA, inB, out
DUP16
// stack: out, f, inB, f', inA, inB, out
%dup_fp6_8
%dup_fp254_6_8
// stack: f', out, f, inB, f', inA, inB, out
DUP14
// stack: inB, f', out, f, inB, f', inA, inB, out
%dup_fp6_8
%dup_fp254_6_8
// stack: f, inB, f', out, f, inB, f', inA, inB, out
DUP7
// stack: inB, f, inB, f', out, f, inB, f', inA, inB, out
%dup_fp6_8
%dup_fp254_6_8
// stack: f', inB, f, inB, f', out, f, inB, f', inA, inB, out
%dup_fp6_7
%dup_fp254_6_7
// stack: f, f', inB, f, inB, f', out, f, inB, f', inA, inB, out
DUP13
// stack: inB, f, f', inB, f, inB, f', out, f, inB, f', inA, inB, out
%mload_kernel_general
// stack: g0 , f, f', inB, f, inB, f', out, f, inB, f', inA, inB, out
%mul_fp_fp6
%mul_fp254__fp254_6
// stack: g0 * f, f', inB, f, inB, f', out, f, inB, f', inA, inB, out
%swap_fp6
%swap_fp254_6
// stack: f' , g0 * f, inB, f, inB, f', out, f, inB, f', inA, inB, out
DUP13
%add_const(8)
// stack: inB2, f' , g0 * f, inB, f, inB, f', out, f, inB, f', inA, inB, out
%load_fp2
%load_fp254_2
// stack: G2 , f' , g0 * f, inB, f, inB, f', out, f, inB, f', inA, inB, out
%mul_fp2_fp6_sh2
%mul_fp254_2_fp254_6_sh2
// stack: G2 * sh2(f') , g0 * f, inB, f, inB, f', out, f, inB, f', inA, inB, out
%add_fp6
%add_fp254_6
// stack: G2 * sh2(f') + g0 * f, inB, f, inB, f', out, f, inB, f', inA, inB, out
%swap_fp6_hole
%swap_fp254_6_hole
// stack: f , inB, G2 * sh2(f') + g0 * f, inB, f', out, f, inB, f', inA, inB, out
DUP7 %add_const(2)
// stack: inB1, f , inB, G2 * sh2(f') + g0 * f, inB, f', out, f, inB, f', inA, inB, out
%load_fp2
%load_fp254_2
// stack: G1 , f , inB, G2 * sh2(f') + g0 * f, inB, f', out, f, inB, f', inA, inB, out
%mul_fp2_fp6_sh
%mul_fp254_2_fp254_6_sh
// stack: G1 * sh(f), inB, G2 * sh2(f') + g0 * f, inB, f', out, f, inB, f', inA, inB, out
%add_fp6_hole
%add_fp254_6_hole
// stack: G1 * sh(f) + G2 * sh2(f') + g0 * f, inB, f', out, f, inB, f', inA, inB, out
DUP14
// stack: out, G1 * sh(f) + G2 * sh2(f') + g0 * f, inB, f', out, f, inB, f', inA, inB, out
%store_fp6
%store_fp254_6
// stack: inB, f', out, f, inB, f', inA, inB, out
%mload_kernel_general
// stack: g0 , f', out, f, inB, f', inA, inB, out
%mul_fp_fp6
%mul_fp254__fp254_6
// stack: g0 * f', out, f, inB, f', inA, inB, out
%swap_fp6_hole
%swap_fp254_6_hole
// stack: f , out, g0 * f', inB, f', inA, inB, out
DUP14
%add_const(8)
// stack: inB2, f , out, g0 * f', inB, f', inA, inB, out
%load_fp2
%load_fp254_2
// stack: G2 , f , out, g0 * f', inB, f', inA, inB, out
%mul_fp2_fp6_sh
%mul_fp254_2_fp254_6_sh
// stack: G2 * sh(f) , out, g0 * f', inB, f', inA, inB, out
%add_fp6_hole
%add_fp254_6_hole
// stack: G2 * sh(f) + g0 * f', inB, f', inA, inB, out
%swap_fp6_hole
%swap_fp254_6_hole
// stack: f' , inB, G2 * sh(f) + g0 * f', inA, inB, out
DUP7
%add_const(2)
// stack: inB1, f' , inB, G2 * sh(f) + g0 * f', inA, inB, out
%load_fp2
%load_fp254_2
// stack: G1 , f' , inB, G2 * sh(f) + g0 * f', inA, inB, out
%mul_fp2_fp6_sh
%mul_fp254_2_fp254_6_sh
// stack: G1 * sh(f'), inB, G2 * sh(f) + g0 * f', inA, inB, out
%add_fp6_hole
%add_fp254_6_hole
// stack: G1 * sh(f') + G2 * sh(f) + g0 * f', inA, inB, out
DUP9
%offset_fp6
%offset_fp254_6
// stack: out', G1 * sh(f') + G2 * sh(f) + g0 * f', inA, inB, out
%store_fp6
%store_fp254_6
// stack: inA, inB, out
%pop3
JUMP
@ -279,7 +279,7 @@ global mul_fp254_12_sparse:
/// cost: 646
/// fp6 functions:
/// fp254_6 functions:
/// fn | num | ops | cost
/// -------------------------
/// load | 2 | 40 | 80
@ -324,58 +324,58 @@ global square_fp254_12:
// stack: inp, out
DUP1
// stack: inp, inp, out
%load_fp6
%load_fp254_6
// stack: f, inp, out
PUSH square_fp12_3
// stack: square_fp12_3, f, inp, out
PUSH square_fp254_12_3
// stack: square_fp254_12_3, f, inp, out
SWAP7
// stack: inp, f, square_fp12_3, out
PUSH square_fp12_2
// stack: square_fp12_2, inp, f, square_fp12_3, out
%dup_fp6_2
// stack: f , square_fp12_2, inp, f, square_fp12_3, out
// stack: inp, f, square_fp254_12_3, out
PUSH square_fp254_12_2
// stack: square_fp254_12_2, inp, f, square_fp254_12_3, out
%dup_fp254_6_2
// stack: f , square_fp254_12_2, inp, f, square_fp254_12_3, out
DUP16
%offset_fp6
// stack: out', f , square_fp12_2, inp, f, square_fp12_3, out
PUSH square_fp12_1
// stack: square_fp12_1, out', f , square_fp12_2, inp, f, square_fp12_3, out
%offset_fp254_6
// stack: out', f , square_fp254_12_2, inp, f, square_fp254_12_3, out
PUSH square_fp254_12_1
// stack: square_fp254_12_1, out', f , square_fp254_12_2, inp, f, square_fp254_12_3, out
DUP10
%offset_fp6
// stack: inp', square_fp12_1, out', f , square_fp12_2, inp, f, square_fp12_3, out
%load_fp6
// stack: f', square_fp12_1, out', f , square_fp12_2, inp, f, square_fp12_3, out
%swap_fp6_hole_2
// stack: f , square_fp12_1, out', f', square_fp12_2, inp, f, square_fp12_3, out
%dup_fp6_8
// stack: f', f , square_fp12_1, out', f', square_fp12_2, inp, f, square_fp12_3, out
%offset_fp254_6
// stack: inp', square_fp254_12_1, out', f , square_fp254_12_2, inp, f, square_fp254_12_3, out
%load_fp254_6
// stack: f', square_fp254_12_1, out', f , square_fp254_12_2, inp, f, square_fp254_12_3, out
%swap_fp254_6_hole_2
// stack: f , square_fp254_12_1, out', f', square_fp254_12_2, inp, f, square_fp254_12_3, out
%dup_fp254_6_8
// stack: f', f , square_fp254_12_1, out', f', square_fp254_12_2, inp, f, square_fp254_12_3, out
%jump(mul_fp254_6)
square_fp12_1:
// stack: f'f, out', f', square_fp12_2, inp, f, square_fp12_3, out
square_fp254_12_1:
// stack: f'f, out', f', square_fp254_12_2, inp, f, square_fp254_12_3, out
DUP7
// stack: out', f'f, out', f', square_fp12_2, inp, f, square_fp12_3, out
%store_fp6_double
// stack: out', f', square_fp12_2, inp, f, square_fp12_3, out
// stack: out', f'f, out', f', square_fp254_12_2, inp, f, square_fp254_12_3, out
%store_fp254_6_double
// stack: out', f', square_fp254_12_2, inp, f, square_fp254_12_3, out
POP
// stack: f', square_fp12_2, inp, f, square_fp12_3, out
// stack: f', square_fp254_12_2, inp, f, square_fp254_12_3, out
%jump(square_fp254_6)
square_fp12_2:
// stack: f'f', inp, f, square_fp12_3, out
square_fp254_12_2:
// stack: f'f', inp, f, square_fp254_12_3, out
%sh_fp254_6
// stack: sh(f'f'), inp, f, square_fp12_3, out
%swap_fp6_hole
// stack: f, inp, sh(f'f'), square_fp12_3, out
// stack: sh(f'f'), inp, f, square_fp254_12_3, out
%swap_fp254_6_hole
// stack: f, inp, sh(f'f'), square_fp254_12_3, out
SWAP6
SWAP13
SWAP6
// stack: f, square_fp12_3, sh(f'f'), inp, out
// stack: f, square_fp254_12_3, sh(f'f'), inp, out
%jump(square_fp254_6)
square_fp12_3:
square_fp254_12_3:
// stack: ff , sh(f'f'), inp, out
%add_fp6
%add_fp254_6
// stack: ff + sh(f'f'), inp, out
DUP8
// stack: out, ff + sh(f'f'), inp, out
%store_fp6
%store_fp254_6
// stack: inp, out
%pop2
JUMP

View File

@ -34,23 +34,23 @@ global test_frob_fp254_12_6:
// stack: ptr
DUP1
// stack: ptr, ptr
%load_fp6
%load_fp254_6
// stack: f, ptr
%frob_fp254_6_1
// stack: g, ptr
DUP7
// stack: ptr, g, ptr
%store_fp6
%store_fp254_6
// stack: ptr
DUP1 %offset_fp6
DUP1 %offset_fp254_6
// stack: ptr', ptr
%load_fp6
%load_fp254_6
// stack: f', ptr
%frobz_1
// stack: g', ptr
DUP7 %offset_fp6
DUP7 %offset_fp254_6
// stack: ptr', g', ptr
%store_fp6
%store_fp254_6
// stack: ptr
%endmacro
@ -59,23 +59,23 @@ global test_frob_fp254_12_6:
// stack: ptr , out
DUP1
// stack: ptr, ptr , out
%load_fp6
%load_fp254_6
// stack: f, ptr , out
%frob_fp254_6_2
// stack: g, ptr , out
DUP8
// stack: out, g, ptr , out
%store_fp6
%store_fp254_6
// stack: ptr , out
%offset_fp6
%offset_fp254_6
// stack: ptr', out
%load_fp6
%load_fp254_6
// stack: f', out
%frobz_2
// stack: g', out
DUP7 %offset_fp6
DUP7 %offset_fp254_6
// stack: out', g', out
%store_fp6
%store_fp254_6
// stack: out
%endmacro
@ -83,37 +83,37 @@ global test_frob_fp254_12_6:
// stack: ptr
DUP1
// stack: ptr, ptr
%load_fp6
%load_fp254_6
// stack: f, ptr
%frob_fp254_6_3
// stack: g, ptr
DUP7
// stack: ptr, g, ptr
%store_fp6
%store_fp254_6
// stack: ptr
DUP1 %offset_fp6
DUP1 %offset_fp254_6
// stack: ptr', ptr
%load_fp6
%load_fp254_6
// stack: f', ptr
%frobz_3
// stack: g', ptr
DUP7 %offset_fp6
DUP7 %offset_fp254_6
// stack: ptr', g', ptr
%store_fp6
%store_fp254_6
// stack: ptr
%endmacro
%macro frob_fp254_12_6
// stack: ptr
DUP1 %offset_fp6
DUP1 %offset_fp254_6
// stack: ptr', ptr
%load_fp6
%load_fp254_6
// stack: f', ptr
%frobz_6
// stack: g', ptr
DUP7 %offset_fp6
DUP7 %offset_fp254_6
// stack: ptr', g', ptr
%store_fp6
%store_fp254_6
// stack: ptr
%endmacro
@ -131,37 +131,37 @@ global test_frob_fp254_12_6:
// stack: C0 , C1 , C2
%conj_fp254_2
// stack: D0 , C1 , C2
%swap_fp2_hole_2
%swap_fp254_2_hole_2
// stack: C2 , C1 , D0
%conj_fp254_2
// stack: C2`, C1 , D0
%frobt2_1
// stack: D2 , C1 , D0
%swap_fp2_hole_2
%swap_fp254_2_hole_2
// stack: D0 , C1 , D2
%swap_fp2
%swap_fp254_2
// stack: C1 , D0 , D2
%conj_fp254_2
// stack: C1`, D0 , D2
%frobt1_1
// stack: D1 , D0 , D2
%swap_fp2
%swap_fp254_2
// stack: D0 , D1 , D2
%endmacro
%macro frob_fp254_6_2
// stack: C0, C1, C2
%swap_fp2_hole_2
%swap_fp254_2_hole_2
// stack: C2, C1, C0
%frobt2_2
// stack: D2, C1, C0
%swap_fp2_hole_2
%swap_fp254_2_hole_2
// stack: C0, C1, D2
%swap_fp2
%swap_fp254_2
// stack: C1, C0, D2
%frobt1_2
// stack: D1, C0, D2
%swap_fp2
%swap_fp254_2
// stack: D0, D1, D2
%endmacro
@ -169,21 +169,21 @@ global test_frob_fp254_12_6:
// stack: C0 , C1 , C2
%conj_fp254_2
// stack: D0 , C1 , C2
%swap_fp2_hole_2
%swap_fp254_2_hole_2
// stack: C2 , C1 , D0
%conj_fp254_2
// stack: C2`, C1 , D0
%frobt2_3
// stack: D2 , C1 , D0
%swap_fp2_hole_2
%swap_fp254_2_hole_2
// stack: D0 , C1 , D2
%swap_fp2
%swap_fp254_2
// stack: C1 , D0 , D2
%conj_fp254_2
// stack: C1`, D0 , D2
%frobt1_3
// stack: D1 , D0 , D2
%swap_fp2
%swap_fp254_2
// stack: D0 , D1 , D2
%endmacro
@ -192,59 +192,59 @@ global test_frob_fp254_12_6:
%frob_fp254_6_1
PUSH 0x246996f3b4fae7e6a6327cfe12150b8e747992778eeec7e5ca5cf05f80f362ac
PUSH 0x1284b71c2865a7dfe8b99fdd76e68b605c521e08292f2176d60b35dadcc9e470
%mul_fp2_fp6
%mul_fp254_2_fp254_6
%endmacro
%macro frobz_2
%frob_fp254_6_2
PUSH 0x30644e72e131a0295e6dd9e7e0acccb0c28f069fbb966e3de4bd44e5607cfd49
%mul_fp_fp6
%mul_fp254__fp254_6
%endmacro
%macro frobz_3
%frob_fp254_6_3
PUSH 0xabf8b60be77d7306cbeee33576139d7f03a5e397d439ec7694aa2bf4c0c101
PUSH 0x19dc81cfcc82e4bbefe9608cd0acaa90894cb38dbe55d24ae86f7d391ed4a67f
%mul_fp2_fp6
%mul_fp254_2_fp254_6
%endmacro
%macro frobz_6
PUSH 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd46
%mul_fp_fp6
%mul_fp254__fp254_6
%endmacro
%macro frobt1_1
PUSH 0x16c9e55061ebae204ba4cc8bd75a079432ae2a1d0b7c9dce1665d51c640fcba2
PUSH 0x2fb347984f7911f74c0bec3cf559b143b78cc310c2c3330c99e39557176f553d
%mul_fp2
%mul_fp254_2
%endmacro
%macro frobt2_1
PUSH 0x2c145edbe7fd8aee9f3a80b03b0b1c923685d2ea1bdec763c13b4711cd2b8126
PUSH 0x5b54f5e64eea80180f3c0b75a181e84d33365f7be94ec72848a1f55921ea762
%mul_fp2
%mul_fp254_2
%endmacro
%macro frobt1_2
PUSH 0x30644e72e131a0295e6dd9e7e0acccb0c28f069fbb966e3de4bd44e5607cfd48
%mul_fp_fp2
%mul_fp254__fp254_2
%endmacro
%macro frobt2_2
PUSH 0x59e26bcea0d48bacd4f263f1acdb5c4f5763473177fffffe
%mul_fp_fp2
%mul_fp254__fp254_2
%endmacro
%macro frobt1_3
PUSH 0x4f1de41b3d1766fa9f30e6dec26094f0fdf31bf98ff2631380cab2baaa586de
PUSH 0x856e078b755ef0abaff1c77959f25ac805ffd3d5d6942d37b746ee87bdcfb6d
%mul_fp2
%mul_fp254_2
%endmacro
%macro frobt2_3
PUSH 0x23d5e999e1910a12feb0f6ef0cd21d04a44a9e08737f96e55fe3ed9d730c239f
PUSH 0xbc58c6611c08dab19bee0f7b5b2444ee633094575b06bcb0e1a92bc3ccbf066
%mul_fp2
%mul_fp254_2
%endmacro

View File

@ -28,7 +28,7 @@ global inv_fp254_12:
// stack: f^-1, inp, out, retdest
DUP14
// stack: out, f^-1, inp, out, retdest
%store_fp12
%store_fp254_12
// stack: inp, out, retdest
%stack (inp, out) -> (inp, out, 50, check_inv_fp254_12)
// stack: inp, out, 50, check_inv_fp254_12, retdest
@ -36,9 +36,9 @@ global inv_fp254_12:
check_inv_fp254_12:
// stack: retdest
PUSH 50
%load_fp12
%load_fp254_12
// stack: unit?, retdest
%assert_eq_unit_fp12
%assert_eq_unit_fp254_12
// stack: retdest
JUMP

View File

@ -1,11 +1,11 @@
%macro offset_fp6
%macro offset_fp254_6
%add_const(6)
%endmacro
// fp2 macros
// fp254_2 macros
// cost: 2 loads + 6 dup/swaps + 5 adds = 6*4 + 6*1 + 5*2 = 40
%macro load_fp2
%macro load_fp254_2
// stack: ptr
DUP1
%add_const(1)
@ -28,7 +28,7 @@
// stack: a, -b
%endmacro
%macro swap_fp2
%macro swap_fp254_2
// stack: a , a_, b , b_
SWAP2
// stack: b , a_, a , b_
@ -40,7 +40,7 @@
// stack: b , b_, a , a_
%endmacro
%macro swap_fp2_hole_2
%macro swap_fp254_2_hole_2
// stack: a , a_, X, b , b_
SWAP4
// stack: b , a_, X, a , b_
@ -52,7 +52,7 @@
// stack: b , b_, X, a , a_
%endmacro
%macro mul_fp_fp2
%macro mul_fp254__fp254_2
// stack: c, x, y
SWAP2
// stack: y, x, c
@ -89,7 +89,7 @@
// stack: 9b + a, 9a - b
%endmacro
%macro mul_fp2
%macro mul_fp254_2
// stack: a, b, c, d
DUP4
DUP3
@ -115,10 +115,10 @@
// stack: ac - bd, bc + ad
%endmacro
// fp6 macros
// fp254_6 macros
// cost: 6 loads + 6 dup/swaps + 5 adds = 6*4 + 6*1 + 5*2 = 40
%macro load_fp6
%macro load_fp254_6
// stack: ptr
DUP1
%add_const(4)
@ -152,7 +152,7 @@
%endmacro
// cost: 6 loads + 6 pushes + 5 adds = 6*4 + 6*1 + 5*2 = 40
%macro load_fp6(ptr)
%macro load_fp254_6(ptr)
// stack:
PUSH $ptr
%add_const(5)
@ -186,7 +186,7 @@
%endmacro
// cost: 6 stores + 6 swaps/dups + 5 adds = 6*4 + 6*1 + 5*2 = 40
%macro store_fp6
%macro store_fp254_6
// stack: ptr, x0, x1, x2, x3, x4 , x5
SWAP5
// stack: x4, x0, x1, x2, x3, ptr, x5
@ -221,7 +221,7 @@
%endmacro
// cost: 6 stores + 7 swaps/dups + 5 adds + 6 doubles = 6*4 + 7*1 + 5*2 + 6*2 = 53
%macro store_fp6_double
%macro store_fp254_6_double
// stack: ptr, x0, x1, x2, x3, x4, x5
SWAP6
// stack: x5, x0, x1, x2, x3, x4, ptr
@ -276,7 +276,7 @@
%endmacro
// cost: 6 stores + 6 pushes + 5 adds = 6*4 + 6*1 + 5*2 = 40
%macro store_fp6(ptr)
%macro store_fp254_6(ptr)
// stack: x0, x1, x2, x3, x4, x5
PUSH $ptr
// stack: ind0, x0, x1, x2, x3, x4, x5
@ -310,7 +310,7 @@
%endmacro
// cost: store (40) + i9 (9) = 49
%macro store_fp6_sh(ptr)
%macro store_fp254_6_sh(ptr)
// stack: x0, x1, x2, x3, x4, x5
PUSH $ptr
%add_const(2)
@ -346,7 +346,7 @@
%endmacro
// cost: 6
%macro dup_fp6_0
%macro dup_fp254_6_0
// stack: f: 6
DUP6
DUP6
@ -358,7 +358,7 @@
%endmacro
// cost: 6
%macro dup_fp6_2
%macro dup_fp254_6_2
// stack: X: 2, f: 6
DUP8
DUP8
@ -370,7 +370,7 @@
%endmacro
// cost: 6
%macro dup_fp6_6
%macro dup_fp254_6_6
// stack: X: 6, f: 6
DUP12
DUP12
@ -382,7 +382,7 @@
%endmacro
// cost: 6
%macro dup_fp6_7
%macro dup_fp254_6_7
// stack: X: 7, f: 6
DUP13
DUP13
@ -394,7 +394,7 @@
%endmacro
// cost: 6
%macro dup_fp6_8
%macro dup_fp254_6_8
// stack: X: 8, f: 6
DUP14
DUP14
@ -406,7 +406,7 @@
%endmacro
// cost: 16
%macro swap_fp6
%macro swap_fp254_6
// stack: f0, f1, f2, f3, f4, f5, g0, g1, g2, g3, g4, g5
SWAP6
// stack: g0, f1, f2, f3, f4, f5, f0, g1, g2, g3, g4, g5
@ -433,9 +433,9 @@
%endmacro
// cost: 16
// swap two fp6 elements with a stack term separating them
// swap two fp254_6 elements with a stack term separating them
// (f: 6, X, g: 6) -> (g: 6, X, f: 6)
%macro swap_fp6_hole
%macro swap_fp254_6_hole
// stack: f0, f1, f2, f3, f4, f5, X, g0, g1, g2, g3, g4, g5
SWAP7
// stack: g0, f1, f2, f3, f4, f5, X, f0, g1, g2, g3, g4, g5
@ -462,9 +462,9 @@
%endmacro
// cost: 16
// swap two fp6 elements with two stack terms separating them
// swap two fp254_6 elements with two stack terms separating them
// (f: 6, X: 2, g: 6) -> (g: 6, X: 2, f: 6)
%macro swap_fp6_hole_2
%macro swap_fp254_6_hole_2
// stack: f0, f1, f2, f3, f4, f5, X, g0, g1, g2, g3, g4, g5
SWAP8
// stack: g0, f1, f2, f3, f4, f5, X, f0, g1, g2, g3, g4, g5
@ -513,7 +513,7 @@
%endmacro
// cost: 16
%macro add_fp6
%macro add_fp254_6
// stack: f0, f1, f2, f3, f4, f5, g0, g1, g2, g3, g4, g5
SWAP7
ADDFP254
@ -540,9 +540,9 @@
%endmacro
// cost: 18
// add two fp6 elements with a to-be-popped stack term separating them
// add two fp254_6 elements with a to-be-popped stack term separating them
// (f: 6, X, g: 6) -> (f + g: 6)
%macro add_fp6_hole
%macro add_fp254_6_hole
// stack: f0, f1, f2, f3, f4, f5, X, g0, g1, g2, g3, g4, g5
SWAP8
ADDFP254
@ -571,7 +571,7 @@
%endmacro
// *reversed argument subtraction* cost: 17
%macro subr_fp6
%macro subr_fp254_6
// stack: f0, f1, f2, f3, f4, f5, g0, g1, g2, g3, g4, g5
SWAP7
SUBFP254
@ -599,7 +599,7 @@
%endmacro
// cost: 21
%macro mul_fp_fp6
%macro mul_fp254__fp254_6
// stack: c , f0, f1, f2, f3, f4, f5
SWAP6
DUP7
@ -639,7 +639,7 @@
/// G1 = (a+bi)(f1+f1_i) = (af1 - bf1_) + (bf1 + af1_)i
/// G2 = (a+bi)(f2+f2_i) = (af2 - bf2_) + (bf2 + af2_)i
%macro mul_fp2_fp6
%macro mul_fp254_2_fp254_6
// stack: a, b, f0, f0_, f1, f1_, f2, f2_
DUP2
DUP5
@ -730,7 +730,7 @@
/// G1 = (a+bi)(f0+f0_i) = (af0 - bf0_) + (bf0 + af0_)i
/// G2 = (a+bi)(f1+f1_i) = (af1 - bf1_) + (bf1 + af1_)i
%macro mul_fp2_fp6_sh
%macro mul_fp254_2_fp254_6_sh
// stack: a, b, f0, f0_, f1, f1_, f2, f2_
DUP6
DUP3
@ -824,7 +824,7 @@
/// G1 = (a+bi)(f2+f2_i) = (cf2 - df2_) + (df2 + cf2_)i
/// G2 = (a+bi)(f0+f0_i) = (af0 - bf0_) + (bf0 + af0_)i
%macro mul_fp2_fp6_sh2
%macro mul_fp254_2_fp254_6_sh2
// stack: a, b, f0, f0_, f1, f1_, f2, f2_
DUP4
DUP3
@ -908,7 +908,7 @@
// stack: g0, g0_, g1, g1_, g2, g2_
%endmacro
%macro load_fp12
%macro load_fp254_12
// stack: ptr
DUP1
%add_const(10)
@ -971,7 +971,7 @@
// stack: x00, x01, x02, x03, x04, x05, x06, x07, x08, x09, x10, x11
%endmacro
%macro store_fp12
%macro store_fp254_12
// stack: ptr, x00, x01, x02, x03, x04, x05, x06, x07, x08, x09, x10, x11
SWAP11
// stack: x10, x00, x01, x02, x03, x04, x05, x06, x07, x08, x09, ptr, x11
@ -1035,9 +1035,9 @@
// stack:
%endmacro
/// moves fp12 from src..src+12 to dest..dest+12
/// moves fp254_12 from src..src+12 to dest..dest+12
/// these should not overlap. leaves dest on stack
%macro move_fp12
%macro move_fp254_12
// stack: src, dest
DUP1
// stack: ind00, src, dest
@ -1157,7 +1157,7 @@
%mstore_kernel_general
%endmacro
%macro assert_eq_unit_fp12
%macro assert_eq_unit_fp254_12
%assert_eq_const(1)
%assert_zero
%assert_zero