mirror of
https://github.com/saymrwulf/risc0-curve25519-dalek-source.git
synced 2026-09-05 20:10:35 +00:00
Add function to get the basepoint from a basepoint table
This commit is contained in:
parent
127169c151
commit
0ae0d2b72a
2 changed files with 19 additions and 0 deletions
14
src/curve.rs
14
src/curve.rs
|
|
@ -890,6 +890,13 @@ impl EdwardsBasepointTable {
|
|||
}
|
||||
table
|
||||
}
|
||||
|
||||
/// Get the basepoint for this table as an `ExtendedPoint`.
|
||||
pub fn basepoint(&self) -> ExtendedPoint {
|
||||
// self.0[0][0] has 1*(16^2)^0*B, but as an `AffineNielsPoint`
|
||||
// Add identity to convert to extended.
|
||||
(&ExtendedPoint::identity() + &self.0[0][0]).to_extended()
|
||||
}
|
||||
}
|
||||
|
||||
impl ExtendedPoint {
|
||||
|
|
@ -1271,6 +1278,13 @@ mod test {
|
|||
assert_eq!(compressed, constants::BASE_CMPRSSD);
|
||||
}
|
||||
|
||||
/// Test that `EdwardsBasepointTable::basepoint()` gives the correct basepoint.
|
||||
#[test]
|
||||
fn basepoint_table_basepoint_function_correct() {
|
||||
let bp = constants::ED25519_BASEPOINT_TABLE.basepoint();
|
||||
assert_eq!(bp.compress_edwards(), constants::BASE_CMPRSSD);
|
||||
}
|
||||
|
||||
/// Test `impl Add<ExtendedPoint> for ExtendedPoint`
|
||||
/// using basepoint + basepoint versus the 2*basepoint constant.
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -276,6 +276,11 @@ impl DecafBasepointTable {
|
|||
pub fn create(basepoint: &DecafPoint) -> DecafBasepointTable {
|
||||
DecafBasepointTable(EdwardsBasepointTable::create(&basepoint.0))
|
||||
}
|
||||
|
||||
/// Get the basepoint for this table as a `DecafPoint`.
|
||||
pub fn basepoint(&self) -> DecafPoint {
|
||||
DecafPoint(self.0.basepoint())
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Reference in a new issue