Use current context for pairing memory (#1091)

This commit is contained in:
wborgeaud 2023-06-12 22:55:38 +02:00 committed by GitHub
parent 9838a367ae
commit ba705703a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 133 additions and 132 deletions

View File

@ -73,37 +73,37 @@ loading_loop_contd6:
// stack: i, y_im, y_re, x_re, x_im, y, x, i, k, kexit_info
%mul_const(6) %add_const(@SNARKV_INP)
%add_const(5)
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: y_re, x_re, x_im, y, x, i, k, kexit_info
DUP6
// stack: i, y_re, x_re, x_im, y, x, i, k, kexit_info
%mul_const(6) %add_const(@SNARKV_INP)
%add_const(4)
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
SWAP1 // the EVM serializes the imaginary part first
// stack: x_im, x_re, y, x, i, k, kexit_info
DUP5
// stack: i, x_im, x_re, y, x, i, k, kexit_info
%mul_const(6) %add_const(@SNARKV_INP)
%add_const(3)
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: x_re, y, x, i, k, kexit_info
DUP4
// stack: i, x_re, y, x, i, k, kexit_info
%mul_const(6) %add_const(@SNARKV_INP)
%add_const(2)
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: y, x, i, k, kexit_info
DUP3
// stack: i, y, x, i, k, kexit_info
%mul_const(6) %add_const(@SNARKV_INP)
%add_const(1)
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: x, i, k, kexit_info
DUP2
// stack: i, x, i, k, kexit_info
%mul_const(6) %add_const(@SNARKV_INP)
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: i, k, kexit_info
%increment
%jump(loading_loop)

View File

@ -59,9 +59,9 @@ final_exp:
// stack: 0, val, retdest {0: sqr}
%stack () -> (1, 1, 1)
// stack: 1, 1, 1, 0, val, retdest
%mstore_kernel_bn254_pairing(12)
%mstore_kernel_bn254_pairing(24)
%mstore_kernel_bn254_pairing(36)
%mstore_bn254_pairing(12)
%mstore_bn254_pairing(24)
%mstore_bn254_pairing(36)
// stack: 0, val, retdest {0: sqr, 12: y0, 24: y2, 36: y4}
%stack () -> (64, 62, 65)
// stack: 64, 62, 65, 0, val, retdest {0: sqr, 12: y0, 24: y2, 36: y4}

View File

@ -194,7 +194,7 @@ after_add:
// stack: py^2 , 9, px, py, qx, qx_, qy, qy_
SUBFP254
// stack: py^2 - 9, px, py, qx, qx_, qy, qy_
%mstore_kernel_bn254_pairing(12)
%mstore_bn254_pairing(12)
// stack: px, py, qx, qx_, qy, qy_
DUP1
MULFP254
@ -210,7 +210,7 @@ after_add:
DUP3
MULFP254
// stack: (-3*px^2)qx, py, -3px^2, qx_, qy, qy_
%mstore_kernel_bn254_pairing(14)
%mstore_bn254_pairing(14)
// stack: py, -3px^2, qx_, qy, qy_
PUSH 2
MULFP254
@ -220,15 +220,15 @@ after_add:
DUP4
MULFP254
// stack: (2py)qy, -3px^2, qx_, 2py, qy_
%mstore_kernel_bn254_pairing(20)
%mstore_bn254_pairing(20)
// stack: -3px^2, qx_, 2py, qy_
MULFP254
// stack: (-3px^2)*qx_, 2py, qy_
%mstore_kernel_bn254_pairing(15)
%mstore_bn254_pairing(15)
// stack: 2py, qy_
MULFP254
// stack: (2py)*qy_
%mstore_kernel_bn254_pairing(21)
%mstore_bn254_pairing(21)
%endmacro
/// def cord(p1x, p1y, p2x, p2y, qx, qy):
@ -250,7 +250,7 @@ after_add:
// stack: p1y*p2x , p2y*p1x, p1x , p1y, p2x , p2y, qx, qx_, qy, qy_
SUBFP254
// stack: p1y*p2x - p2y*p1x, p1x , p1y, p2x , p2y, qx, qx_, qy, qy_
%mstore_kernel_bn254_pairing(12)
%mstore_bn254_pairing(12)
// stack: p1x , p1y, p2x , p2y, qx, qx_, qy, qy_
SWAP3
// stack: p2y , p1y, p2x , p1x, qx, qx_, qy, qy_
@ -265,29 +265,29 @@ after_add:
DUP5
MULFP254
// stack: (p1x - p2x)qy, p2y - p1y, qx, qx_, p1x - p2x, qy_
%mstore_kernel_bn254_pairing(20)
%mstore_bn254_pairing(20)
// stack: p2y - p1y, qx, qx_, p1x - p2x, qy_
SWAP1
// stack: qx, p2y - p1y, qx_, p1x - p2x, qy_
DUP2
MULFP254
// stack: (p2y - p1y)qx, p2y - p1y, qx_, p1x - p2x, qy_
%mstore_kernel_bn254_pairing(14)
%mstore_bn254_pairing(14)
// stack: p2y - p1y, qx_, p1x - p2x, qy_
MULFP254
// stack: (p2y - p1y)qx_, p1x - p2x, qy_
%mstore_kernel_bn254_pairing(15)
%mstore_bn254_pairing(15)
// stack: p1x - p2x, qy_
MULFP254
// stack: (p1x - p2x)*qy_
%mstore_kernel_bn254_pairing(21)
%mstore_bn254_pairing(21)
%endmacro
%macro clear_line
%stack () -> (0, 0, 0, 0, 0)
%mstore_kernel_bn254_pairing(12)
%mstore_kernel_bn254_pairing(14)
%mstore_kernel_bn254_pairing(15)
%mstore_kernel_bn254_pairing(20)
%mstore_kernel_bn254_pairing(21)
%mstore_bn254_pairing(12)
%mstore_bn254_pairing(14)
%mstore_bn254_pairing(15)
%mstore_bn254_pairing(20)
%mstore_bn254_pairing(21)
%endmacro

View File

@ -85,7 +85,7 @@ bn254_pairing_start:
// stack: 0, k, inp, out, retdest
%stack (j, k, inp, out) -> (out, 1, k, inp, out, bn254_pairing_output_validation, out)
// stack: out, 1, k, inp, out, bn254_pairing_output_validation, out, retdest
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: k, inp, out, bn254_pairing_output_validation, out, retdest
bn254_pairing_loop:
@ -147,7 +147,7 @@ bn254_pairing_output_validation:
// stack: check, out
DUP2
// stack: out0, check, out
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: f0, check, out
%eq_const(1)
// stack: check0, check, out
@ -160,7 +160,7 @@ bn254_pairing_output_validation:
DUP2
%add_const($j)
// stack: outj, check, out
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: fj, check, out
ISZERO
// stack: checkj, check, out

View File

@ -160,7 +160,7 @@ global mul_fp254_12_sparse:
// 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_bn254_pairing
%mload_bn254_pairing
// stack: g0 , f, f', inB, f, inB, f', out, f, inB, f', inA, inB, out
%scale_re_fp254_6
// stack: g0 * f, f', inB, f, inB, f', out, f, inB, f', inA, inB, out
@ -189,7 +189,7 @@ global mul_fp254_12_sparse:
// stack: out, G1 * sh(f) + G2 * sh2(f') + g0 * f, inB, f', out, f, inB, f', inA, inB, out
%store_fp254_6
// stack: inB, f', out, f, inB, f', inA, inB, out
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: g0 , f', out, f, inB, f', inA, inB, out
%scale_re_fp254_6
// stack: g0 * f', out, f, inB, f', inA, inB, out

View File

@ -44,7 +44,7 @@ check_inv_fp254_12:
// stack: retdest
PUSH 0
// stack: 0, retdest
%mstore_kernel_bn254_pairing(60)
%mstore_bn254_pairing(60)
JUMP
%macro prover_inv_fp254_12

View File

@ -1,30 +1,30 @@
// Load a single value from bn254 pairings memory.
%macro mload_kernel_bn254_pairing
%macro mload_bn254_pairing
// stack: offset
%mload_kernel(@SEGMENT_KERNEL_BN_PAIRING)
%mload_current(@SEGMENT_KERNEL_BN_PAIRING)
// stack: value
%endmacro
%macro mload_kernel_bn254_pairing(offset)
%macro mload_bn254_pairing(offset)
// stack:
PUSH $offset
// stack: offset
%mload_kernel(@SEGMENT_KERNEL_BN_PAIRING)
%mload_current(@SEGMENT_KERNEL_BN_PAIRING)
// stack: value
%endmacro
// Store a single value to bn254 pairings memory.
%macro mstore_kernel_bn254_pairing
%macro mstore_bn254_pairing
// stack: offset, value
%mstore_kernel(@SEGMENT_KERNEL_BN_PAIRING)
%mstore_current(@SEGMENT_KERNEL_BN_PAIRING)
// stack:
%endmacro
%macro mstore_kernel_bn254_pairing(offset)
%macro mstore_bn254_pairing(offset)
// stack: value
PUSH $offset
// stack: offset, value
%mstore_kernel(@SEGMENT_KERNEL_BN_PAIRING)
%mstore_current(@SEGMENT_KERNEL_BN_PAIRING)
// stack:
%endmacro
@ -35,11 +35,11 @@
DUP1
%add_const(1)
// stack: ind1, ptr
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x1, ptr
SWAP1
// stack: ind0, x1
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x0, x1
%endmacro
@ -148,21 +148,21 @@
DUP1
%add_const(2)
// stack: ind2, ptr
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x2, ptr
DUP2
%add_const(1)
// stack: ind1, x2, ptr
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x1, x2, ptr
DUP3
%add_const(3)
// stack: ind3, x1, x2, ptr
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x3, x1, x2, ptr
SWAP3
// stack: ind0, x1, x2, x3
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x0, x1, x2, x3
%endmacro
@ -173,31 +173,31 @@
DUP1
%add_const(4)
// stack: ind4, ptr
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x4, ptr
DUP2
%add_const(3)
// stack: ind3, x4, ptr
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x3, x4, ptr
DUP3
%add_const(2)
// stack: ind2, x3, x4, ptr
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x2, x3, x4, ptr
DUP4
%add_const(1)
// stack: ind1, x2, x3, x4, ptr
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x1, x2, x3, x4, ptr
DUP5
%add_const(5)
// stack: ind5, x1, x2, x3, x4, ptr
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x5, x1, x2, x3, x4, ptr
SWAP5
// stack: ind0, x1, x2, x3, x4, x5
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x0, x1, x2, x3, x4, x5
%endmacro
@ -207,31 +207,31 @@
PUSH $ptr
%add_const(5)
// stack: ind5
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x5
PUSH $ptr
%add_const(4)
// stack: ind4, x5
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x4, x5
PUSH $ptr
%add_const(3)
// stack: ind3, x4, x5
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x3, x4, x5
PUSH $ptr
%add_const(2)
// stack: ind2, x3, x4, x5
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x2, x3, x4, x5
PUSH $ptr
%add_const(1)
// stack: ind1, x2, x3, x4, x5
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x1, x2, x3, x4, x5
PUSH $ptr
// stack: ind0, x1, x2, x3, x4, x5
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x0, x1, x2, x3, x4, x5
%endmacro
@ -243,30 +243,30 @@
DUP6
%add_const(4)
// stack: ind4, x4, x0, x1, x2, x3, ptr, x5
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: x0, x1, x2, x3, ptr, x5
DUP5
// stack: ind0, x0, x1, x2, x3, ptr, x5
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: x1, x2, x3, ptr, x5
DUP4
%add_const(1)
// stack: ind1, x1, x2, x3, ptr, x5
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: x2, x3, ptr, x5
DUP3
%add_const(2)
// stack: ind2, x2, x3, ptr, x5
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: x3, ptr, x5
DUP2
%add_const(3)
// stack: ind3, x3, ptr, x5
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: ptr, x5
%add_const(5)
// stack: ind5, x5
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack:
%endmacro
@ -281,14 +281,14 @@
DUP7
%add_const(5)
// stack: ind5, 2*x5, x0, x1, x2, x3, x4, ptr
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: x0, x1, x2, x3, x4, ptr
PUSH 2
MULFP254
// stack: 2*x0, x1, x2, x3, x4, ptr
DUP6
// stack: ind0, 2*x0, x1, x2, x3, x4, ptr
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: x1, x2, x3, x4, ptr
PUSH 2
MULFP254
@ -296,7 +296,7 @@
DUP5
%add_const(1)
// stack: ind1, 2*x1, x2, x3, x4, ptr
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: x2, x3, x4, ptr
PUSH 2
MULFP254
@ -304,7 +304,7 @@
DUP4
%add_const(2)
// stack: ind2, 2*x2, x3, x4, ptr
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: x3, x4, ptr
PUSH 2
MULFP254
@ -312,7 +312,7 @@
DUP3
%add_const(3)
// stack: ind3, 2*x3, x4, ptr
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: x4, ptr
PUSH 2
MULFP254
@ -321,7 +321,7 @@
// stack: ptr, 2*x4
%add_const(4)
// stack: ind4, 2*x4
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack:
%endmacro
@ -330,32 +330,32 @@
// stack: x0, x1, x2, x3, x4, x5
PUSH $ptr
// stack: ind0, x0, x1, x2, x3, x4, x5
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: x1, x2, x3, x4, x5
PUSH $ptr
%add_const(1)
// stack: ind1, x1, x2, x3, x4, x5
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: x2, x3, x4, x5
PUSH $ptr
%add_const(2)
// stack: ind2, x2, x3, x4, x5
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: x3, x4, x5
PUSH $ptr
%add_const(3)
// stack: ind3, x3, x4, x5
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: x4, x5
PUSH $ptr
%add_const(4)
// stack: ind4, x4, x5
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: x5
PUSH $ptr
%add_const(5)
// stack: ind5, x5
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack:
%endmacro
@ -365,33 +365,33 @@
PUSH $ptr
%add_const(2)
// stack: ind2, x0, x1, x2, x3, x4, x5
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: x1, x2, x3, x4, x5
PUSH $ptr
%add_const(3)
// stack: ind3, x1, x2, x3, x4, x5
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: x2, x3, x4, x5
PUSH $ptr
%add_const(4)
// stack: ind4, x2, x3, x4, x5
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: x3, x4, x5
PUSH $ptr
%add_const(5)
// stack: ind5, x3, x4, x5
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: x4, x5
%i9
// stack: y5, y4
PUSH $ptr
%add_const(1)
// stack: ind1, y5, y4
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: y4
PUSH $ptr
// stack: ind0, y4
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack:
%endmacro
@ -867,61 +867,61 @@
DUP1
%add_const(10)
// stack: ind10, ptr
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x10, ptr
DUP2
%add_const(9)
// stack: ind09, x10, ptr
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x09, x10, ptr
DUP3
%add_const(8)
// stack: ind08, x09, x10, ptr
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x08, x09, x10, ptr
DUP4
%add_const(7)
// stack: ind07, x08, x09, x10, ptr
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x07, x08, x09, x10, ptr
DUP5
%add_const(6)
// stack: ind06, x07, x08, x09, x10, ptr
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x06, x07, x08, x09, x10, ptr
DUP6
%add_const(5)
// stack: ind05, x06, x07, x08, x09, x10, ptr
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x05, x06, x07, x08, x09, x10, ptr
DUP7
%add_const(4)
// stack: ind04, x05, x06, x07, x08, x09, x10, ptr
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// 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_bn254_pairing
%mload_bn254_pairing
// 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_bn254_pairing
%mload_bn254_pairing
// 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_bn254_pairing
%mload_bn254_pairing
// 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_bn254_pairing
%mload_bn254_pairing
// 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_bn254_pairing
%mload_bn254_pairing
// stack: x00, x01, x02, x03, x04, x05, x06, x07, x08, x09, x10, x11
%endmacro
@ -932,60 +932,60 @@
DUP12
%add_const(10)
// stack: ind10, x10, x00, x01, x02, x03, x04, x05, x06, x07, x08, x09, ptr, x11
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: x00, x01, x02, x03, x04, x05, x06, x07, x08, x09, ptr, x11
DUP11
// stack: ind00, x00, x01, x02, x03, x04, x05, x06, x07, x08, x09, ptr, x11
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: x01, x02, x03, x04, x05, x06, x07, x08, x09, ptr, x11
DUP10
%add_const(01)
// stack: ind01, x01, x02, x03, x04, x05, x06, x07, x08, x09, ptr, x11
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: x02, x03, x04, x05, x06, x07, x08, x09, ptr, x11
DUP9
%add_const(02)
// stack: ind02, x02, x03, x04, x05, x06, x07, x08, x09, ptr, x11
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: x03, x04, x05, x06, x07, x08, x09, ptr, x11
DUP8
%add_const(03)
// stack: ind03, x03, x04, x05, x06, x07, x08, x09, ptr, x11
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: x04, x05, x06, x07, x08, x09, ptr, x11
DUP7
%add_const(04)
// stack: ind04, x04, x05, x06, x07, x08, x09, ptr, x11
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: x05, x06, x07, x08, x09, ptr, x11
DUP6
%add_const(05)
// stack: ind05, x05, x06, x07, x08, x09, ptr, x11
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: x06, x07, x08, x09, ptr, x11
DUP5
%add_const(06)
// stack: ind06, x06, x07, x08, x09, ptr, x11
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: x07, x08, x09, ptr, x11
DUP4
%add_const(07)
// stack: ind07, x07, x08, x09, ptr, x11
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: x08, x09, ptr, x11
DUP3
%add_const(08)
// stack: ind08, x08, x09, ptr, x11
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: x09, ptr, x11
DUP2
%add_const(09)
// stack: ind09, x09, ptr, x11
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: ptr, x11
%add_const(11)
// stack: ind11, x11
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack:
%endmacro
@ -995,120 +995,120 @@
// stack: src, dest
DUP1
// stack: ind00, src, dest
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x00, src, dest
DUP3
// stack: ind00', x00, src, dest
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: src, dest
DUP1
%add_const(1)
// stack: ind01, src, dest
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x01, src, dest
DUP3
%add_const(1)
// stack: ind01', x01, src, dest
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: src, dest
DUP1
%add_const(2)
// stack: ind02, src, dest
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x02, src, dest
DUP3
%add_const(2)
// stack: ind02', x02, src, dest
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: src, dest
DUP1
%add_const(3)
// stack: ind03, src, dest
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x03, src, dest
DUP3
%add_const(3)
// stack: ind03', x03, src, dest
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: src, dest
DUP1
%add_const(4)
// stack: ind04, src, dest
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x04, src, dest
DUP3
%add_const(4)
// stack: ind04', x04, src, dest
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: src, dest
DUP1
%add_const(5)
// stack: ind05, src, dest
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x05, src, dest
DUP3
%add_const(5)
// stack: ind05', x05, src, dest
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: src, dest
DUP1
%add_const(6)
// stack: ind06, src, dest
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x06, src, dest
DUP3
%add_const(6)
// stack: ind06', x06, src, dest
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: src, dest
DUP1
%add_const(7)
// stack: ind07, src, dest
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x07, src, dest
DUP3
%add_const(7)
// stack: ind07', x07, src, dest
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: src, dest
DUP1
%add_const(8)
// stack: ind08, src, dest
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x08, src, dest
DUP3
%add_const(8)
// stack: ind08', x08, src, dest
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: src, dest
DUP1
%add_const(9)
// stack: ind09, src, dest
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x09, src, dest
DUP3
%add_const(9)
// stack: ind09', x09, src, dest
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: src, dest
DUP1
%add_const(10)
// stack: ind10, src, dest
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x10, src, dest
DUP3
%add_const(10)
// stack: ind10', x10, src, dest
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
// stack: src, dest
%add_const(11)
// stack: ind11, dest
%mload_kernel_bn254_pairing
%mload_bn254_pairing
// stack: x11, dest
DUP2
%add_const(11)
// stack: ind11', x11, dest
%mstore_kernel_bn254_pairing
%mstore_bn254_pairing
%endmacro
%macro assert_eq_unit_fp254_12

View File

@ -16,7 +16,7 @@ use crate::generation::state::GenerationState;
use crate::memory::segments::Segment;
use crate::memory::segments::Segment::BnPairing;
use crate::util::{biguint_to_mem_vec, mem_vec_to_biguint};
use crate::witness::util::{kernel_peek, stack_peek};
use crate::witness::util::{current_context_peek, stack_peek};
/// Prover input function represented as a scoped function name.
/// Example: `PROVER_INPUT(ff::bn254_base::inverse)` is represented as `ProverInputFn([ff, bn254_base, inverse])`.
@ -97,7 +97,7 @@ impl<F: Field> GenerationState<F> {
.as_usize();
let f: [U256; 12] = match field {
Bn254Base => std::array::from_fn(|i| kernel_peek(self, BnPairing, ptr + i)),
Bn254Base => std::array::from_fn(|i| current_context_peek(self, BnPairing, ptr + i)),
_ => todo!(),
};
field.field_extension_inverse(n, f)

View File

@ -40,12 +40,13 @@ pub(crate) fn stack_peek<F: Field>(state: &GenerationState<F>, i: usize) -> Opti
}
/// Peek at kernel at specified segment and address
pub(crate) fn kernel_peek<F: Field>(
pub(crate) fn current_context_peek<F: Field>(
state: &GenerationState<F>,
segment: Segment,
virt: usize,
) -> U256 {
state.memory.get(MemoryAddress::new(0, segment, virt))
let context = state.registers.context;
state.memory.get(MemoryAddress::new(context, segment, virt))
}
pub(crate) fn mem_read_with_log<F: Field>(