Skip to content
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

refactor: generic size limbs for curve precompiles #417

Merged
merged 19 commits into from
Mar 23, 2024
Merged

Conversation

ctian1
Copy link
Member

@ctian1 ctian1 commented Mar 21, 2024

0xkanekiken and others added 10 commits March 11, 2024 15:48
diff curves

Signed-off-by: 0xkanekiken <100861945+0xKanekiKen@users.noreply.github.com>
Signed-off-by: 0xkanekiken <100861945+0xKanekiKen@users.noreply.github.com>
Signed-off-by: 0xkanekiken <100861945+0xKanekiKen@users.noreply.github.com>
@ctian1 ctian1 marked this pull request as ready for review March 21, 2024 18:14
core/src/lib.rs Show resolved Hide resolved
core/src/operations/field/field_den.rs Outdated Show resolved Hide resolved
core/src/operations/field/field_inner_product.rs Outdated Show resolved Hide resolved
core/src/operations/field/params.rs Show resolved Hide resolved
core/src/syscall/precompiles/edwards/ed_add.rs Outdated Show resolved Hide resolved
}

/// Implement NumWords for NumLimbs where # Limbs is divisible by 4.
impl<N: NumLimbs> NumWords for N
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you could leave a comment explaining wtf is going on here, that would be great :)

@@ -53,14 +52,14 @@ pub struct EdAddAssignCols<T> {
pub q_ptr: T,
pub p_access: [MemoryWriteCols<T>; 16],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: shouldn't these be Ed25519BaseField::... for consistency?


let p_x = limbs_from_prev_access(&row.p_access[0..NUM_WORDS_FIELD_ELEMENT]);
let p_y = limbs_from_prev_access(&row.p_access[NUM_WORDS_FIELD_ELEMENT..]);
let num_words_field_element = E::BaseField::NB_LIMBS / 4;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: here shouldn't we just use the NUM_WORDS trait on E?


// a in the Weierstrass form: y^2 = x^3 + a * x + b.
let a = limbs_from_biguint::<AB, E::BaseField>(&E::a_int());
// TODO: U32 can't be hardcoded here?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this todo mean?

@@ -6,6 +6,9 @@ use serde::{Deserialize, Serialize};
use crate::utils::ec::field::{FieldParameters, MAX_NB_LIMBS};
use crate::utils::ec::{AffinePoint, EllipticCurve, EllipticCurveParameters};

// The number of `u8` limbs in the base field of Ed25519.
const NUM_LIMBS: usize = 32;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we clean up MAX_NB_LIMBS and NUM_LIMBS in here?

@@ -38,6 +40,11 @@ impl FieldParameters for Bn254BaseField {
}
}

impl NumLimbs for Bn254BaseField {
type Limbs = U16;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait i think this should be u32, u62 lol, i was just trolling when i added this file

@ctian1 ctian1 merged commit 5fa44d6 into main Mar 23, 2024
5 checks passed
@ctian1 ctian1 deleted the chris/limbs-generic branch March 23, 2024 00:41
jtguibas pushed a commit that referenced this pull request Mar 29, 2024
Signed-off-by: 0xkanekiken <100861945+0xKanekiKen@users.noreply.github.com>
Co-authored-by: 0xkanekiken <100861945+0xKanekiKen@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants