Skip to content

Commit

Permalink
fix: rename the "simple_svdw_*" with "sswu_*"
Browse files Browse the repository at this point in the history
  • Loading branch information
duguorong009 committed Dec 16, 2023
1 parent 29b3f12 commit 31690de
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/hash_to_curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ fn hash_to_field<F: FromUniformBytes<64>>(

// Implementation of <https://datatracker.ietf.org/doc/html/rfc9380#name-simplified-swu-method>
#[allow(clippy::too_many_arguments)]
pub(crate) fn simple_svdw_map_to_curve<C>(u: C::Base, z: C::Base) -> C
pub(crate) fn sswu_map_to_curve<C>(u: C::Base, z: C::Base) -> C
where
C: CurveExt,
{
Expand Down Expand Up @@ -157,7 +157,7 @@ where

// Implementation of <https://datatracker.ietf.org/doc/html/rfc9380#name-simplified-swu-method>
#[allow(clippy::type_complexity)]
pub(crate) fn simple_svdw_hash_to_curve<'a, C>(
pub(crate) fn sswu_hash_to_curve<'a, C>(
curve_id: &'static str,
domain_prefix: &'a str,
z: C::Base,
Expand All @@ -170,7 +170,7 @@ where
let mut us = [C::Base::ZERO; 2];
hash_to_field("SSWU", curve_id, domain_prefix, message, &mut us);

let [q0, q1]: [C; 2] = us.map(|u| simple_svdw_map_to_curve::<C>(u, z));
let [q0, q1]: [C; 2] = us.map(|u| sswu_map_to_curve::<C>(u, z));

let r = q0 + &q1;
debug_assert!(bool::from(r.is_on_curve()));
Expand All @@ -180,7 +180,7 @@ where

// Implementation of <https://datatracker.ietf.org/doc/html/rfc9380#name-simplified-swu-for-ab-0>
#[allow(clippy::type_complexity)]
pub(crate) fn simple_svdw_hash_to_curve_secp256k1<'a>(
pub(crate) fn sswu_hash_to_curve_secp256k1<'a>(
_curve_id: &'static str,
domain_prefix: &'a str,
) -> Box<dyn Fn(&[u8]) -> Secp256k1 + 'a> {
Expand Down
8 changes: 4 additions & 4 deletions src/secp256k1/curve.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::ff::WithSmallOrderMulGroup;
use crate::ff::{Field, PrimeField};
use crate::group::{prime::PrimeCurveAffine, Curve, Group as _, GroupEncoding};
use crate::hash_to_curve::{simple_svdw_hash_to_curve, simple_svdw_hash_to_curve_secp256k1};
use crate::hash_to_curve::{sswu_hash_to_curve, sswu_hash_to_curve_secp256k1};
use crate::secp256k1::Fp;
use crate::secp256k1::Fq;
use crate::{Coordinates, CurveAffine, CurveExt};
Expand Down Expand Up @@ -65,7 +65,7 @@ new_curve_impl!(
SECP_A,
SECP_B,
"secp256k1",
|curve_id, domain_prefix| simple_svdw_hash_to_curve_secp256k1(curve_id, domain_prefix),
|curve_id, domain_prefix| sswu_hash_to_curve_secp256k1(curve_id, domain_prefix),
);

impl Secp256k1 {
Expand Down Expand Up @@ -134,14 +134,14 @@ new_curve_impl!(
ISO_SECP_A,
ISO_SECP_B,
"secp256k1",
|curve_id, domain_prefix| simple_svdw_hash_to_curve(curve_id, domain_prefix, IsoSecp256k1::SVDW_Z),
|curve_id, domain_prefix| sswu_hash_to_curve(curve_id, domain_prefix, IsoSecp256k1::SSWU_Z),
);

impl IsoSecp256k1 {
// Z = -11 (reference: <https://www.rfc-editor.org/rfc/rfc9380.html#name-suites-for-secp256k1>)
// 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc24
// NOTE: This `Z` is the `SSWU_Z` of `Secp256k1` curve.
const SVDW_Z: Fp = Fp([
const SSWU_Z: Fp = Fp([
0xfffffffefffffc24,
0xffffffffffffffff,
0xffffffffffffffff,
Expand Down
4 changes: 2 additions & 2 deletions src/secp256r1/curve.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::ff::WithSmallOrderMulGroup;
use crate::ff::{Field, PrimeField};
use crate::group::{prime::PrimeCurveAffine, Curve, Group as _, GroupEncoding};
use crate::hash_to_curve::simple_svdw_hash_to_curve;
use crate::hash_to_curve::sswu_hash_to_curve;
use crate::secp256r1::Fp;
use crate::secp256r1::Fq;
use crate::{Coordinates, CurveAffine, CurveExt};
Expand Down Expand Up @@ -76,7 +76,7 @@ new_curve_impl!(
SECP_A,
SECP_B,
"secp256r1",
|curve_id, domain_prefix| simple_svdw_hash_to_curve(curve_id, domain_prefix, Secp256r1::SSVDW_Z),
|curve_id, domain_prefix| sswu_hash_to_curve(curve_id, domain_prefix, Secp256r1::SSVDW_Z),
);

impl Secp256r1 {
Expand Down

0 comments on commit 31690de

Please sign in to comment.