-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Replace curve::C in ECPoint{T,C} with reference to reduce memory usage
Description:
Currently, the ECPoint struct stores a full copy of the curve object:
struct ECPoint{T, C<:Curve}
point::Point{T}
curve::C
endIn many cases, especially for static or singleton curves (e.g. base points on a known curve), this results in unnecessary duplication and increased memory pressure. Holding a reference to the curve (or even using a shared singleton via const or Ref) could significantly reduce the memory footprint without impacting correctness.
Proposal:
Refactor ECPoint to hold a reference or shared handle to the curve object. Some ideas:
- Use
const GLOBAL_CURVE = ...and pass reference to that - Change
curve::C→curve::Ref{C}orcurve::Base.RefValue{C} - Use a parametric singleton pattern if curve data is constant
New structure could look like:
struct ECPoint{T, C<:Curve}
point::Point{T}
curve::Ref{C} # or Base.RefValue{C}
endTasks:
- Benchmark construction and point arithmetic with current
curve::C - Measure memory overhead for large sets of
ECPoints - Evaluate design options (immutable singleton vs reference container)
- Implement the chosen strategy
- Test impact on performance and garbage collection
Motivation:
- Reduce per-point memory footprint
- Enable more efficient curve-based cryptographic structures
- Lay the groundwork for supporting large batches of points over the same curve
Metadata
Metadata
Assignees
Labels
No labels