Skip to content

Commit

Permalink
rename stark-felt -> starknet-types-core && Implement curve mod
Browse files Browse the repository at this point in the history
  • Loading branch information
pefontana committed Oct 20, 2023
1 parent 79a7461 commit c39043a
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 17 deletions.
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
[workspace]
members = [
"crates/stark-felt",
"crates/stark-curve",
"crates/starknet-types-core",
"crates/starknet-types-rpc",
]
Expand Down
2 changes: 1 addition & 1 deletion crates/stark-curve/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ description = "A stark curve type for Cairo."
readme = "README.md"

[dependencies]
lambdaworks-math = { git = "https://github.com/Lambdaclass/lambdaworks.git" ,rev = "23154c1b2b7c1cb1620e40ee53fbb446a2923923", default_features = true }
lambdaworks-math = { git = "https://github.com/Lambdaclass/lambdaworks.git" ,rev = "340045b631e7465cc66cc9140dff9c2d41b7839f", default_features = false }
num-traits = { version = "0.2.16", default-features = false }

stark-felt = {path = "../stark-felt"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "stark-felt"
name = "starknet-types-core"
version = "0.0.3"
edition = "2021"
license = "MIT"
Expand All @@ -13,7 +13,8 @@ readme = "README.md"
[dependencies]
bitvec = { version = "1.0.1", default-features = false }
serde = { version = "1.0.163", optional = true, default-features = false }
lambdaworks-math = { git = "https://github.com/Lambdaclass/lambdaworks.git" ,rev = "23154c1b2b7c1cb1620e40ee53fbb446a2923923", default_features = false }
lambdaworks-math = { path = "../../../lambdaworks/math", default-features = false}


arbitrary = { version = "1.3.0", optional = true, default-features = false }
num-traits = { version = "0.2.16", default-features = false }
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use crate::felt::Felt;
use core::ops;
use lambdaworks_math::cyclic_group::IsGroup;
use lambdaworks_math::elliptic_curve::short_weierstrass::curves::stark_curve::StarkCurve;
use lambdaworks_math::elliptic_curve::short_weierstrass::point::ShortWeierstrassProjectivePoint;
use lambdaworks_math::elliptic_curve::traits::{EllipticCurveError, FromAffine};
use stark_felt::Felt;

// TODO sacar pub
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ProjectivePoint(ShortWeierstrassProjectivePoint<StarkCurve>);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
#![cfg_attr(not(feature = "std"), no_std)]

use core::ops::{Add, Neg};

use bitvec::array::BitArray;
use num_traits::{FromPrimitive, ToPrimitive, Zero};

#[cfg(test)]
mod arbitrary_proptest;

#[cfg(target_pointer_width = "64")]
pub type BitArrayStore = [u64; 4];

Expand All @@ -33,7 +28,7 @@ use arbitrary::{self, Arbitrary, Unstructured};

/// Definition of the Field Element type.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Felt(pub FieldElement<Stark252PrimeField>);
pub struct Felt(pub(crate) FieldElement<Stark252PrimeField>);

/// A non-zero [Felt].
pub struct NonZeroFelt(FieldElement<Stark252PrimeField>);
Expand Down Expand Up @@ -830,7 +825,7 @@ mod errors {
mod test {
use super::alloc::{format, string::String, vec::Vec};
use super::*;
use crate::arbitrary_proptest::nonzero_felt;
use crate::felt_arbitrary::nonzero_felt;
use core::ops::Shl;
use proptest::prelude::*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use lambdaworks_math::{field::element::FieldElement, unsigned_integer::element::
use num_traits::Zero;
use proptest::prelude::*;

use crate::Felt;
use crate::felt::Felt;
const FIELD_HIGH: u128 = (1 << 123) + (17 << 64); // this is equal to 10633823966279327296825105735305134080
const FIELD_LOW: u128 = 1;

Expand Down
6 changes: 6 additions & 0 deletions crates/starknet-types-core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#![cfg_attr(not(feature = "std"), no_std)]
pub mod curve;
pub mod felt;

#[cfg(test)]
mod felt_arbitrary;
3 changes: 1 addition & 2 deletions ensure_no_std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ version = "0.1.0"
edition = "2021"

[dependencies]
stark-felt = { path = "../crates/stark-felt", default-features = false, features = [
starknet-types-core = { path = "../crates/starknet-types-core", default-features = false, features = [
"alloc",
"serde",
] }
starknet-types-core = { path = "../crates/starknet-types-core", default-features = false }
starknet-types-rpc = { path = "../crates/starknet-types-rpc", default-features = false }
wee_alloc = "0.4.5"

Expand Down
2 changes: 1 addition & 1 deletion ensure_no_std/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ pub extern "C" fn _start() -> ! {
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;

#[allow(unused_imports)]
use stark_felt;
use stark_types;

0 comments on commit c39043a

Please sign in to comment.