Skip to content

Commit a989555

Browse files
authored
docs: add docs for starknet-curve (#633)
1 parent 5299462 commit a989555

File tree

3 files changed

+70
-2
lines changed

3 files changed

+70
-2
lines changed

starknet-curve/README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
1-
# Starknet Curve
1+
# Starknet Curve Parameters
2+
3+
The `starknet-curve` crate contains a few useful parameters for the STARK curve defined as:
4+
5+
```
6+
y^2 = x^3 + alpha * x + beta
7+
```
8+
9+
where:
10+
11+
- `alpha` = `0x0000000000000000000000000000000000000000000000000000000000000001`
12+
- `beta` = `0x06f21413efbe40de150e596d72f7a8c5609ad26c15c915c1f4cdfcb99cee9e89`

starknet-curve/src/curve_params.rs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,51 @@
11
use starknet_types_core::curve::AffinePoint;
22
use starknet_types_core::felt::Felt;
33

4+
/// EC order of the STARK curve for ECDSA. Equals to
5+
/// `0x0800000000000010ffffffffffffffffb781126dcae7b2321e66a241adc64d2f`.
46
pub const EC_ORDER: Felt = Felt::from_raw([
57
369010039416812937,
68
9,
79
1143265896874747514,
810
8939893405601011193,
911
]);
1012

13+
/// The alpha parameter of the STARK curve. Equals to
14+
/// `0x0000000000000000000000000000000000000000000000000000000000000001`.
15+
///
16+
/// The alpha parameter is used in the curve definition as:
17+
///
18+
/// ```markdown
19+
/// y^2 = x^3 + alpha * x + beta
20+
/// ```
1121
pub const ALPHA: Felt = Felt::from_raw([
1222
576460752303422960,
1323
18446744073709551615,
1424
18446744073709551615,
1525
18446744073709551585,
1626
]);
1727

28+
/// The beta parameter of the STARK curve. Equals to
29+
/// `0x06f21413efbe40de150e596d72f7a8c5609ad26c15c915c1f4cdfcb99cee9e89`.
30+
///
31+
/// The beta parameter is used in the curve definition as:
32+
///
33+
/// ```markdown
34+
/// y^2 = x^3 + alpha * x + beta
35+
/// ```
1836
pub const BETA: Felt = Felt::from_raw([
1937
88155977965380735,
2038
12360725113329547591,
2139
7432612994240712710,
2240
3863487492851900874,
2341
]);
2442

43+
/// Generator point of the STARK curve.
44+
///
45+
/// Coordinates:
46+
///
47+
/// - x: `0x01ef15c18599971b7beced415a40f0c7deacfd9b0d1819e03d723d8bc943cfca`
48+
/// - y: `0x005668060aa49730b7be4801df46ec62de53ecd11abe43a32873000c36e8dc1f`
2549
pub const GENERATOR: AffinePoint = AffinePoint::new_unchecked(
2650
Felt::from_raw([
2751
232005955912912577,
@@ -37,6 +61,12 @@ pub const GENERATOR: AffinePoint = AffinePoint::new_unchecked(
3761
]),
3862
);
3963

64+
/// Shift point of the STARK curve.
65+
///
66+
/// Coordinates:
67+
///
68+
/// - x: `0x049ee3eba8c1600700ee1b87eb599f16716b0b1022947733551fde4050ca6804`
69+
/// - y: `0x03ca0cfe4b3bc6ddf346d49d06ea0ed34e621062c0e056c1d0405d266e10268a`
4070
pub const SHIFT_POINT: AffinePoint = AffinePoint::new_unchecked(
4171
Felt::from_raw([
4272
316327189671755572,
@@ -52,6 +82,12 @@ pub const SHIFT_POINT: AffinePoint = AffinePoint::new_unchecked(
5282
]),
5383
);
5484

85+
/// The P0 constant of the STARK curve.
86+
///
87+
/// Coordinates:
88+
///
89+
/// - x: `0x0234287dcbaffe7f969c748655fca9e58fa8120b6d56eb0c1080d17957ebe47b`
90+
/// - y: `0x03b056f100f96fb21e889527d41f4e39940135dd7a6c94cc6ed0268ee89e5615`
5591
pub const PEDERSEN_P0: AffinePoint = AffinePoint::new_unchecked(
5692
Felt::from_raw([
5793
241691544791834578,
@@ -67,6 +103,12 @@ pub const PEDERSEN_P0: AffinePoint = AffinePoint::new_unchecked(
67103
]),
68104
);
69105

106+
/// The P1 constant of the STARK curve.
107+
///
108+
/// Coordinates:
109+
///
110+
/// - x: `0x04fa56f376c83db33f9dab2656558f3399099ec1de5e3018b7a6932dba8aa378`
111+
/// - y: `0x03fa0984c931c9e38113e0c0e47e4401562761f92a7a23b45168f4e80ff5b54d`
70112
pub const PEDERSEN_P1: AffinePoint = AffinePoint::new_unchecked(
71113
Felt::from_raw([
72114
253000153565733272,
@@ -82,6 +124,12 @@ pub const PEDERSEN_P1: AffinePoint = AffinePoint::new_unchecked(
82124
]),
83125
);
84126

127+
/// The P2 constant of the STARK curve.
128+
///
129+
/// Coordinates:
130+
///
131+
/// - x: `0x04ba4cc166be8dec764910f75b45f74b40c690c74709e90f3aa372f0bd2d6997`
132+
/// - y: `0x0040301cf5c1751f4b971e46c4ede85fcac5c59a5ce5ae7c48151f27b24b219c`
85133
pub const PEDERSEN_P2: AffinePoint = AffinePoint::new_unchecked(
86134
Felt::from_raw([
87135
338510149841406402,
@@ -97,6 +145,12 @@ pub const PEDERSEN_P2: AffinePoint = AffinePoint::new_unchecked(
97145
]),
98146
);
99147

148+
/// The P3 constant of the STARK curve.
149+
///
150+
/// Coordinates:
151+
///
152+
/// - x: `0x054302dcb0e6cc1c6e44cca8f61a63bb2ca65048d53fb325d36ff12c49a58202`
153+
/// - y: `0x01b77b3e37d13504b348046268d8ae25ce98ad783c25561a879dcc77e99c2426`
100154
pub const PEDERSEN_P3: AffinePoint = AffinePoint::new_unchecked(
101155
Felt::from_raw([
102156
425493972656615276,

starknet-curve/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
//! A library with constant parameters for the Stark elliptic curve.
2+
3+
#![deny(missing_docs)]
14
#![no_std]
2-
#![doc = include_str!("../README.md")]
35

6+
/// Module containing the Stark elliptic curve parameters.
47
pub mod curve_params;

0 commit comments

Comments
 (0)