Skip to main content

k256/arithmetic/
tables.rs

1//! Precomputed tables (optional).
2//!
3//! We only provide a constant-time basepoint table here as the generic wNAF implementation in the
4//! `group` crate doesn't support the secp256k1 endomorphism optimization and thus winds up being
5//! slower than the constant-time version (see RustCrypto/elliptic-curves
6
7use super::Secp256k1;
8use crate::ProjectivePoint;
9use primeorder::PrimeCurveWithBasepointTable;
10
11/// Window size for the basepoint table.
12const WINDOW_SIZE: usize = 33;
13
14/// Basepoint table for multiples of secp256k1's generator.
15type BasepointTable = primeorder::BasepointTable<ProjectivePoint, WINDOW_SIZE>;
16
17/// Lazily computed basepoint table.
18pub(super) static BASEPOINT_TABLE: BasepointTable = BasepointTable::new();
19
20impl PrimeCurveWithBasepointTable<WINDOW_SIZE> for Secp256k1 {
21    const BASEPOINT_TABLE: &'static BasepointTable = &BASEPOINT_TABLE;
22}