This commit is contained in:
wborgeaud 2022-07-14 13:16:25 +02:00
parent 905b0243e7
commit ad9e131026
3 changed files with 23 additions and 17 deletions

View File

@ -48,23 +48,6 @@ ecrecover_valid_input:
// stack: x, y, u1, ecrecover_with_first_point, hash, r^(-1), retdest
%jump(ec_mul_valid_point_secp)
SWAP2
// stack: hash, y, u1, x, r^(-1), retdest
SWAP3
// stack: x, y, u1, hash, r^(-1), retdest
SWAP4
// stack: r^(-1), y, hash, x, u1, retdest
SWAP1
// stack: y, r^(-1), hash, x, u1, retdest
SWAP2
// stack: hash, r^(-1), y, x, u1, retdest
%secp_scalar
// stack: p, hash, r^(-1), y, x, u1, retdest
SUB
// stack: p - hash, r^(-1), y, x, u1, retdest // Assume hash < p, should be hard (127-bit) to find a hash larger than p.
%mulmodn_secp_scalar
// stack: u2, y, x, u1, retdest // Assume hash < p, should be hard (127-bit) to find a hash larger than p.
ecrecover_with_first_point:
JUMPDEST
// stack: X, Y, hash, r^(-1), retdest

View File

@ -0,0 +1,22 @@
use anyhow::Result;
use crate::cpu::kernel::aggregator::combined_kernel;
use crate::cpu::kernel::interpreter::run;
use crate::cpu::kernel::tests::u256ify;
#[test]
fn test_ec_ops() -> Result<()> {
// Make sure we can parse and assemble the entire kernel.
let kernel = combined_kernel();
let ecrecover = kernel.global_labels["ecrecover"];
let hash = "0x0";
let v = "0x27";
let r = "0x1";
let s = "0x1";
let initial_stack = u256ify([s, r, v, hash])?;
let stack = run(&kernel.code, ecrecover, initial_stack);
dbg!(stack);
Ok(())
}

View File

@ -1,4 +1,5 @@
mod curve_ops;
mod ecrecover;
mod exp;
use std::str::FromStr;