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
end
In 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} or curve::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}
end
Tasks:
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
Replace
curve::CinECPoint{T,C}with reference to reduce memory usageDescription:
Currently, the
ECPointstruct stores a full copy of the curve object:In 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
constorRef) could significantly reduce the memory footprint without impacting correctness.Proposal:
Refactor
ECPointto hold a reference or shared handle to the curve object. Some ideas:const GLOBAL_CURVE = ...and pass reference to thatcurve::C→curve::Ref{C}orcurve::Base.RefValue{C}New structure could look like:
Tasks:
curve::CECPointsMotivation: