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

generalize-curve: move CurvePoint behind a trait #557

Merged
merged 49 commits into from
Feb 11, 2025
Merged

Conversation

naure
Copy link

@naure naure commented Dec 29, 2024

In this PR we make the following changes:

  • Introduce a trait for the curve (named CurveTrait).
  • Introduce a trait for the scalar (temp. name ScalarTrait).
  • Introduce a trait for the verifying key (named VerifyingKeyTrait).
  • Introduce a trait for the Signature (temp. name SignatureTrait).
  • Add the generic type (<C>) everywhere.
  • Extract operations into the traits. This is not a full curve trait, rather it represents exactly the needs of the library.
  • Add P256 curve implementation of the above 4 traits
  • Generalize part of the testing infra structure
  • Create variable TestCurve that points to the curve that will be fully tested
    (joint work with @emmorais)

@naure naure marked this pull request as draft January 8, 2025 17:15
@emmorais emmorais self-assigned this Jan 28, 2025
@naure naure marked this pull request as ready for review January 30, 2025 10:44
This was referenced Jan 30, 2025
Copy link

@gatoWololo gatoWololo left a comment

Choose a reason for hiding this comment

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

Hello,

I left some minor feedback. Overall this looks good to me. This change is very impressive. It adds quite a bit of complexity specially with the Generics + associated types and lifetimes. But it all seems to work. And IDK how we would do this any simpler.

My only real thought. I notice we have a pattern of C: CurveTrait + 'static throughout. I wonder if it would be possible to fold in the 'static lifetime as part of the definition on trait CurveTrait. This way we wouldn't need to list it in so many places (IDK this may not work). The observation is that we don't have a use case for our C: CurveTrait to ever have a non-static lifetime, i.e some reference.

@emmorais
Copy link

emmorais commented Feb 3, 2025

Hello,

I left some minor feedback. Overall this looks good to me. This change is very impressive. It adds quite a bit of complexity specially with the Generics + associated types and lifetimes. But it all seems to work. And IDK how we would do this any simpler.

My only real thought. I notice we have a pattern of C: CurveTrait + 'static throughout. I wonder if it would be possible to fold in the 'static lifetime as part of the definition on trait CurveTrait. This way we wouldn't need to list it in so many places (IDK this may not work). The observation is that we don't have a use case for our C: CurveTrait to ever have a non-static lifetime, i.e some reference.

Indeed moving static to CurveTrait allowed to remove a lot of repeated code. Thank you.

Copy link
Member

@jakinyele jakinyele left a comment

Choose a reason for hiding this comment

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

LGTM!

@gatoWololo gatoWololo self-requested a review February 11, 2025 16:33
@gatoWololo gatoWololo merged commit 4c0357b into main Feb 11, 2025
2 checks passed
@gatoWololo gatoWololo deleted the generalize-curve branch February 11, 2025 16:34
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.

4 participants