initialize out in asm

This commit is contained in:
Dmitry Vagner 2023-04-20 14:07:45 -07:00
parent 4e0be66432
commit 44a623d453
3 changed files with 10 additions and 5 deletions

View File

@ -1,8 +1,8 @@
/// def bn254_pairing(pairs: List((Curve, TwistedCurve))) -> Fp12:
///
/// for P, Q in pairs:
/// assert(is_valid(P))
/// assert(is_valid(Q))
/// assert(P.is_valid)
/// assert(Q.is_valid)
///
/// out = 1
/// for P, Q in pairs:
@ -11,7 +11,12 @@
/// return bn254_final_exponent(out)
global bn254_pairing:
// stack: k, inp, out, retdest
// stack: k, inp, out, retdest
%stack (k, inp, out) -> (out, 1, k, inp, out)
// stack: out, 1, k, inp, out, retdest
%mstore_kernel_bn254_pairing
// stack: k, inp, out, retdest
%jump(bn254_pairing_loop) // this short circuits the input checks
DUP1
// stack: k, k, inp, out, retdest

View File

@ -2,7 +2,7 @@
// Returns (range & curve) || ident
// where
// range = (x < N) & (x_ < N) & (y < N) & (y_ < N)
// curve = Y^2 == X^3 + A
// curve = Y^2 == X^3 + 3/(9+i)
// ident = (X,Y) == (0,0)
%macro bn_check_twisted

View File

@ -304,7 +304,7 @@ fn test_bn_pairing() -> Result<()> {
U256::from(0xdeadbeefu32),
],
segment: BnPairing,
memory: vec![(ptr, inputs), (out, vec![U256::from(acc)])],
memory: vec![(ptr, inputs)],
};
let interpreter = run_interpreter_with_memory(setup).unwrap();
let output: Vec<U256> = interpreter.extract_kernel_memory(BnPairing, out..out + 12);