mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-11 18:23:09 +00:00
naming for global labels
This commit is contained in:
parent
c107c5055e
commit
0f030fae4a
@ -31,8 +31,8 @@ pub(crate) fn combined_kernel() -> Kernel {
|
||||
include_str!("asm/curve/bn254/curve_arithmetic/miller_loop.asm"),
|
||||
include_str!("asm/curve/bn254/curve_arithmetic/tate_pairing.asm"),
|
||||
include_str!("asm/curve/bn254/field_arithmetic/inverse.asm"),
|
||||
include_str!("asm/curve/bn254/field_arithmetic/fp6_mul.asm"),
|
||||
include_str!("asm/curve/bn254/field_arithmetic/fp12_mul.asm"),
|
||||
include_str!("asm/curve/bn254/field_arithmetic/degree_6_mul.asm"),
|
||||
include_str!("asm/curve/bn254/field_arithmetic/degree_12_mul.asm"),
|
||||
include_str!("asm/curve/bn254/field_arithmetic/frobenius.asm"),
|
||||
include_str!("asm/curve/bn254/field_arithmetic/util.asm"),
|
||||
include_str!("asm/curve/common.asm"),
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
/// y1 = y1.frob(1)
|
||||
/// return y * y2 * y1 * y0
|
||||
|
||||
global final_exp:
|
||||
global bn254_final_exp:
|
||||
// stack: val, retdest
|
||||
%stack (val) -> (val, 300, val)
|
||||
// stack: val, 300, val, retdest
|
||||
@ -47,43 +47,43 @@ make_term_1:
|
||||
// stack: val, retdest {212: y2, 224: y4, 236: y0^-1}
|
||||
%stack () -> (212, 224, 224, make_term_2)
|
||||
// stack: 212, 224, 224, make_term_2, val, retdest {212: y2, 224: y4, 236: y0^-1}
|
||||
%jump(mul_fp12)
|
||||
%jump(mul_fp254_12)
|
||||
make_term_2:
|
||||
// stack: val, retdest {212: y2, 224: y4 * y2, 236: y0^-1}
|
||||
%stack () -> (212, 224, 224, make_term_3)
|
||||
// stack: 212, 224, 224, make_term_3, val, retdest {212: y2, 224: y4 * y2, 236: y0^-1}
|
||||
%jump(mul_fp12)
|
||||
%jump(mul_fp254_12)
|
||||
make_term_3:
|
||||
// stack: val, retdest {212: y2, 224: y4 * y2^2, 236: y0^-1}
|
||||
%stack () -> (236, 224, 224, final_power)
|
||||
// stack: 236, 224, 224, final_power, val, retdest {212: y2, 224: y4 * y2^2, 236: y0^-1}
|
||||
%jump(mul_fp12)
|
||||
%jump(mul_fp254_12)
|
||||
|
||||
final_power:
|
||||
// stack: val, retdest {val: y , 212: y^a2 , 224: y^a1 , 236: y^a0}
|
||||
%frob_fp12_3
|
||||
%frob_fp254_12_3
|
||||
// stack: val, retdest {val: y_3, 212: y^a2 , 224: y^a1 , 236: y^a0}
|
||||
%stack () -> (212, 212)
|
||||
%frob_fp12_2_
|
||||
%frob_fp254_12_2_
|
||||
POP
|
||||
// stack: val, retdest {val: y_3, 212: (y^a2)_2, 224: y^a1 , 236: y^a0}
|
||||
PUSH 224
|
||||
%frob_fp12_1
|
||||
%frob_fp254_12_1
|
||||
POP
|
||||
// stack: val, retdest {val: y_3, 212: (y^a2)_2, 224: (y^a1)_1, 236: y^a0}
|
||||
%stack (val) -> (212, val, val, penult_mul, val)
|
||||
// stack: 212, val, val, penult_mul, val, retdest {val: y_3, 212: (y^a2)_2, 224: (y^a1)_1, 236: y^a0}
|
||||
%jump(mul_fp12)
|
||||
%jump(mul_fp254_12)
|
||||
penult_mul:
|
||||
// stack: val, retdest {val: y_3 * (y^a2)_2, 224: (y^a1)_1, 236: y^a0}
|
||||
%stack (val) -> (224, val, val, final_mul, val)
|
||||
// stack: 224, val, val, final_mul, val, retdest {val: y_3 * (y^a2)_2, 224: (y^a1)_1, 236: y^a0}
|
||||
%jump(mul_fp12)
|
||||
%jump(mul_fp254_12)
|
||||
final_mul:
|
||||
// stack: val, retdest {val: y_3 * (y^a2)_2 * (y^a1)_1, 236: y^a0}
|
||||
%stack (val) -> (236, val, val)
|
||||
// stack: 236, val, val, retdest {val: y_3 * (y^a2)_2 * (y^a1)_1, 236: y^a0}
|
||||
%jump(mul_fp12)
|
||||
%jump(mul_fp254_12)
|
||||
|
||||
|
||||
/// def power_loop_4():
|
||||
@ -95,7 +95,7 @@ final_mul:
|
||||
/// y2 *= acc
|
||||
/// if c:
|
||||
/// y0 *= acc
|
||||
/// acc = square_fp12(acc)
|
||||
/// acc = square_fp254_12(acc)
|
||||
/// y4 *= acc
|
||||
///
|
||||
/// def power_loop_2():
|
||||
@ -105,7 +105,7 @@ final_mul:
|
||||
/// y2 *= acc
|
||||
/// if b:
|
||||
/// y0 *= acc
|
||||
/// acc = square_fp12(acc)
|
||||
/// acc = square_fp254_12(acc)
|
||||
/// y2 *= acc
|
||||
///
|
||||
/// def power_loop_0():
|
||||
@ -113,7 +113,7 @@ final_mul:
|
||||
/// a = load(i, power_data_0)
|
||||
/// if a:
|
||||
/// y0 *= acc
|
||||
/// acc = square_fp12(acc)
|
||||
/// acc = square_fp254_12(acc)
|
||||
/// y0 *= acc
|
||||
|
||||
power_loop_4:
|
||||
@ -139,7 +139,7 @@ power_loop_4:
|
||||
// stack: 224, 224, power_loop_4_b, bc, i-1, j, k, sqr {200: y0, 212: y2, 224: y4}
|
||||
DUP8
|
||||
// stack: sqr, 224, 224, power_loop_4_b, bc, i-1, j, k, sqr {200: y0, 212: y2, 224: y4}
|
||||
%jump(mul_fp12)
|
||||
%jump(mul_fp254_12)
|
||||
power_loop_4_b:
|
||||
// stack: bc, i, j, k, sqr {200: y0, 212: y2, 224: y4}
|
||||
DUP1
|
||||
@ -153,7 +153,7 @@ power_loop_4_b:
|
||||
// stack: 212, 212, power_loop_4_c, c, i, j, k, sqr {200: y0, 212: y2, 224: y4}
|
||||
DUP8
|
||||
// stack: sqr, 212, 212, power_loop_4_c, c, i, j, k, sqr {200: y0, 212: y2, 224: y4}
|
||||
%jump(mul_fp12)
|
||||
%jump(mul_fp254_12)
|
||||
power_loop_4_c:
|
||||
// stack: c, i, j, k, sqr {200: y0, 212: y2, 224: y4}
|
||||
ISZERO
|
||||
@ -164,7 +164,7 @@ power_loop_4_c:
|
||||
// stack: 200, 200, power_loop_4_sq, i, j, k, sqr {200: y0, 212: y2, 224: y4}
|
||||
DUP7
|
||||
// stack: sqr, 200, 200, power_loop_4_sq, i, j, k, sqr {200: y0, 212: y2, 224: y4}
|
||||
%jump(mul_fp12)
|
||||
%jump(mul_fp254_12)
|
||||
power_loop_4_sq:
|
||||
// stack: i, j, k, sqr {200: y0, 212: y2, 224: y4}
|
||||
PUSH power_loop_4
|
||||
@ -172,7 +172,7 @@ power_loop_4_sq:
|
||||
DUP5
|
||||
DUP1
|
||||
// stack: sqr, sqr, power_loop_4, i, j, k, sqr {200: y0, 212: y2, 224: y4}
|
||||
%jump(square_fp12)
|
||||
%jump(square_fp254_12)
|
||||
power_loop_4_end:
|
||||
// stack: 0, j, k, sqr {200: y0, 212: y2, 224: y4}
|
||||
POP
|
||||
@ -181,7 +181,7 @@ power_loop_4_end:
|
||||
// stack: 224, 224, power_loop_2, j, k, sqr {200: y0, 212: y2, 224: y4}
|
||||
DUP6
|
||||
// stack: sqr, 224, 224, power_loop_2, j, k, sqr {200: y0, 212: y2, 224: y4}
|
||||
%jump(mul_fp12)
|
||||
%jump(mul_fp254_12)
|
||||
|
||||
power_loop_2:
|
||||
// stack: j , k, sqr {200: y0, 212: y2, 224: y4}
|
||||
@ -206,7 +206,7 @@ power_loop_2:
|
||||
// stack: 212, 212, power_loop_2_b, b, j-1, k, sqr {200: y0, 212: y2, 224: y4}
|
||||
DUP7
|
||||
// stack: sqr, 212, 212, power_loop_2_b, b, j-1, k, sqr {200: y0, 212: y2, 224: y4}
|
||||
%jump(mul_fp12)
|
||||
%jump(mul_fp254_12)
|
||||
power_loop_2_b:
|
||||
// stack: b, j, k, sqr {200: y0, 212: y2, 224: y4}
|
||||
ISZERO
|
||||
@ -217,7 +217,7 @@ power_loop_2_b:
|
||||
// stack: 200, 200, power_loop_2_sq, j, k, sqr {200: y0, 212: y2, 224: y4}
|
||||
DUP6
|
||||
// stack: sqr, 200, 200, power_loop_2_sq, j, k, sqr {200: y0, 212: y2, 224: y4}
|
||||
%jump(mul_fp12)
|
||||
%jump(mul_fp254_12)
|
||||
power_loop_2_sq:
|
||||
// stack: j, k, sqr {200: y0, 212: y2, 224: y4}
|
||||
PUSH power_loop_2
|
||||
@ -225,7 +225,7 @@ power_loop_2_sq:
|
||||
DUP4
|
||||
DUP1
|
||||
// stack: sqr, sqr, power_loop_2, j, k, sqr {200: y0, 212: y2, 224: y4}
|
||||
%jump(square_fp12)
|
||||
%jump(square_fp254_12)
|
||||
power_loop_2_end:
|
||||
// stack: 0, k, sqr {200: y0, 212: y2, 224: y4}
|
||||
POP
|
||||
@ -234,7 +234,7 @@ power_loop_2_end:
|
||||
// stack: 212, 212, power_loop_0, k, sqr {200: y0, 212: y2, 224: y4}
|
||||
DUP5
|
||||
// stack: sqr, 212, 212, power_loop_0, k, sqr {200: y0, 212: y2, 224: y4}
|
||||
%jump(mul_fp12)
|
||||
%jump(mul_fp254_12)
|
||||
|
||||
power_loop_0:
|
||||
// stack: k , sqr {200: y0, 212: y2, 224: y4}
|
||||
@ -256,7 +256,7 @@ power_loop_0:
|
||||
// stack: 200, 200, power_loop_0_sq, k-1, sqr {200: y0, 212: y2, 224: y4}
|
||||
DUP5
|
||||
// stack: sqr, 200, 200, power_loop_0_sq, k-1, sqr {200: y0, 212: y2, 224: y4}
|
||||
%jump(mul_fp12)
|
||||
%jump(mul_fp254_12)
|
||||
power_loop_0_sq:
|
||||
// stack: k, sqr {200: y0, 212: y2, 224: y4}
|
||||
PUSH power_loop_0
|
||||
@ -264,9 +264,9 @@ power_loop_0_sq:
|
||||
DUP3
|
||||
DUP1
|
||||
// stack: sqr, sqr, power_loop_0, k, sqr {200: y0, 212: y2, 224: y4}
|
||||
%jump(square_fp12)
|
||||
%jump(square_fp254_12)
|
||||
power_loop_0_end:
|
||||
// stack: 0, sqr {200: y0, 212: y2, 224: y4}
|
||||
%stack (i, sqr) -> (200, sqr, 200, custom_powers)
|
||||
// stack: 200, sqr, 200, custom_powers {200: y0, 212: y2, 224: y4}
|
||||
%jump(mul_fp12)
|
||||
%jump(mul_fp254_12)
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
/// 0xnm -= 1
|
||||
/// mul_tangent()
|
||||
|
||||
global miller:
|
||||
global bn254_miller:
|
||||
// stack: ptr, out, retdest
|
||||
%stack (ptr, out) -> (out, 1, ptr, out)
|
||||
// stack: out, 1, ptr, out, retdest
|
||||
@ -36,7 +36,7 @@ global miller:
|
||||
%stack (P: 2) -> (0, 53, P, P)
|
||||
// stack: 0, 53, O, P, Q, out, retdest
|
||||
// the head 0 lets miller_loop start with POP
|
||||
global miller_loop:
|
||||
miller_loop:
|
||||
POP
|
||||
// stack: times , O, P, Q, out, retdest
|
||||
DUP1
|
||||
@ -85,9 +85,9 @@ miller_zero:
|
||||
|
||||
|
||||
/// def mul_tangent()
|
||||
/// out = square_fp12(out)
|
||||
/// out = square_fp254_12(out)
|
||||
/// line = tangent(O, Q)
|
||||
/// out = mul_fp12_sparse(out, line)
|
||||
/// out = mul_fp254_12_sparse(out, line)
|
||||
/// O += O
|
||||
|
||||
mul_tangent:
|
||||
@ -98,7 +98,7 @@ mul_tangent:
|
||||
// stack: mul_tangent_1, out, mul_tangent_2, retdest, 0xnm, times, O, P, Q, out
|
||||
%stack (mul_tangent_1, out) -> (out, out, mul_tangent_1, out)
|
||||
// stack: out, out, mul_tangent_1, out, mul_tangent_2, retdest, 0xnm, times, O, P, Q, out
|
||||
%jump(square_fp12)
|
||||
%jump(square_fp254_12)
|
||||
mul_tangent_1:
|
||||
// stack: out, mul_tangent_2, retdest, 0xnm, times, O, P, Q, out
|
||||
DUP13
|
||||
@ -113,7 +113,7 @@ mul_tangent_1:
|
||||
// stack: out, mul_tangent_2, retdest, 0xnm, times, O, P, Q, out {100: line}
|
||||
%stack (out) -> (out, 100, out)
|
||||
// stack: out, 100, out, mul_tangent_2, retdest, 0xnm, times, O, P, Q, out {100: line}
|
||||
%jump(mul_fp12_sparse)
|
||||
%jump(mul_fp254_12_sparse)
|
||||
mul_tangent_2:
|
||||
// stack: retdest, 0xnm, times, O, P, Q, out {100: line}
|
||||
PUSH after_double
|
||||
@ -133,7 +133,7 @@ after_double:
|
||||
|
||||
/// def mul_cord()
|
||||
/// line = cord(P, O, Q)
|
||||
/// out = mul_fp12_sparse(out, line)
|
||||
/// out = mul_fp254_12_sparse(out, line)
|
||||
/// O += P
|
||||
|
||||
mul_cord:
|
||||
@ -157,7 +157,7 @@ mul_cord:
|
||||
// stack: out, mul_cord_1, 0xnm, times, O, P, Q, out {100: line}
|
||||
%stack (out) -> (out, 100, out)
|
||||
// stack: out, 100, out, mul_cord_1, 0xnm, times, O, P, Q, out {100: line}
|
||||
%jump(mul_fp12_sparse)
|
||||
%jump(mul_fp254_12_sparse)
|
||||
mul_cord_1:
|
||||
// stack: 0xnm, times, O , P, Q, out
|
||||
PUSH after_add
|
||||
|
||||
@ -1,18 +1,18 @@
|
||||
/// def tate(P: Curve, Q: TwistedCurve) -> Fp12:
|
||||
/// out = miller_loop(P, Q)
|
||||
/// return make_invariant(P, Q)
|
||||
global tate:
|
||||
global bn254_tate:
|
||||
// stack: inp, out, retdest
|
||||
%stack (inp, out) -> (inp, out, make_invariant, out)
|
||||
// stack: inp, out, make_invariant, out, retdest
|
||||
%jump(miller)
|
||||
%jump(bn254_miller)
|
||||
|
||||
|
||||
/// def make_invariant(y: Fp12):
|
||||
/// y = first_exp(y)
|
||||
/// y = second_exp(y)
|
||||
/// return final_exponentiation(y)
|
||||
global make_invariant:
|
||||
make_invariant:
|
||||
|
||||
/// map t to t^(p^6 - 1) via
|
||||
/// def first_exp(t):
|
||||
@ -21,21 +21,21 @@ global make_invariant:
|
||||
%stack (out) -> (out, 100, first_exp, out)
|
||||
// stack: out, 100, first_exp, out, retdest {out: y}
|
||||
%jump(inv_fp254_12)
|
||||
global first_exp:
|
||||
first_exp:
|
||||
// stack: out, retdest {out: y , 100: y^-1}
|
||||
%frob_fp12_6
|
||||
%frob_fp254_12_6
|
||||
// stack: out, retdest {out: y_6, 100: y^-1}
|
||||
%stack (out) -> (out, 100, out, second_exp, out)
|
||||
// stack: out, 100, out, second_exp, out, retdest {out: y_6, 100: y^-1}
|
||||
%jump(mul_fp12)
|
||||
%jump(mul_fp254_12)
|
||||
|
||||
/// map t to t^(p^2 + 1) via
|
||||
/// def second_exp(t):
|
||||
/// return t.frob(2) * t
|
||||
global second_exp:
|
||||
// stack: out, retdest {out: y}
|
||||
%stack (out) -> (out, 100, out, out, final_exp, out)
|
||||
// stack: out, 100, out, out, final_exp, out, retdest {out: y}
|
||||
%frob_fp12_2_
|
||||
// stack: 100, out, out, final_exp, out, retdest {out: y, 100: y_2}
|
||||
%jump(mul_fp12)
|
||||
second_exp:
|
||||
// stack: out, retdest {out: y}
|
||||
%stack (out) -> (out, 100, out, out, bn254_final_exp, out)
|
||||
// stack: out, 100, out, out, bn254_final_exp, out, retdest {out: y}
|
||||
%frob_fp254_12_2_
|
||||
// stack: 100, out, out, bn254_final_exp, out, retdest {out: y, 100: y_2}
|
||||
%jump(mul_fp254_12)
|
||||
|
||||
@ -43,7 +43,7 @@
|
||||
///
|
||||
/// f, f', g, g' consist of six elements on the stack
|
||||
|
||||
global mul_fp12:
|
||||
global mul_fp254_12:
|
||||
// stack: inA, inB, out
|
||||
DUP1
|
||||
%offset_fp6
|
||||
@ -61,7 +61,7 @@ global mul_fp12:
|
||||
// stack: f', mul_fp12_1, g', f', inA, inB, out
|
||||
%dup_fp6_7
|
||||
// stack: g', f', mul_fp12_1, g', f', inA, inB, out
|
||||
%jump(mul_fp6)
|
||||
%jump(mul_fp254_6)
|
||||
mul_fp12_1:
|
||||
// stack: f'g', g' , f', inA, inB, out
|
||||
%dup_fp6_0
|
||||
@ -90,7 +90,7 @@ mul_fp12_1:
|
||||
// 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'}
|
||||
%jump(mul_fp6)
|
||||
%jump(mul_fp254_6)
|
||||
mul_fp12_2:
|
||||
// stack: fg, g+g', f', inA, inB, out {0: sh(f'g'), 6: f'g'}
|
||||
%store_fp6(12)
|
||||
@ -105,7 +105,7 @@ mul_fp12_2:
|
||||
// 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}
|
||||
%jump(mul_fp6)
|
||||
%jump(mul_fp254_6)
|
||||
mul_fp12_3:
|
||||
// stack: (f+f')(g+g'), inB, out {0: sh(f'g'), 6: f'g', 12: fg}
|
||||
%load_fp6(12)
|
||||
@ -180,7 +180,7 @@ mul_fp12_3:
|
||||
///
|
||||
/// f, f' consist of six elements; G1, G1' consist of two elements; and g0 of one element
|
||||
|
||||
global mul_fp12_sparse:
|
||||
global mul_fp254_12_sparse:
|
||||
// stack: inA, inB, out
|
||||
DUP1
|
||||
%offset_fp6
|
||||
@ -317,10 +317,10 @@ global mul_fp12_sparse:
|
||||
///
|
||||
/// f, f' consist of six elements on the stack
|
||||
|
||||
global square_fp12_test:
|
||||
global square_fp254_12_test:
|
||||
POP
|
||||
|
||||
global square_fp12:
|
||||
global square_fp254_12:
|
||||
// stack: inp, out
|
||||
DUP1
|
||||
// stack: inp, inp, out
|
||||
@ -348,7 +348,7 @@ global square_fp12:
|
||||
// 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
|
||||
%jump(mul_fp6)
|
||||
%jump(mul_fp254_6)
|
||||
square_fp12_1:
|
||||
// stack: f'f, out', f', square_fp12_2, inp, f, square_fp12_3, out
|
||||
DUP7
|
||||
@ -357,7 +357,7 @@ square_fp12_1:
|
||||
// stack: out', f', square_fp12_2, inp, f, square_fp12_3, out
|
||||
POP
|
||||
// stack: f', square_fp12_2, inp, f, square_fp12_3, out
|
||||
%jump(square_fp6)
|
||||
%jump(square_fp254_6)
|
||||
square_fp12_2:
|
||||
// stack: f'f', inp, f, square_fp12_3, out
|
||||
%sh_fp254_6
|
||||
@ -368,7 +368,7 @@ square_fp12_2:
|
||||
SWAP13
|
||||
SWAP6
|
||||
// stack: f, square_fp12_3, sh(f'f'), inp, out
|
||||
%jump(square_fp6)
|
||||
%jump(square_fp254_6)
|
||||
square_fp12_3:
|
||||
// stack: ff , sh(f'f'), inp, out
|
||||
%add_fp6
|
||||
@ -59,7 +59,7 @@
|
||||
/// e2_ = c0d2_ + c0_d2 + c1d1_ + c1_d1 + c2d0_ + c2_d0
|
||||
|
||||
// cost: 157
|
||||
global mul_fp6:
|
||||
global mul_fp254_6:
|
||||
// e2
|
||||
// make c0_d2_ + c1_d1_ + c2_d0_
|
||||
DUP8
|
||||
@ -299,7 +299,7 @@ global mul_fp6:
|
||||
/// e2_ = 2(c0_c2 + c2c0_) + 2c1c1_
|
||||
|
||||
// cost: 101
|
||||
global square_fp6:
|
||||
global square_fp254_6:
|
||||
/// e0 = (c0^2 - c0_^2) + x0
|
||||
/// e0_ = 2c0c0_ + x0_
|
||||
/// where x0_, x0 = %i9 2(c1c2 - c1_c2_), 2(c1_c2 + c1c2_)
|
||||
@ -1,42 +1,42 @@
|
||||
global test_frob_fp12_1:
|
||||
global test_frob_fp254_12_1:
|
||||
// stack: ptr
|
||||
%frob_fp12_1
|
||||
%frob_fp254_12_1
|
||||
// stack: ptr
|
||||
%jump(0xdeadbeef)
|
||||
|
||||
global test_frob_fp12_2:
|
||||
global test_frob_fp254_12_2:
|
||||
// stack: ptr
|
||||
DUP1
|
||||
// stack: ptr, ptr
|
||||
%frob_fp12_2_
|
||||
%frob_fp254_12_2_
|
||||
// stack: ptr
|
||||
%jump(0xdeadbeef)
|
||||
|
||||
global test_frob_fp12_3:
|
||||
global test_frob_fp254_12_3:
|
||||
// stack: ptr
|
||||
%frob_fp12_3
|
||||
%frob_fp254_12_3
|
||||
// stack: ptr
|
||||
%jump(0xdeadbeef)
|
||||
|
||||
global test_frob_fp12_6:
|
||||
global test_frob_fp254_12_6:
|
||||
// stack: ptr
|
||||
%frob_fp12_6
|
||||
%frob_fp254_12_6
|
||||
// stack: ptr
|
||||
%jump(0xdeadbeef)
|
||||
|
||||
|
||||
/// def frob_fp12_n(f, f'):
|
||||
/// g = frob_fp6(n, f )
|
||||
/// g' = FROB_z[n] * frob_fp6(n, f')
|
||||
/// def frob_fp254_12_n(f, f'):
|
||||
/// g = frob_fp254_6(n, f )
|
||||
/// g' = FROB_z[n] * frob_fp254_6(n, f')
|
||||
/// return g, g'
|
||||
|
||||
%macro frob_fp12_1
|
||||
%macro frob_fp254_12_1
|
||||
// stack: ptr
|
||||
DUP1
|
||||
// stack: ptr, ptr
|
||||
%load_fp6
|
||||
// stack: f, ptr
|
||||
%frob_fp6_1
|
||||
%frob_fp254_6_1
|
||||
// stack: g, ptr
|
||||
DUP7
|
||||
// stack: ptr, g, ptr
|
||||
@ -55,13 +55,13 @@ global test_frob_fp12_6:
|
||||
%endmacro
|
||||
|
||||
// Note: this is the only one with distinct input and output pointers
|
||||
%macro frob_fp12_2_
|
||||
%macro frob_fp254_12_2_
|
||||
// stack: ptr , out
|
||||
DUP1
|
||||
// stack: ptr, ptr , out
|
||||
%load_fp6
|
||||
// stack: f, ptr , out
|
||||
%frob_fp6_2
|
||||
%frob_fp254_6_2
|
||||
// stack: g, ptr , out
|
||||
DUP8
|
||||
// stack: out, g, ptr , out
|
||||
@ -79,13 +79,13 @@ global test_frob_fp12_6:
|
||||
// stack: out
|
||||
%endmacro
|
||||
|
||||
%macro frob_fp12_3
|
||||
%macro frob_fp254_12_3
|
||||
// stack: ptr
|
||||
DUP1
|
||||
// stack: ptr, ptr
|
||||
%load_fp6
|
||||
// stack: f, ptr
|
||||
%frob_fp6_3
|
||||
%frob_fp254_6_3
|
||||
// stack: g, ptr
|
||||
DUP7
|
||||
// stack: ptr, g, ptr
|
||||
@ -103,7 +103,7 @@ global test_frob_fp12_6:
|
||||
// stack: ptr
|
||||
%endmacro
|
||||
|
||||
%macro frob_fp12_6
|
||||
%macro frob_fp254_12_6
|
||||
// stack: ptr
|
||||
DUP1 %offset_fp6
|
||||
// stack: ptr', ptr
|
||||
@ -120,14 +120,14 @@ global test_frob_fp12_6:
|
||||
|
||||
/// let Z` denote the complex conjugate of Z
|
||||
|
||||
/// def frob_fp6_n(C0, C1, C2):
|
||||
/// def frob_fp254_6_n(C0, C1, C2):
|
||||
/// if n%2:
|
||||
/// D0, D1, D2 = C0`, FROB_T1[n] * C1`, FROB_T2[n] * C2`
|
||||
/// else:
|
||||
/// D0, D1, D2 = C0 , FROB_T1[n] * C1 , FROB_T2[n] * C2
|
||||
/// return D0, D1, D2
|
||||
|
||||
%macro frob_fp6_1
|
||||
%macro frob_fp254_6_1
|
||||
// stack: C0 , C1 , C2
|
||||
%conj_fp254_2
|
||||
// stack: D0 , C1 , C2
|
||||
@ -149,7 +149,7 @@ global test_frob_fp12_6:
|
||||
// stack: D0 , D1 , D2
|
||||
%endmacro
|
||||
|
||||
%macro frob_fp6_2
|
||||
%macro frob_fp254_6_2
|
||||
// stack: C0, C1, C2
|
||||
%swap_fp2_hole_2
|
||||
// stack: C2, C1, C0
|
||||
@ -165,7 +165,7 @@ global test_frob_fp12_6:
|
||||
// stack: D0, D1, D2
|
||||
%endmacro
|
||||
|
||||
%macro frob_fp6_3
|
||||
%macro frob_fp254_6_3
|
||||
// stack: C0 , C1 , C2
|
||||
%conj_fp254_2
|
||||
// stack: D0 , C1 , C2
|
||||
@ -189,20 +189,20 @@ global test_frob_fp12_6:
|
||||
|
||||
|
||||
%macro frobz_1
|
||||
%frob_fp6_1
|
||||
%frob_fp254_6_1
|
||||
PUSH 0x246996f3b4fae7e6a6327cfe12150b8e747992778eeec7e5ca5cf05f80f362ac
|
||||
PUSH 0x1284b71c2865a7dfe8b99fdd76e68b605c521e08292f2176d60b35dadcc9e470
|
||||
%mul_fp2_fp6
|
||||
%endmacro
|
||||
|
||||
%macro frobz_2
|
||||
%frob_fp6_2
|
||||
%frob_fp254_6_2
|
||||
PUSH 0x30644e72e131a0295e6dd9e7e0acccb0c28f069fbb966e3de4bd44e5607cfd49
|
||||
%mul_fp_fp6
|
||||
%endmacro
|
||||
|
||||
%macro frobz_3
|
||||
%frob_fp6_3
|
||||
%frob_fp254_6_3
|
||||
PUSH 0xabf8b60be77d7306cbeee33576139d7f03a5e397d439ec7694aa2bf4c0c101
|
||||
PUSH 0x19dc81cfcc82e4bbefe9608cd0acaa90894cb38dbe55d24ae86f7d391ed4a67f
|
||||
%mul_fp2_fp6
|
||||
|
||||
@ -32,7 +32,7 @@ global inv_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
|
||||
%jump(mul_fp12)
|
||||
%jump(mul_fp254_12)
|
||||
check_inv_fp254_12:
|
||||
// stack: retdest
|
||||
PUSH 50
|
||||
|
||||
@ -84,9 +84,9 @@ fn test_mul_fp254_12() -> Result<()> {
|
||||
let g: Fp12 = rng.gen::<Fp12>();
|
||||
let h: Fp12 = gen_fp12_sparse(&mut rng);
|
||||
|
||||
let setup_normal: InterpreterSetup = setup_mul_test(in0, in1, out, f, g, "mul_fp12");
|
||||
let setup_sparse: InterpreterSetup = setup_mul_test(in0, in1, out, f, h, "mul_fp12_sparse");
|
||||
let setup_square: InterpreterSetup = setup_mul_test(in0, in1, out, f, f, "square_fp12_test");
|
||||
let setup_normal: InterpreterSetup = setup_mul_test(in0, in1, out, f, g, "mul_fp254_12");
|
||||
let setup_sparse: InterpreterSetup = setup_mul_test(in0, in1, out, f, h, "mul_fp254_12_sparse");
|
||||
let setup_square: InterpreterSetup = setup_mul_test(in0, in1, out, f, f, "square_fp254_12_test");
|
||||
|
||||
let intrptr_normal: Interpreter = run_setup_interpreter(setup_normal).unwrap();
|
||||
let intrptr_sparse: Interpreter = run_setup_interpreter(setup_sparse).unwrap();
|
||||
@ -122,10 +122,10 @@ fn test_frob_fp254_12() -> Result<()> {
|
||||
let mut rng = rand::thread_rng();
|
||||
let f: Fp12 = rng.gen::<Fp12>();
|
||||
|
||||
let setup_frob_1 = setup_frob_test(ptr, f, "test_frob_fp12_1");
|
||||
let setup_frob_2 = setup_frob_test(ptr, f, "test_frob_fp12_2");
|
||||
let setup_frob_3 = setup_frob_test(ptr, f, "test_frob_fp12_3");
|
||||
let setup_frob_6 = setup_frob_test(ptr, f, "test_frob_fp12_6");
|
||||
let setup_frob_1 = setup_frob_test(ptr, f, "test_frob_fp254_12_1");
|
||||
let setup_frob_2 = setup_frob_test(ptr, f, "test_frob_fp254_12_2");
|
||||
let setup_frob_3 = setup_frob_test(ptr, f, "test_frob_fp254_12_3");
|
||||
let setup_frob_6 = setup_frob_test(ptr, f, "test_frob_fp254_12_6");
|
||||
|
||||
let intrptr_frob_1: Interpreter = run_setup_interpreter(setup_frob_1).unwrap();
|
||||
let intrptr_frob_2: Interpreter = run_setup_interpreter(setup_frob_2).unwrap();
|
||||
@ -276,7 +276,7 @@ fn test_tate() -> Result<()> {
|
||||
];
|
||||
|
||||
let setup = InterpreterSetup {
|
||||
label: "tate".to_string(),
|
||||
label: "bn254_tate".to_string(),
|
||||
stack: vec![U256::from(ptr), U256::from(out), U256::from(0xdeadbeefu32)],
|
||||
memory: vec![(ptr, inputs)],
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user