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

View File

@ -59,9 +59,9 @@ final_exp:
// stack: 0, val, retdest {0: sqr} // stack: 0, val, retdest {0: sqr}
%stack () -> (1, 1, 1) %stack () -> (1, 1, 1)
// stack: 1, 1, 1, 0, val, retdest // stack: 1, 1, 1, 0, val, retdest
%mstore_kernel_bn254_pairing(12) %mstore_bn254_pairing(12)
%mstore_kernel_bn254_pairing(24) %mstore_bn254_pairing(24)
%mstore_kernel_bn254_pairing(36) %mstore_bn254_pairing(36)
// stack: 0, val, retdest {0: sqr, 12: y0, 24: y2, 36: y4} // stack: 0, val, retdest {0: sqr, 12: y0, 24: y2, 36: y4}
%stack () -> (64, 62, 65) %stack () -> (64, 62, 65)
// stack: 64, 62, 65, 0, val, retdest {0: sqr, 12: y0, 24: y2, 36: y4} // 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_ // stack: py^2 , 9, px, py, qx, qx_, qy, qy_
SUBFP254 SUBFP254
// stack: py^2 - 9, px, py, qx, qx_, qy, qy_ // 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_ // stack: px, py, qx, qx_, qy, qy_
DUP1 DUP1
MULFP254 MULFP254
@ -210,7 +210,7 @@ after_add:
DUP3 DUP3
MULFP254 MULFP254
// stack: (-3*px^2)qx, py, -3px^2, qx_, qy, qy_ // 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_ // stack: py, -3px^2, qx_, qy, qy_
PUSH 2 PUSH 2
MULFP254 MULFP254
@ -220,15 +220,15 @@ after_add:
DUP4 DUP4
MULFP254 MULFP254
// stack: (2py)qy, -3px^2, qx_, 2py, qy_ // stack: (2py)qy, -3px^2, qx_, 2py, qy_
%mstore_kernel_bn254_pairing(20) %mstore_bn254_pairing(20)
// stack: -3px^2, qx_, 2py, qy_ // stack: -3px^2, qx_, 2py, qy_
MULFP254 MULFP254
// stack: (-3px^2)*qx_, 2py, qy_ // stack: (-3px^2)*qx_, 2py, qy_
%mstore_kernel_bn254_pairing(15) %mstore_bn254_pairing(15)
// stack: 2py, qy_ // stack: 2py, qy_
MULFP254 MULFP254
// stack: (2py)*qy_ // stack: (2py)*qy_
%mstore_kernel_bn254_pairing(21) %mstore_bn254_pairing(21)
%endmacro %endmacro
/// def cord(p1x, p1y, p2x, p2y, qx, qy): /// 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_ // stack: p1y*p2x , p2y*p1x, p1x , p1y, p2x , p2y, qx, qx_, qy, qy_
SUBFP254 SUBFP254
// stack: p1y*p2x - p2y*p1x, p1x , p1y, p2x , p2y, qx, qx_, qy, qy_ // 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_ // stack: p1x , p1y, p2x , p2y, qx, qx_, qy, qy_
SWAP3 SWAP3
// stack: p2y , p1y, p2x , p1x, qx, qx_, qy, qy_ // stack: p2y , p1y, p2x , p1x, qx, qx_, qy, qy_
@ -265,29 +265,29 @@ after_add:
DUP5 DUP5
MULFP254 MULFP254
// stack: (p1x - p2x)qy, p2y - p1y, qx, qx_, p1x - p2x, qy_ // 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_ // stack: p2y - p1y, qx, qx_, p1x - p2x, qy_
SWAP1 SWAP1
// stack: qx, p2y - p1y, qx_, p1x - p2x, qy_ // stack: qx, p2y - p1y, qx_, p1x - p2x, qy_
DUP2 DUP2
MULFP254 MULFP254
// stack: (p2y - p1y)qx, p2y - p1y, qx_, p1x - p2x, qy_ // 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_ // stack: p2y - p1y, qx_, p1x - p2x, qy_
MULFP254 MULFP254
// stack: (p2y - p1y)qx_, p1x - p2x, qy_ // stack: (p2y - p1y)qx_, p1x - p2x, qy_
%mstore_kernel_bn254_pairing(15) %mstore_bn254_pairing(15)
// stack: p1x - p2x, qy_ // stack: p1x - p2x, qy_
MULFP254 MULFP254
// stack: (p1x - p2x)*qy_ // stack: (p1x - p2x)*qy_
%mstore_kernel_bn254_pairing(21) %mstore_bn254_pairing(21)
%endmacro %endmacro
%macro clear_line %macro clear_line
%stack () -> (0, 0, 0, 0, 0) %stack () -> (0, 0, 0, 0, 0)
%mstore_kernel_bn254_pairing(12) %mstore_bn254_pairing(12)
%mstore_kernel_bn254_pairing(14) %mstore_bn254_pairing(14)
%mstore_kernel_bn254_pairing(15) %mstore_bn254_pairing(15)
%mstore_kernel_bn254_pairing(20) %mstore_bn254_pairing(20)
%mstore_kernel_bn254_pairing(21) %mstore_bn254_pairing(21)
%endmacro %endmacro

View File

@ -85,7 +85,7 @@ bn254_pairing_start:
// stack: 0, k, inp, out, retdest // stack: 0, k, inp, out, retdest
%stack (j, k, inp, out) -> (out, 1, k, inp, out, bn254_pairing_output_validation, out) %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 // 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 // stack: k, inp, out, bn254_pairing_output_validation, out, retdest
bn254_pairing_loop: bn254_pairing_loop:
@ -147,7 +147,7 @@ bn254_pairing_output_validation:
// stack: check, out // stack: check, out
DUP2 DUP2
// stack: out0, check, out // stack: out0, check, out
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: f0, check, out // stack: f0, check, out
%eq_const(1) %eq_const(1)
// stack: check0, check, out // stack: check0, check, out
@ -160,7 +160,7 @@ bn254_pairing_output_validation:
DUP2 DUP2
%add_const($j) %add_const($j)
// stack: outj, check, out // stack: outj, check, out
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: fj, check, out // stack: fj, check, out
ISZERO ISZERO
// stack: checkj, check, out // 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 // stack: f, f', inB, f, inB, f', out, f, inB, f', inA, inB, out
DUP13 DUP13
// stack: inB, f, f', inB, f, inB, f', out, f, inB, f', inA, inB, out // 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 // stack: g0 , f, f', inB, f, inB, f', out, f, inB, f', inA, inB, out
%scale_re_fp254_6 %scale_re_fp254_6
// stack: g0 * f, f', inB, f, inB, f', out, f, inB, f', inA, inB, out // 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 // stack: out, G1 * sh(f) + G2 * sh2(f') + g0 * f, inB, f', out, f, inB, f', inA, inB, out
%store_fp254_6 %store_fp254_6
// stack: inB, f', out, f, inB, f', inA, inB, out // 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 // stack: g0 , f', out, f, inB, f', inA, inB, out
%scale_re_fp254_6 %scale_re_fp254_6
// stack: g0 * f', out, f, inB, f', inA, inB, out // stack: g0 * f', out, f, inB, f', inA, inB, out

View File

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

View File

@ -1,30 +1,30 @@
// Load a single value from bn254 pairings memory. // Load a single value from bn254 pairings memory.
%macro mload_kernel_bn254_pairing %macro mload_bn254_pairing
// stack: offset // stack: offset
%mload_kernel(@SEGMENT_KERNEL_BN_PAIRING) %mload_current(@SEGMENT_KERNEL_BN_PAIRING)
// stack: value // stack: value
%endmacro %endmacro
%macro mload_kernel_bn254_pairing(offset) %macro mload_bn254_pairing(offset)
// stack: // stack:
PUSH $offset PUSH $offset
// stack: offset // stack: offset
%mload_kernel(@SEGMENT_KERNEL_BN_PAIRING) %mload_current(@SEGMENT_KERNEL_BN_PAIRING)
// stack: value // stack: value
%endmacro %endmacro
// Store a single value to bn254 pairings memory. // Store a single value to bn254 pairings memory.
%macro mstore_kernel_bn254_pairing %macro mstore_bn254_pairing
// stack: offset, value // stack: offset, value
%mstore_kernel(@SEGMENT_KERNEL_BN_PAIRING) %mstore_current(@SEGMENT_KERNEL_BN_PAIRING)
// stack: // stack:
%endmacro %endmacro
%macro mstore_kernel_bn254_pairing(offset) %macro mstore_bn254_pairing(offset)
// stack: value // stack: value
PUSH $offset PUSH $offset
// stack: offset, value // stack: offset, value
%mstore_kernel(@SEGMENT_KERNEL_BN_PAIRING) %mstore_current(@SEGMENT_KERNEL_BN_PAIRING)
// stack: // stack:
%endmacro %endmacro
@ -35,11 +35,11 @@
DUP1 DUP1
%add_const(1) %add_const(1)
// stack: ind1, ptr // stack: ind1, ptr
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x1, ptr // stack: x1, ptr
SWAP1 SWAP1
// stack: ind0, x1 // stack: ind0, x1
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x0, x1 // stack: x0, x1
%endmacro %endmacro
@ -148,21 +148,21 @@
DUP1 DUP1
%add_const(2) %add_const(2)
// stack: ind2, ptr // stack: ind2, ptr
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x2, ptr // stack: x2, ptr
DUP2 DUP2
%add_const(1) %add_const(1)
// stack: ind1, x2, ptr // stack: ind1, x2, ptr
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x1, x2, ptr // stack: x1, x2, ptr
DUP3 DUP3
%add_const(3) %add_const(3)
// stack: ind3, x1, x2, ptr // stack: ind3, x1, x2, ptr
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x3, x1, x2, ptr // stack: x3, x1, x2, ptr
SWAP3 SWAP3
// stack: ind0, x1, x2, x3 // stack: ind0, x1, x2, x3
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x0, x1, x2, x3 // stack: x0, x1, x2, x3
%endmacro %endmacro
@ -173,31 +173,31 @@
DUP1 DUP1
%add_const(4) %add_const(4)
// stack: ind4, ptr // stack: ind4, ptr
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x4, ptr // stack: x4, ptr
DUP2 DUP2
%add_const(3) %add_const(3)
// stack: ind3, x4, ptr // stack: ind3, x4, ptr
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x3, x4, ptr // stack: x3, x4, ptr
DUP3 DUP3
%add_const(2) %add_const(2)
// stack: ind2, x3, x4, ptr // stack: ind2, x3, x4, ptr
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x2, x3, x4, ptr // stack: x2, x3, x4, ptr
DUP4 DUP4
%add_const(1) %add_const(1)
// stack: ind1, x2, x3, x4, ptr // stack: ind1, x2, x3, x4, ptr
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x1, x2, x3, x4, ptr // stack: x1, x2, x3, x4, ptr
DUP5 DUP5
%add_const(5) %add_const(5)
// stack: ind5, x1, x2, x3, x4, ptr // stack: ind5, x1, x2, x3, x4, ptr
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x5, x1, x2, x3, x4, ptr // stack: x5, x1, x2, x3, x4, ptr
SWAP5 SWAP5
// stack: ind0, x1, x2, x3, x4, x5 // stack: ind0, x1, x2, x3, x4, x5
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x0, x1, x2, x3, x4, x5 // stack: x0, x1, x2, x3, x4, x5
%endmacro %endmacro
@ -207,31 +207,31 @@
PUSH $ptr PUSH $ptr
%add_const(5) %add_const(5)
// stack: ind5 // stack: ind5
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x5 // stack: x5
PUSH $ptr PUSH $ptr
%add_const(4) %add_const(4)
// stack: ind4, x5 // stack: ind4, x5
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x4, x5 // stack: x4, x5
PUSH $ptr PUSH $ptr
%add_const(3) %add_const(3)
// stack: ind3, x4, x5 // stack: ind3, x4, x5
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x3, x4, x5 // stack: x3, x4, x5
PUSH $ptr PUSH $ptr
%add_const(2) %add_const(2)
// stack: ind2, x3, x4, x5 // stack: ind2, x3, x4, x5
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x2, x3, x4, x5 // stack: x2, x3, x4, x5
PUSH $ptr PUSH $ptr
%add_const(1) %add_const(1)
// stack: ind1, x2, x3, x4, x5 // stack: ind1, x2, x3, x4, x5
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x1, x2, x3, x4, x5 // stack: x1, x2, x3, x4, x5
PUSH $ptr PUSH $ptr
// stack: ind0, x1, x2, x3, x4, x5 // stack: ind0, x1, x2, x3, x4, x5
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x0, x1, x2, x3, x4, x5 // stack: x0, x1, x2, x3, x4, x5
%endmacro %endmacro
@ -243,30 +243,30 @@
DUP6 DUP6
%add_const(4) %add_const(4)
// stack: ind4, x4, x0, x1, x2, x3, ptr, x5 // stack: ind4, x4, x0, x1, x2, x3, ptr, x5
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: x0, x1, x2, x3, ptr, x5 // stack: x0, x1, x2, x3, ptr, x5
DUP5 DUP5
// stack: ind0, x0, x1, x2, x3, ptr, x5 // stack: ind0, x0, x1, x2, x3, ptr, x5
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: x1, x2, x3, ptr, x5 // stack: x1, x2, x3, ptr, x5
DUP4 DUP4
%add_const(1) %add_const(1)
// stack: ind1, x1, x2, x3, ptr, x5 // stack: ind1, x1, x2, x3, ptr, x5
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: x2, x3, ptr, x5 // stack: x2, x3, ptr, x5
DUP3 DUP3
%add_const(2) %add_const(2)
// stack: ind2, x2, x3, ptr, x5 // stack: ind2, x2, x3, ptr, x5
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: x3, ptr, x5 // stack: x3, ptr, x5
DUP2 DUP2
%add_const(3) %add_const(3)
// stack: ind3, x3, ptr, x5 // stack: ind3, x3, ptr, x5
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: ptr, x5 // stack: ptr, x5
%add_const(5) %add_const(5)
// stack: ind5, x5 // stack: ind5, x5
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: // stack:
%endmacro %endmacro
@ -281,14 +281,14 @@
DUP7 DUP7
%add_const(5) %add_const(5)
// stack: ind5, 2*x5, x0, x1, x2, x3, x4, ptr // stack: ind5, 2*x5, x0, x1, x2, x3, x4, ptr
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: x0, x1, x2, x3, x4, ptr // stack: x0, x1, x2, x3, x4, ptr
PUSH 2 PUSH 2
MULFP254 MULFP254
// stack: 2*x0, x1, x2, x3, x4, ptr // stack: 2*x0, x1, x2, x3, x4, ptr
DUP6 DUP6
// stack: ind0, 2*x0, x1, x2, x3, x4, ptr // stack: ind0, 2*x0, x1, x2, x3, x4, ptr
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: x1, x2, x3, x4, ptr // stack: x1, x2, x3, x4, ptr
PUSH 2 PUSH 2
MULFP254 MULFP254
@ -296,7 +296,7 @@
DUP5 DUP5
%add_const(1) %add_const(1)
// stack: ind1, 2*x1, x2, x3, x4, ptr // stack: ind1, 2*x1, x2, x3, x4, ptr
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: x2, x3, x4, ptr // stack: x2, x3, x4, ptr
PUSH 2 PUSH 2
MULFP254 MULFP254
@ -304,7 +304,7 @@
DUP4 DUP4
%add_const(2) %add_const(2)
// stack: ind2, 2*x2, x3, x4, ptr // stack: ind2, 2*x2, x3, x4, ptr
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: x3, x4, ptr // stack: x3, x4, ptr
PUSH 2 PUSH 2
MULFP254 MULFP254
@ -312,7 +312,7 @@
DUP3 DUP3
%add_const(3) %add_const(3)
// stack: ind3, 2*x3, x4, ptr // stack: ind3, 2*x3, x4, ptr
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: x4, ptr // stack: x4, ptr
PUSH 2 PUSH 2
MULFP254 MULFP254
@ -321,7 +321,7 @@
// stack: ptr, 2*x4 // stack: ptr, 2*x4
%add_const(4) %add_const(4)
// stack: ind4, 2*x4 // stack: ind4, 2*x4
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: // stack:
%endmacro %endmacro
@ -330,32 +330,32 @@
// stack: x0, x1, x2, x3, x4, x5 // stack: x0, x1, x2, x3, x4, x5
PUSH $ptr PUSH $ptr
// stack: ind0, x0, x1, x2, x3, x4, x5 // stack: ind0, x0, x1, x2, x3, x4, x5
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: x1, x2, x3, x4, x5 // stack: x1, x2, x3, x4, x5
PUSH $ptr PUSH $ptr
%add_const(1) %add_const(1)
// stack: ind1, x1, x2, x3, x4, x5 // stack: ind1, x1, x2, x3, x4, x5
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: x2, x3, x4, x5 // stack: x2, x3, x4, x5
PUSH $ptr PUSH $ptr
%add_const(2) %add_const(2)
// stack: ind2, x2, x3, x4, x5 // stack: ind2, x2, x3, x4, x5
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: x3, x4, x5 // stack: x3, x4, x5
PUSH $ptr PUSH $ptr
%add_const(3) %add_const(3)
// stack: ind3, x3, x4, x5 // stack: ind3, x3, x4, x5
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: x4, x5 // stack: x4, x5
PUSH $ptr PUSH $ptr
%add_const(4) %add_const(4)
// stack: ind4, x4, x5 // stack: ind4, x4, x5
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: x5 // stack: x5
PUSH $ptr PUSH $ptr
%add_const(5) %add_const(5)
// stack: ind5, x5 // stack: ind5, x5
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: // stack:
%endmacro %endmacro
@ -365,33 +365,33 @@
PUSH $ptr PUSH $ptr
%add_const(2) %add_const(2)
// stack: ind2, x0, x1, x2, x3, x4, x5 // stack: ind2, x0, x1, x2, x3, x4, x5
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: x1, x2, x3, x4, x5 // stack: x1, x2, x3, x4, x5
PUSH $ptr PUSH $ptr
%add_const(3) %add_const(3)
// stack: ind3, x1, x2, x3, x4, x5 // stack: ind3, x1, x2, x3, x4, x5
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: x2, x3, x4, x5 // stack: x2, x3, x4, x5
PUSH $ptr PUSH $ptr
%add_const(4) %add_const(4)
// stack: ind4, x2, x3, x4, x5 // stack: ind4, x2, x3, x4, x5
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: x3, x4, x5 // stack: x3, x4, x5
PUSH $ptr PUSH $ptr
%add_const(5) %add_const(5)
// stack: ind5, x3, x4, x5 // stack: ind5, x3, x4, x5
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: x4, x5 // stack: x4, x5
%i9 %i9
// stack: y5, y4 // stack: y5, y4
PUSH $ptr PUSH $ptr
%add_const(1) %add_const(1)
// stack: ind1, y5, y4 // stack: ind1, y5, y4
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: y4 // stack: y4
PUSH $ptr PUSH $ptr
// stack: ind0, y4 // stack: ind0, y4
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: // stack:
%endmacro %endmacro
@ -867,61 +867,61 @@
DUP1 DUP1
%add_const(10) %add_const(10)
// stack: ind10, ptr // stack: ind10, ptr
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x10, ptr // stack: x10, ptr
DUP2 DUP2
%add_const(9) %add_const(9)
// stack: ind09, x10, ptr // stack: ind09, x10, ptr
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x09, x10, ptr // stack: x09, x10, ptr
DUP3 DUP3
%add_const(8) %add_const(8)
// stack: ind08, x09, x10, ptr // stack: ind08, x09, x10, ptr
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x08, x09, x10, ptr // stack: x08, x09, x10, ptr
DUP4 DUP4
%add_const(7) %add_const(7)
// stack: ind07, x08, x09, x10, ptr // stack: ind07, x08, x09, x10, ptr
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x07, x08, x09, x10, ptr // stack: x07, x08, x09, x10, ptr
DUP5 DUP5
%add_const(6) %add_const(6)
// stack: ind06, x07, x08, x09, x10, ptr // stack: ind06, x07, x08, x09, x10, ptr
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x06, x07, x08, x09, x10, ptr // stack: x06, x07, x08, x09, x10, ptr
DUP6 DUP6
%add_const(5) %add_const(5)
// stack: ind05, x06, x07, x08, x09, x10, ptr // stack: ind05, x06, x07, x08, x09, x10, ptr
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x05, x06, x07, x08, x09, x10, ptr // stack: x05, x06, x07, x08, x09, x10, ptr
DUP7 DUP7
%add_const(4) %add_const(4)
// stack: ind04, x05, x06, x07, x08, x09, x10, ptr // 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 // stack: x04, x05, x06, x07, x08, x09, x10, ptr
DUP8 DUP8
%add_const(3) %add_const(3)
// stack: ind03, x04, x05, x06, x07, x08, x09, x10, ptr // 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 // stack: x03, x04, x05, x06, x07, x08, x09, x10, ptr
DUP9 DUP9
%add_const(2) %add_const(2)
// stack: ind02, x03, x04, x05, x06, x07, x08, x09, x10, ptr // 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 // stack: x02, x03, x04, x05, x06, x07, x08, x09, x10, ptr
DUP10 DUP10
%add_const(1) %add_const(1)
// stack: ind01, x02, x03, x04, x05, x06, x07, x08, x09, x10, ptr // 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 // stack: x01, x02, x03, x04, x05, x06, x07, x08, x09, x10, ptr
DUP11 DUP11
%add_const(11) %add_const(11)
// stack: ind11, x01, x02, x03, x04, x05, x06, x07, x08, x09, x10, ptr // 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 // stack: x11, x01, x02, x03, x04, x05, x06, x07, x08, x09, x10, ptr
SWAP11 SWAP11
// stack: ind00, x01, x02, x03, x04, x05, x06, x07, x08, x09, x10, x11 // 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 // stack: x00, x01, x02, x03, x04, x05, x06, x07, x08, x09, x10, x11
%endmacro %endmacro
@ -932,60 +932,60 @@
DUP12 DUP12
%add_const(10) %add_const(10)
// stack: ind10, x10, x00, x01, x02, x03, x04, x05, x06, x07, x08, x09, ptr, x11 // 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 // stack: x00, x01, x02, x03, x04, x05, x06, x07, x08, x09, ptr, x11
DUP11 DUP11
// stack: ind00, x00, x01, x02, x03, x04, x05, x06, x07, x08, x09, ptr, x11 // 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 // stack: x01, x02, x03, x04, x05, x06, x07, x08, x09, ptr, x11
DUP10 DUP10
%add_const(01) %add_const(01)
// stack: ind01, x01, x02, x03, x04, x05, x06, x07, x08, x09, ptr, x11 // 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 // stack: x02, x03, x04, x05, x06, x07, x08, x09, ptr, x11
DUP9 DUP9
%add_const(02) %add_const(02)
// stack: ind02, x02, x03, x04, x05, x06, x07, x08, x09, ptr, x11 // 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 // stack: x03, x04, x05, x06, x07, x08, x09, ptr, x11
DUP8 DUP8
%add_const(03) %add_const(03)
// stack: ind03, x03, x04, x05, x06, x07, x08, x09, ptr, x11 // 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 // stack: x04, x05, x06, x07, x08, x09, ptr, x11
DUP7 DUP7
%add_const(04) %add_const(04)
// stack: ind04, x04, x05, x06, x07, x08, x09, ptr, x11 // 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 // stack: x05, x06, x07, x08, x09, ptr, x11
DUP6 DUP6
%add_const(05) %add_const(05)
// stack: ind05, x05, x06, x07, x08, x09, ptr, x11 // stack: ind05, x05, x06, x07, x08, x09, ptr, x11
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: x06, x07, x08, x09, ptr, x11 // stack: x06, x07, x08, x09, ptr, x11
DUP5 DUP5
%add_const(06) %add_const(06)
// stack: ind06, x06, x07, x08, x09, ptr, x11 // stack: ind06, x06, x07, x08, x09, ptr, x11
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: x07, x08, x09, ptr, x11 // stack: x07, x08, x09, ptr, x11
DUP4 DUP4
%add_const(07) %add_const(07)
// stack: ind07, x07, x08, x09, ptr, x11 // stack: ind07, x07, x08, x09, ptr, x11
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: x08, x09, ptr, x11 // stack: x08, x09, ptr, x11
DUP3 DUP3
%add_const(08) %add_const(08)
// stack: ind08, x08, x09, ptr, x11 // stack: ind08, x08, x09, ptr, x11
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: x09, ptr, x11 // stack: x09, ptr, x11
DUP2 DUP2
%add_const(09) %add_const(09)
// stack: ind09, x09, ptr, x11 // stack: ind09, x09, ptr, x11
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: ptr, x11 // stack: ptr, x11
%add_const(11) %add_const(11)
// stack: ind11, x11 // stack: ind11, x11
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: // stack:
%endmacro %endmacro
@ -995,120 +995,120 @@
// stack: src, dest // stack: src, dest
DUP1 DUP1
// stack: ind00, src, dest // stack: ind00, src, dest
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x00, src, dest // stack: x00, src, dest
DUP3 DUP3
// stack: ind00', x00, src, dest // stack: ind00', x00, src, dest
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: src, dest // stack: src, dest
DUP1 DUP1
%add_const(1) %add_const(1)
// stack: ind01, src, dest // stack: ind01, src, dest
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x01, src, dest // stack: x01, src, dest
DUP3 DUP3
%add_const(1) %add_const(1)
// stack: ind01', x01, src, dest // stack: ind01', x01, src, dest
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: src, dest // stack: src, dest
DUP1 DUP1
%add_const(2) %add_const(2)
// stack: ind02, src, dest // stack: ind02, src, dest
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x02, src, dest // stack: x02, src, dest
DUP3 DUP3
%add_const(2) %add_const(2)
// stack: ind02', x02, src, dest // stack: ind02', x02, src, dest
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: src, dest // stack: src, dest
DUP1 DUP1
%add_const(3) %add_const(3)
// stack: ind03, src, dest // stack: ind03, src, dest
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x03, src, dest // stack: x03, src, dest
DUP3 DUP3
%add_const(3) %add_const(3)
// stack: ind03', x03, src, dest // stack: ind03', x03, src, dest
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: src, dest // stack: src, dest
DUP1 DUP1
%add_const(4) %add_const(4)
// stack: ind04, src, dest // stack: ind04, src, dest
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x04, src, dest // stack: x04, src, dest
DUP3 DUP3
%add_const(4) %add_const(4)
// stack: ind04', x04, src, dest // stack: ind04', x04, src, dest
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: src, dest // stack: src, dest
DUP1 DUP1
%add_const(5) %add_const(5)
// stack: ind05, src, dest // stack: ind05, src, dest
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x05, src, dest // stack: x05, src, dest
DUP3 DUP3
%add_const(5) %add_const(5)
// stack: ind05', x05, src, dest // stack: ind05', x05, src, dest
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: src, dest // stack: src, dest
DUP1 DUP1
%add_const(6) %add_const(6)
// stack: ind06, src, dest // stack: ind06, src, dest
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x06, src, dest // stack: x06, src, dest
DUP3 DUP3
%add_const(6) %add_const(6)
// stack: ind06', x06, src, dest // stack: ind06', x06, src, dest
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: src, dest // stack: src, dest
DUP1 DUP1
%add_const(7) %add_const(7)
// stack: ind07, src, dest // stack: ind07, src, dest
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x07, src, dest // stack: x07, src, dest
DUP3 DUP3
%add_const(7) %add_const(7)
// stack: ind07', x07, src, dest // stack: ind07', x07, src, dest
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: src, dest // stack: src, dest
DUP1 DUP1
%add_const(8) %add_const(8)
// stack: ind08, src, dest // stack: ind08, src, dest
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x08, src, dest // stack: x08, src, dest
DUP3 DUP3
%add_const(8) %add_const(8)
// stack: ind08', x08, src, dest // stack: ind08', x08, src, dest
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: src, dest // stack: src, dest
DUP1 DUP1
%add_const(9) %add_const(9)
// stack: ind09, src, dest // stack: ind09, src, dest
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x09, src, dest // stack: x09, src, dest
DUP3 DUP3
%add_const(9) %add_const(9)
// stack: ind09', x09, src, dest // stack: ind09', x09, src, dest
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: src, dest // stack: src, dest
DUP1 DUP1
%add_const(10) %add_const(10)
// stack: ind10, src, dest // stack: ind10, src, dest
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x10, src, dest // stack: x10, src, dest
DUP3 DUP3
%add_const(10) %add_const(10)
// stack: ind10', x10, src, dest // stack: ind10', x10, src, dest
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
// stack: src, dest // stack: src, dest
%add_const(11) %add_const(11)
// stack: ind11, dest // stack: ind11, dest
%mload_kernel_bn254_pairing %mload_bn254_pairing
// stack: x11, dest // stack: x11, dest
DUP2 DUP2
%add_const(11) %add_const(11)
// stack: ind11', x11, dest // stack: ind11', x11, dest
%mstore_kernel_bn254_pairing %mstore_bn254_pairing
%endmacro %endmacro
%macro assert_eq_unit_fp254_12 %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;
use crate::memory::segments::Segment::BnPairing; use crate::memory::segments::Segment::BnPairing;
use crate::util::{biguint_to_mem_vec, mem_vec_to_biguint}; 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. /// Prover input function represented as a scoped function name.
/// Example: `PROVER_INPUT(ff::bn254_base::inverse)` is represented as `ProverInputFn([ff, bn254_base, inverse])`. /// 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(); .as_usize();
let f: [U256; 12] = match field { 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!(), _ => todo!(),
}; };
field.field_extension_inverse(n, f) 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 /// 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>, state: &GenerationState<F>,
segment: Segment, segment: Segment,
virt: usize, virt: usize,
) -> U256 { ) -> 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>( pub(crate) fn mem_read_with_log<F: Field>(