-
Notifications
You must be signed in to change notification settings - Fork 333
Adding Stark curve + test large 2-adicity fields #1001
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
05a8565
to
2dce3e8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR!
I think the suggested comments should improve the tests without the need for hacks.
2a27fe4
to
c4b42e7
Compare
ff/src/fields/utils.rs
Outdated
pub fn k_adicity_big_int(k: BigUint, mut n: BigUint) -> u32 { | ||
let mut r = 0; | ||
while &n > &1_u8.into() { | ||
if &n % &k == 0_u8.into() { | ||
r += 1; | ||
n /= &k; | ||
} else { | ||
return r; | ||
} | ||
} | ||
r | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, we can write the loop more efficiently as:
pub fn k_adicity_big_int(k: BigUint, mut n: BigUint) -> u32 { | |
let mut r = 0; | |
while &n > &1_u8.into() { | |
if &n % &k == 0_u8.into() { | |
r += 1; | |
n /= &k; | |
} else { | |
return r; | |
} | |
} | |
r | |
} | |
pub fn k_adicity_big_int(k: u64, mut n: BigUint) -> u32 { | |
if n.is_zero() { | |
return 0; | |
} | |
let mut r = 0; | |
while (&n % k).is_zero() { | |
r += 1; | |
n /= k; | |
} | |
r | |
} |
Apologies for the dirty commit. #1001 (comment) This looks really pretty! I took the liberty to update the base k_adicity function the same way! ;) |
chore: starkcurve change log feat: implement starkcurve chore: init starkcurve from grumpkin
chore: test large 2-adicity
c28210b
to
ac31f90
Compare
Rebased (for the failing tests) and cleaned up the commit history if we want to preserve it on merging because of all the different stuff included in the PR. new: added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM modulo the comment about documentation.
Description
closes #1000
Support for fields with large 2 adicity
Currently tests fail to fields with large 2-adicity
Field::TWO_ADICITY > 31
(currently limited byu32
used in tests).1_u32 << ADICITY
.63
in favour ofget_root_of_unity
usingu64
.Adds Stark curve on 252 bit field.
This library implements the Stark curve, An elliptic curve defined over the
STARK field by equation y² ≡ x³ + α·x + β (mod q)
Where:
Generator point:
https://docs.starknet.io/architecture/cryptography/#the_stark_curve
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
Pending
section inCHANGELOG.md
Files changed
in the GitHub PR explorer