forked from starknet-io/types-rs
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create stark-cuve crate + naive implement ProjectivePoint
- Loading branch information
Showing
6 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[package] | ||
name = "stark-curve" | ||
version = "0.0.3" | ||
edition = "2021" | ||
license = "MIT" | ||
homepage = "https://github.com/starknet-io/types-rs" | ||
repository = "https://github.com/starknet-io/types-rs" | ||
categories = ["types", "math", "crypto"] | ||
keywords = ["stark", "zkp", "cairo"] | ||
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 } | ||
num-traits = { version = "0.2.16", default-features = false } | ||
|
||
stark-felt = {path = "../stark-felt"} | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
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 stark_felt::Felt; | ||
|
||
#[derive(Debug, Clone, PartialEq, Eq)] | ||
pub struct ProjectivePoint(ShortWeierstrassProjectivePoint<StarkCurve>); | ||
|
||
impl ProjectivePoint { | ||
pub fn new(x: Felt, y: Felt, z: Felt) -> ProjectivePoint { | ||
Self(ShortWeierstrassProjectivePoint::new([x.0, y.0, z.0])) | ||
} | ||
|
||
pub fn identity() -> ProjectivePoint { | ||
Self(ShortWeierstrassProjectivePoint::neutral_element()) | ||
} | ||
} | ||
|
||
impl ops::AddAssign<&ProjectivePoint> for ProjectivePoint { | ||
fn add_assign(&mut self, rhs: &ProjectivePoint) { | ||
self.0 = self.0.operate_with(&rhs.0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters