mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-07 08:13:11 +00:00
Add test
This commit is contained in:
parent
905b0243e7
commit
ad9e131026
@ -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
|
||||
|
||||
22
evm/src/cpu/kernel/tests/ecrecover.rs
Normal file
22
evm/src/cpu/kernel/tests/ecrecover.rs
Normal 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(())
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
mod curve_ops;
|
||||
mod ecrecover;
|
||||
mod exp;
|
||||
|
||||
use std::str::FromStr;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user