mirror of https://github.com/zcash/halo2.git
Move CURVE_ID to CurveExt.
This commit is contained in:
parent
75bb8121fb
commit
12230a49e0
|
@ -33,6 +33,9 @@ pub trait CurveExt:
|
|||
+ Mul<Self::ScalarExt, Output = Self>
|
||||
+ for<'r> Mul<Self::ScalarExt, Output = Self>;
|
||||
|
||||
/// CURVE_ID used for hash-to-curve.
|
||||
const CURVE_ID: &'static str;
|
||||
|
||||
/// Apply the curve endomorphism by multiplying the x-coordinate
|
||||
/// by an element of multiplicative order 3.
|
||||
fn endo(&self) -> Self;
|
||||
|
@ -96,9 +99,6 @@ pub trait CurveAffine:
|
|||
/// The projective form of the curve
|
||||
type CurveExt: CurveExt<AffineExt = Self, ScalarExt = <Self as CurveAffine>::ScalarExt>;
|
||||
|
||||
/// CURVE_ID used for hash-to-curve.
|
||||
const CURVE_ID: &'static str;
|
||||
|
||||
/// Gets the $(x, y)$ coordinates of this point.
|
||||
fn get_xy(&self) -> CtOption<(Self::Base, Self::Base)>;
|
||||
|
||||
|
|
|
@ -92,7 +92,9 @@ macro_rules! new_curve_impl {
|
|||
type Base = $base;
|
||||
type AffineExt = $name_affine;
|
||||
|
||||
impl_projective_curve_ext!($name, $name_affine, $iso, $base, $curve_type);
|
||||
const CURVE_ID: &'static str = $curve_id;
|
||||
|
||||
impl_projective_curve_ext!($name, $iso, $base, $curve_type);
|
||||
|
||||
fn a() -> Self::Base {
|
||||
$name::curve_constant_a()
|
||||
|
@ -615,8 +617,6 @@ macro_rules! new_curve_impl {
|
|||
type Base = $base;
|
||||
type CurveExt = $name;
|
||||
|
||||
const CURVE_ID: &'static str = $curve_id;
|
||||
|
||||
fn is_on_curve(&self) -> Choice {
|
||||
// y^2 - x^3 - ax ?= b
|
||||
(self.y.square() - (self.x.square() + &$name::curve_constant_a()) * self.x).ct_eq(&$name::curve_constant_b())
|
||||
|
@ -834,13 +834,13 @@ macro_rules! impl_projective_curve_specific {
|
|||
}
|
||||
|
||||
macro_rules! impl_projective_curve_ext {
|
||||
($name:ident, $name_affine:ident, $iso:ident, $base:ident, special_a0_b5) => {
|
||||
($name:ident, $iso:ident, $base:ident, special_a0_b5) => {
|
||||
fn hash_to_curve<'a>(domain_prefix: &'a str) -> Box<dyn Fn(&[u8]) -> Self + 'a> {
|
||||
use super::hashtocurve;
|
||||
|
||||
Box::new(move |message| {
|
||||
let mut us = [Field::zero(); 2];
|
||||
hashtocurve::hash_to_field($name_affine::CURVE_ID, domain_prefix, message, &mut us);
|
||||
hashtocurve::hash_to_field($name::CURVE_ID, domain_prefix, message, &mut us);
|
||||
let q0 = hashtocurve::map_to_curve_simple_swu::<$base, $name, $iso>(
|
||||
&us[0],
|
||||
$name::THETA,
|
||||
|
@ -867,7 +867,7 @@ macro_rules! impl_projective_curve_ext {
|
|||
}
|
||||
}
|
||||
};
|
||||
($name:ident, $name_affine:ident, $iso:ident, $base:ident, general) => {
|
||||
($name:ident, $iso:ident, $base:ident, general) => {
|
||||
/// Unimplemented: hashing to this curve is not supported
|
||||
fn hash_to_curve<'a>(_domain_prefix: &'a str) -> Box<dyn Fn(&[u8]) -> Self + 'a> {
|
||||
unimplemented!()
|
||||
|
|
Loading…
Reference in New Issue