From ae34f0a60f94dba6cd4cb580720f40a3ee2ac7c6 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Sat, 4 May 2024 07:21:54 -0400 Subject: [PATCH] Add DivisorCurve impl to Helios and Selene --- crypto/helioselene/Cargo.toml | 2 ++ crypto/helioselene/src/point.rs | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/crypto/helioselene/Cargo.toml b/crypto/helioselene/Cargo.toml index dba27a29..ba569f41 100644 --- a/crypto/helioselene/Cargo.toml +++ b/crypto/helioselene/Cargo.toml @@ -27,6 +27,8 @@ crypto-bigint = { version = "0.5", default-features = false, features = ["zeroiz dalek-ff-group = { path = "../dalek-ff-group", version = "0.4.1", default-features = false, features = ["std"] } +ec-divisors = { path = "../divisors" } + [dev-dependencies] hex = "0.4" diff --git a/crypto/helioselene/src/point.rs b/crypto/helioselene/src/point.rs index c6c08395..e0e68682 100644 --- a/crypto/helioselene/src/point.rs +++ b/crypto/helioselene/src/point.rs @@ -340,6 +340,22 @@ macro_rules! curve { } impl PrimeGroup for $Point {} + + impl ec_divisors::DivisorCurve for $Point { + type FieldElement = $Field; + + fn a() -> Self::FieldElement { + -$Field::from(3u64) + } + fn b() -> Self::FieldElement { + B + } + + fn to_xy(point: Self) -> (Self::FieldElement, Self::FieldElement) { + let z = point.z.invert().unwrap(); + (point.x * z, point.y * z) + } + } }; }