Skip to content

Commit

Permalink
Add Ethereum Execution Tests (#5)
Browse files Browse the repository at this point in the history
* ecadd tests

* ecmul tests

* Add test utils

* Add test suit generator

* Remove old tests

* Update tests

* Fix ecadd

* Fix ecmul

* Handle modexp tests

* Add modexp tests

* Update call helper function

* Fix helper function

* Fix test utils

* Improve ecmul precompile

* Add test helper

* Add python script to test double and add algorithm (#13)

* Add montgomery reduction algorithm

* Add Rust playground crate

* Update montgomery reduction script

* Add Montgomery reduction precompile

* ecAdd refactor

* Montgomery fix

* Add montgomery inv & modexp

* Fix N'

* Fix REDC

* Fix Montgomery modular inverse

* Remove comments

* Fix prints

* Change to bytes comparison instead of decoded output

* Patch tests with extra check for errors in ecadd and ecmul

* Add EOL

* Update modexp precompile

* Finish optimizing ecAdd & ecMul

* Implement optimized montgomery invmod

* modexpGasCost

* Cleanup

* Last version of ecAdd, ecMul & modexp

* Fix modexp tests calldata

* Fix modexp tests to pass with actual vm state

* Update Montgomery precompile

* Add EOL

---------

Co-authored-by: IAvecilla <iavecilla@fi.uba.ar>
Co-authored-by: Nacho Avecilla <nachoavecilla@gmail.com>
  • Loading branch information
3 people authored Aug 17, 2023
1 parent 8d1d6ae commit 5b99326
Show file tree
Hide file tree
Showing 20 changed files with 4,766 additions and 1,087 deletions.
1 change: 1 addition & 0 deletions playground/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
194 changes: 194 additions & 0 deletions playground/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions playground/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "playground"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
lambdaworks-math ={ git = "https://github.com/lambdaclass/lambdaworks"}
16 changes: 16 additions & 0 deletions playground/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use lambdaworks_math::{field::{fields::montgomery_backed_prime_fields::{IsModulus, U256PrimeField}, element::FieldElement}, unsigned_integer::element::{U256, UnsignedInteger}};

#[derive(Clone, Debug)]
struct AltBn128Modulus;
impl IsModulus<U256> for AltBn128Modulus {
const MODULUS: U256 = UnsignedInteger::from_hex_unchecked(
"30644E72E131A029B85045B68181585D97816A916871CA8D3C208C16D87CFD47",
);
}

type AltBn128PrimeField = U256PrimeField<AltBn128Modulus>;
type AltBn128FieldElement = FieldElement<AltBn128PrimeField>;

fn main() {
println!("{:?}", AltBn128FieldElement::from(3).value().to_string())
}
Loading

0 comments on commit 5b99326

Please sign in to comment.