Skip to content

Commit

Permalink
Abstract Felt Type so that we can have different implementation that …
Browse files Browse the repository at this point in the history
…uses different big int libraries (#630)

* Add felt and field types

* Add felt and field types

* Add operations

* Changes to Structure

* Update felt.rs

* Change bigint to felt instruction

* Change bigint to felt run_context

* Make new method take integer param

* Add and comment out ops; fix new signature

* Use  on

* Remove bigint from macros

* Remove bigint from memory

* Remove unwrap

* Remove bigint from utils

* Change BigInt to Felt instruction

* Change BigInt to Felt hint proce def

* Change BigInt to Felt decoder

* Change BigInt to Felt vm_core

* More work on macros

* Remove field

* Fix imports

* Remove Bigint from deserialize

* Remove BigInt straggelers

* Change BigInt to Felt hint proc utils

* Update relocatable.rs

* Change BigInt to Felt blake2s_utils

* Change BigInt3 to Felt

* Replace BigInt in hint_utils

* Remove BigInt keccak

* Replace BigInt in dict manager

* Remove BigInt find_elem_hint

* Remove bigint keccak hints

* Add new functions

* Remove Bigint from math utils

* Remove bigint from memory cp and set

* Remove field from error

* Remove Bigint from range check

* Remobe bigint pow, segments

* Remove Bigint set hint

* Remove BigInt

* Remove bigint from usor hints

* Remove bigint uint256

* Various replacements

* Felt ops and fmt

* Add comment

* WIP

* Add needed deps, Fix some std::ops impls

* fix more std::ops and get it to compile

* enable all tests

* use the felt type from the felt library

* make felt Add generic over into bigint

* add Sub for usize - felt

* Add to_str_radix to felt

* fix felt tests

* add Sub u32 - Felt because its needed in some places

* Use felt in cairo_runner

* fix vm_memory/memory tests

* Add abs to felt

* fix various issues in builtin_runner

* fix to_field_element

* add Neg to felt

* partially port math,ec_utils,segments hints from bigint to felt

* format

* remove some clones, fix clippy warnings

* assert the felt type implements the proper traits

* implement more traits

* Solve conflicts on main code

* Main code is compiling

* Fix macro import errors; Fix some tests

* Unit tests now compile

* Fix some math hint bugs

* fix some errors and clippy warnings

* add ibig dependency and create the module

* Add felt neg test

* Debug secp

* Save work

* Fix secp bugs

* Remove clones; use lto fat

* Fix misc unit tests; fix big assert_le_felt

* Fix sqrt bug

* Unit & integration tests work

* Fix tests

* Fix clippy warnings

* Extend tratis check

* Add missing sub checks

* Add bench; remove ibig from branch

* Reduce number

* Remove dependency

* Reverse bad changes

* Merge with main

* Move felt_str macro

* Shorten From impls with macros

* Remove benchmark

* Remove monostate dep

* Expand from macro

* Change Felt internal type to BigUint

* Use Integer trait

* Use primitive instead of calling 'one'

* Use primitive instead of calling 'one'

* Use primitive instead of calling 'one'

* Use primitive instead of calling 'one'

* Small fixes

* Create just one Felt in Pow hint

* Use new_n instead of Zero

* Fix Clippy warnings hyperlinks

* Change usize to u128

* Create CAIRO_SIGNED_PRIME const

* Use value into instead of conversion

* Use div_mod_floor for mul_inverse

* Return x instead of using mod_floor

* Use SumAssign in loop

* Remove unused function

* Use acc in Sum trait

* Use SubAssing in Sub for FeltBigInt

* Use match num instead of self.0

* Use CAIRO_PRIME - 1 in max value

* Make abs_sub implementation explicit

* Use max value in signum

* Simplify match math_utils

* Use or(|) instead of add(+)

* Remove clone from get_point_from_x

* Use div rem

* Remove clones and Felt from ec_double

* Remove clones and Felt from ec_double_slope

* Remove clones and Felt from ec_double_slope

* Uncomment math tests

* Create BigUint instead of converting

* Uncomment builtin ec_op tests

* Fix broken ec_op runner tests

* Use Add Assign

* Fix clippy warnings

Co-authored-by: Mario J. Rugiero <[email protected]>
Co-authored-by: Edgar Luque <[email protected]>
Co-authored-by: Juanma <[email protected]>
  • Loading branch information
4 people authored Jan 5, 2023
1 parent 91f8dce commit 9bf61ea
Show file tree
Hide file tree
Showing 67 changed files with 4,190 additions and 3,475 deletions.
12 changes: 12 additions & 0 deletions Cargo.lock

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

7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[workspace]
members = [".", "felt"]

[package]
name = "cairo-rs"
version = "0.1.0"
Expand Down Expand Up @@ -35,6 +38,7 @@ generic-array = "0.14.6"
# https://github.com/Geal/nom/issues/1253
keccak = "0.1.2"
parse-hyperlinks = { path = "./deps/parse-hyperlinks" }
felt = { path = "./felt" }

[dev-dependencies]
iai = "0.1"
Expand All @@ -61,3 +65,6 @@ name = "cairo-rs-run"
path = "src/main.rs"
bench = false
doc = false

[profile.release]
lto = "fat"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"prime": "0x000A",
"prime": "0x800000000000011000000000000000000000000000000000000000000000001",
"attributes": [],
"debug_info": {
"instruction_locations": {}
Expand Down
2 changes: 1 addition & 1 deletion deps/parse-hyperlinks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub fn take_until_unbalanced(
let matching = i
.get(0..index)
.ok_or_else(|| Err::Error(Error::from_error_kind(i, ErrorKind::TakeUntil)))?;
return Ok((&remaining, &matching));
return Ok((remaining, matching));
};
}

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

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

[dependencies]
num-integer = "*"
num-bigint = { version = "0.4", features = ["serde"] }
num-traits = "*"
lazy_static = "*"
serde = { version = "1.0", features = ["derive"] }
Loading

0 comments on commit 9bf61ea

Please sign in to comment.