-
Notifications
You must be signed in to change notification settings - Fork 25
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
Extension field #44
Extension field #44
Conversation
0524294
to
9c0ba70
Compare
use crate::field::FiniteField; | ||
|
||
/// Pluto curve with modulus 101 supports two degree extension field. This can be verified | ||
/// by finding out embedding degree of the curve, i.e. smallest k: r|q^k-1 |
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.
When reading about the embedding degree I was trying to see this by hand but came across some questions. In our case r is our curve order which is 17 and p is field order which is 101. How does 17 | 101 ^2 - 1 which is 17 | 10200. 17 doesn't divide 10200. Also 10200 mod 101 is just 17 | 100. Do I have an error in my arithmetic? Are we working in a field here?
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.
17 doesn't divide 10200.
Umm, Waylon 17 does divide 10200.
In our case r is our curve order which is 17
Also, our curve order is 102 (101 points + 1 point at infinity). 17 is the largest prime factor of
E1 = EllipticCurve(F, [0, 3])
print(E1.order())
P1 = E1(1, 2)
print(P1.order())
k = 17
cofactor = 6
# use cofactor clearing to find generator of prime order subgroup
# take a random point, and multiply by cofactor until it's INF point
G = E1.random_point()
INF = E1(0)
print(G, cofactor * G)
while cofactor * G == INF:
print("as")
G = E1.random_point()
Ps = cofactor * G
print(cofactor * G, Ps.order())
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.
that's a classic 😅
#[derive(Clone, Default, Copy, Eq, PartialEq, Hash, Debug, Serialize, Deserialize)] | ||
|
||
/// Quadratic Extension field element represented as polynomial of degree 1 in form: | ||
/// a_0 + a_1*t where {a_0, a_1} \in \mathhbb{F}. Uses irreducible poly of the form: |
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.
I think this is the right approach but curious how or if we should use this in our polynomial module. I know @Autoparallel you have been working on the FFTs and polynomial interface. Maybe you have some insight here?
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.
Let me get the polynomial PR up.
|
||
/// Quadratic Extension field element represented as polynomial of degree 1 in form: | ||
/// a_0 + a_1*t where {a_0, a_1} \in \mathhbb{F}. Uses irreducible poly of the form: | ||
/// (X^2-K). |
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.
should this be X^2 -K or X^2 + K? X^2 + 2 is irreducible in F_{101} and should be used to generate our extension field.
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.
I think both work as (correct me if I'm wrong) 2 is not a square in GF_{101}.
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.
yeah, both of them are irreducible, added it in the field sage script as well
Lines 47 to 51 in 9c0ba70
Ft.<t> = F[] | |
# irreducible element: t^2-2 | |
P = Ft(t ^ 2 - 2) | |
assert P.is_irreducible() |
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.
I'm good with this to go in as is :)
src/field/gf_101.rs
Outdated
@@ -83,6 +83,8 @@ impl FiniteField for GF101 { | |||
fn neg_one() -> Self { Self::new(Self::ORDER - 1) } | |||
|
|||
fn generator() -> Self { Self::new(2) } | |||
|
|||
fn from_canonical_u32(n: u32) -> Self { Self::new(n) } // TODO: recheck |
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.
This is a nit, but we don't really need this if we just use GF101::new()
right?
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.
but then that's struct specific function right? We need a trait specific function to create new values, for example: in extension fields, each subvalue in extension field element is base field element.
ronkathon/src/field/gf_101_2.rs
Line 69 in 9c0ba70
Self { value: [F::from_canonical_u32(15), F::from_canonical_u32(20)] } |
Is there a better way in Rust to do this? Sorry, still in my learning path for Rust.
#[derive(Clone, Default, Copy, Eq, PartialEq, Hash, Debug, Serialize, Deserialize)] | ||
|
||
/// Quadratic Extension field element represented as polynomial of degree 1 in form: | ||
/// a_0 + a_1*t where {a_0, a_1} \in \mathhbb{F}. Uses irreducible poly of the form: |
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.
Let me get the polynomial PR up.
|
||
/// Quadratic Extension field element represented as polynomial of degree 1 in form: | ||
/// a_0 + a_1*t where {a_0, a_1} \in \mathhbb{F}. Uses irreducible poly of the form: | ||
/// (X^2-K). |
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.
I think both work as (correct me if I'm wrong) 2 is not a square in GF_{101}.
@0xJepsen @Autoparallel changes done. let me know if any others are needed |
commit 2637594 Author: Waylon Jepsen <[email protected]> Date: Thu May 9 10:38:12 2024 -0600 curves: Second curve group and some test (#49) * chore: tests + scalar multiplication * fmt * wip: compiles, but generator point is broken * wip * fix mul, generator and add hardcoded tests (#51) * fix mul, generator and add hardcoded tests * fix generator test * wip * fix: test fails when rng has no inverse --------- Co-authored-by: Sambhav <[email protected]> commit def9371 Author: Waylon Jepsen <[email protected]> Date: Thu May 9 09:36:25 2024 -0600 docs: readme (#46) * docs: readme * wip: pairing check * docs * Update README.md Co-authored-by: Colin Roberts <[email protected]> * Update README.md Co-authored-by: Colin Roberts <[email protected]> --------- Co-authored-by: Colin Roberts <[email protected]> commit ab0d374 Author: Sambhav <[email protected]> Date: Wed May 8 03:00:15 2024 +0530 Extension field (#44) * feat: extension field init * add test * add more tests and comments * move pow impl default to trait commit f9aa66e Author: Waylon Jepsen <[email protected]> Date: Tue May 7 09:00:35 2024 -0600 curves in sage (#39) commit 63ce62f Author: Waylon Jepsen <[email protected]> Date: Mon May 6 17:46:22 2024 -0600 fix: lock commit d1c84eb Author: Colin Roberts <[email protected]> Date: Mon May 6 16:39:25 2024 -0700 feat: home-baked `FiniteField` trait (#38) * feat: new `FiniteField` trait Now everything compiles again. Will work to clean this all up and get all the tests to pass. * fix: `GF101` tests pass * fix: reimplement monty optimizations * clean: udeps --------- Co-authored-by: Waylon Jepsen <[email protected]> commit 96c8b66 Merge: fb27e5f 62a9a57 Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon May 6 23:26:56 2024 +0000 Merge pull request #42 from pluto/dependabot/cargo/anyhow-1.0.83 Bump anyhow from 1.0.82 to 1.0.83 commit 62a9a57 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon May 6 23:26:43 2024 +0000 Bump anyhow from 1.0.82 to 1.0.83 Bumps [anyhow](https://github.com/dtolnay/anyhow) from 1.0.82 to 1.0.83. - [Release notes](https://github.com/dtolnay/anyhow/releases) - [Commits](dtolnay/anyhow@1.0.82...1.0.83) --- updated-dependencies: - dependency-name: anyhow dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]>
This PR closes issue #40
It changes the following:
PlutoField
. I've not made field extension generic over degree. let me know if that is required.