Skip to content

Commit

Permalink
Precompiled ECDSA (#14)
Browse files Browse the repository at this point in the history
* implement a ecrecover contract

* add test cases for ecrecover

* support precompiled ecrecover

* fix simplify

* fix memcopy

* decrease clone

* improve logging

* fix the process of addrs

* update
  • Loading branch information
Koukyosyumei authored Aug 16, 2024
1 parent b2d7b95 commit 68b9649
Show file tree
Hide file tree
Showing 12 changed files with 294 additions and 297 deletions.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ byteorder = "1.5.0"
env_logger = "0.11.5"
log = "0.4.22"
regex = "1.10.5"
getopts = "0.2"
getopts = "0.2"
secp256k1={ version = "0.29.0", features = ["recovery", "rand-std"] }
sha3="0.10.8"
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use rhoevm::modules::expr::is_function_sig_check_prop;
use rhoevm::modules::format::{hex_byte_string, strip_0x};
use rhoevm::modules::smt::parse_z3_output;
use rhoevm::modules::transactions::init_tx;
use rhoevm::modules::types::{ContractCode, Env, Expr, Prop, RuntimeCodeStruct, VM, W256};
use rhoevm::modules::types::{ContractCode, Env, Expr, Prop, RuntimeCodeStruct, EXPR_MEMPTY, VM, W256};

#[derive(Debug)]
struct Args {
Expand Down Expand Up @@ -118,7 +118,7 @@ fn dummy_symvm_from_command(cmd: &SymbolicCommand, calldata: (Expr, Vec<Box<Prop
(_, _, Some(code)) => {
let bs = hex_byte_string("bytes", &strip_0x(code));
let mc = if cmd.create {
ContractCode::InitCode(Box::new(bs), Box::new(Expr::Mempty))
ContractCode::InitCode(Box::new(bs), Box::new(EXPR_MEMPTY))
} else {
ContractCode::RuntimeCode(RuntimeCodeStruct::ConcreteRuntimeCode(Box::new(bs)))
};
Expand Down Expand Up @@ -357,6 +357,7 @@ async fn main() {
vm.state.pc += 1;
}

debug!("Start SMT Solving...");
let mut tasks_check_envs = vec![];
for (pc, constraints, env) in potential_envs {
let constraints_clone = constraints.clone(); // Clone constraints to move into the task
Expand Down Expand Up @@ -442,7 +443,6 @@ async fn main() {
//debug!("UNRECHABLE REVERT @ PC=0x{:x}", pc);
//}
}

info!("Execution of '{}' completed.\n", function_signature);
}
reachable_envs = next_reachable_envs;
Expand Down
6 changes: 3 additions & 3 deletions src/modules/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::modules::format::{hex_byte_string, strip_0x};
use crate::modules::symexec::mk_calldata;
use crate::modules::transactions::init_tx;
use crate::modules::types::{
Addr, BaseState, Contract, ContractCode, Expr, Gas, Prop, RuntimeCodeStruct, VMOpts, VM, W256,
Addr, BaseState, Contract, ContractCode, Expr, Gas, Prop, RuntimeCodeStruct, VMOpts, EXPR_MEMPTY, VM, W256,
};

type URL = String;
Expand Down Expand Up @@ -110,7 +110,7 @@ pub async fn symvm_from_command(cmd: &SymbolicCommand, calldata: (Expr, Vec<Box<
Some(code) => {
let bs = hex_byte_string("bytes", &strip_0x(code));
let mc = if cmd.create {
ContractCode::InitCode(Box::new(bs), Box::new(Expr::Mempty))
ContractCode::InitCode(Box::new(bs), Box::new(EXPR_MEMPTY))
} else {
ContractCode::RuntimeCode(RuntimeCodeStruct::ConcreteRuntimeCode(Box::new(bs)))
};
Expand All @@ -127,7 +127,7 @@ pub async fn symvm_from_command(cmd: &SymbolicCommand, calldata: (Expr, Vec<Box<
(_, _, Some(code)) => {
let bs = hex_byte_string("bytes", &strip_0x(code));
let mc = if cmd.create {
ContractCode::InitCode(Box::new(bs), Box::new(Expr::Mempty))
ContractCode::InitCode(Box::new(bs), Box::new(EXPR_MEMPTY))
} else {
ContractCode::RuntimeCode(RuntimeCodeStruct::ConcreteRuntimeCode(Box::new(bs)))
};
Expand Down
Loading

0 comments on commit 68b9649

Please sign in to comment.