Skip to content

Commit ac67970

Browse files
authored
elliptic-curve: add PointWithBasepointTable trait (#2376)
Adds a trait with an associated `BASEPOINT_TABLE` constant which provides a place to access a particular curve group's `BasepointTable` from a generic context.
1 parent cf5b810 commit ac67970

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

elliptic-curve/src/point.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ mod non_identity;
88
pub use {self::non_identity::NonIdentity, lookup_table::LookupTable};
99

1010
#[cfg(feature = "basepoint-table")]
11-
pub use self::basepoint_table::BasepointTable;
11+
pub use self::basepoint_table::{BasepointTable, PointWithBasepointTable};
1212

1313
use crate::{Curve, FieldBytes};
1414
use subtle::{Choice, CtOption};

elliptic-curve/src/point/basepoint_table.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#[cfg(not(any(feature = "critical-section", feature = "std")))]
77
compile_error!("`basepoint-table` feature requires either `critical-section` or `std`");
88

9-
use crate::point::LookupTable;
9+
use super::LookupTable;
1010
use group::Group;
1111
use subtle::ConditionallySelectable;
1212
use {core::ops::Deref, ff::PrimeField};
@@ -16,6 +16,12 @@ use once_cell::sync::Lazy as LazyLock;
1616
#[cfg(all(feature = "std", not(feature = "critical-section")))]
1717
use std::sync::LazyLock;
1818

19+
/// Associate a precomputed `BASEPOINT_TABLE` constant with a curve point.
20+
pub trait PointWithBasepointTable<const WINDOW_SIZE: usize>: Group {
21+
/// Basepoint table for this curve.
22+
const BASEPOINT_TABLE: &'static BasepointTable<Self, WINDOW_SIZE>;
23+
}
24+
1925
/// Precomputed lookup table of multiples of a base point, a.k.a. generator.
2026
///
2127
/// This type leverages lazy computation, and requires one of the following crate features to be

0 commit comments

Comments
 (0)