This commit is contained in:
Dmitry Vagner 2022-12-08 15:18:43 -08:00
parent 03c14d0392
commit bf9c32463f
3 changed files with 115 additions and 22 deletions

View File

@ -27,10 +27,12 @@ global tate:
%jump(miller_init)
global post_mllr:
// stack: out, tate_mul1, tate_mul2, tate_mul3, retdest
DUP1
// stack: out, out, tate_mul1, tate_mul2, tate_mul3, retdest
PUSH 100
// stack: 100, out, tate_mul1, tate_mul2, tate_mul3, retdest
// stack: 100, out, out, tate_mul1, tate_mul2, tate_mul3, retdest
DUP2
// stack: out, 100, out, tate_mul1, tate_mul2, tate_mul3, retdest
// stack: out, 100, out, out, tate_mul1, tate_mul2, tate_mul3, retdest
// %inverse_fp12
// stack: 100, out, tate_mul1, tate_mul2, tate_mul3, retdest {100: inv}
DUP2

View File

@ -865,3 +865,96 @@
SWAP1
// stack: g0, g0_, g1, g1_, g2, g2_
%endmacro
%macro load_fp12
// stack: ptr
DUP1 %add_const(10)
// stack: ind10, ptr
%mload_kernel_general
// stack: x10, ptr
DUP2 %add_const(9)
// stack: ind09, x10, ptr
%mload_kernel_general
// stack: x09, x10, ptr
DUP3 %add_const(8)
// stack: ind08, x09, x10, ptr
%mload_kernel_general
// stack: x08, x09, x10, ptr
DUP4 %add_const(7)
// stack: ind07, x08, x09, x10, ptr
%mload_kernel_general
// stack: x07, x08, x09, x10, ptr
DUP5 %add_const(6)
// stack: ind06, x07, x08, x09, x10, ptr
%mload_kernel_general
// stack: x06, x07, x08, x09, x10, ptr
DUP6 %add_const(5)
// stack: ind05, x06, x07, x08, x09, x10, ptr
%mload_kernel_general
// stack: x05, x06, x07, x08, x09, x10, ptr
DUP7 %add_const(4)
// stack: ind04, x05, x06, x07, x08, x09, x10, ptr
%mload_kernel_general
// stack: x04, x05, x06, x07, x08, x09, x10, ptr
DUP8 %add_const(3)
// stack: ind03, x04, x05, x06, x07, x08, x09, x10, ptr
%mload_kernel_general
// stack: x03, x04, x05, x06, x07, x08, x09, x10, ptr
DUP9 %add_const(2)
// stack: ind02, x03, x04, x05, x06, x07, x08, x09, x10, ptr
%mload_kernel_general
// stack: x02, x03, x04, x05, x06, x07, x08, x09, x10, ptr
DUP10 %add_const(1)
// stack: ind01, x02, x03, x04, x05, x06, x07, x08, x09, x10, ptr
%mload_kernel_general
// stack: x01, x02, x03, x04, x05, x06, x07, x08, x09, x10, ptr
DUP11 %add_const(11)
// stack: ind11, x01, x02, x03, x04, x05, x06, x07, x08, x09, x10, ptr
%mload_kernel_general
// stack: x11, x01, x02, x03, x04, x05, x06, x07, x08, x09, x10, ptr
SWAP11
// stack: ind00, x01, x02, x03, x04, x05, x06, x07, x08, x09, x10, x11
%mload_kernel_general
// stack: x00, x01, x02, x03, x04, x05, x06, x07, x08, x09, x10, x11
%endmacro
%macro assert_eq_unit_fp12
// stack: ptr
DUP1 %mload_kernel_code
// stack: x00, ptr
%assert_eq_const(1)
// stack: ptr
DUP1 %add_const(01) %mload_kernel_code
// stack: x01, ptr
%assert_eq_const(0)
DUP1 %add_const(02) %mload_kernel_code
// stack: x02, ptr
%assert_eq_const(0)
DUP1 %add_const(03) %mload_kernel_code
// stack: x03, ptr
%assert_eq_const(0)
DUP1 %add_const(04) %mload_kernel_code
// stack: x04, ptr
%assert_eq_const(0)
DUP1 %add_const(05) %mload_kernel_code
// stack: x05, ptr
%assert_eq_const(0)
DUP1 %add_const(06) %mload_kernel_code
// stack: x06, ptr
%assert_eq_const(0)
DUP1 %add_const(07) %mload_kernel_code
// stack: x07, ptr
%assert_eq_const(0)
DUP1 %add_const(08) %mload_kernel_code
// stack: x08, ptr
%assert_eq_const(0)
DUP1 %add_const(09) %mload_kernel_code
// stack: x09, ptr
%assert_eq_const(0)
DUP1 %add_const(10) %mload_kernel_code
// stack: x10, ptr
%assert_eq_const(0)
DUP1 %add_const(11) %mload_kernel_code
// stack: x11, ptr
%assert_eq_const(0)
%endmacro

View File

@ -22,11 +22,11 @@
%endmacro
global inverse_fp12:
// stack: ptr, inv, retdest
// DUP1 %load_fp12
// stack: f, ptr, inv, retdest
// stack: ptr, inv, retdest
DUP1 %load_fp12
// stack: f, ptr, inv, retdest
DUP14
// stack: inv, f, ptr, inv, retdest
// stack: inv, f, ptr, inv, retdest
PROVER_INPUT(ff::bn254_base::inverse_fp12)
PROVER_INPUT(ff::bn254_base::inverse_fp12)
PROVER_INPUT(ff::bn254_base::inverse_fp12)
@ -39,24 +39,22 @@ global inverse_fp12:
PROVER_INPUT(ff::bn254_base::inverse_fp12)
PROVER_INPUT(ff::bn254_base::inverse_fp12)
PROVER_INPUT(ff::bn254_base::inverse_fp12)
// stack: f^-1, inv, f, ptr, inv, retdest
// stack: f^-1, inv, f, ptr, inv, retdest
DUP13
// stack: inv, f^-1, inv, f, ptr, inv, retdest
// %store_fp12 POP
// stack: f, ptr, inv, retdest
%pop4 %pop4 %pop4
// stack: ptr, inv, retdest
PUSH check_inv PUSH 200
// stack: 200, check_inv, ptr, inv, retdest
DUP4 DUP4
// stack: ptr, inv, 200, check_inv, ptr, inv, retdest
// stack: inv, f^-1, inv, f, ptr, inv, retdest
%store_fp12
// stack: inv, f, ptr, inv, retdest
%stack (inv, f: 12) -> ()
// stack: ptr, inv, retdest
PUSH 200 PUSH check_inv
// stack: check_inv, 200, ptr, inv, retdest
DUP2 DUP5 DUP5
// stack: ptr, inv, 200, check_inv, 200, ptr, inv, retdest
%jump(mul_fp12)
global check_inv:
// stack: 200, ptr, inv, retdest
// %eq_unit_fp12
// stack: is_unit, ptr, inv, retdest
%assert_nonzero
// stack: ptr, inv, retdest
// stack: 200, ptr, inv, retdest
%assert_eq_unit_fp12
// stack: ptr, inv, retdest
POP SWAP1
// stack: retdest, inv
// stack: retdest, inv
JUMP