Skip to content

Commit 437db4c

Browse files
authored
hash2curve: rename GroupDigest::K to SecurityLevel (#1388)
1 parent e25ccd1 commit 437db4c

File tree

7 files changed

+15
-15
lines changed

7 files changed

+15
-15
lines changed

ed448-goldilocks/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl elliptic_curve::CurveArithmetic for Ed448 {
118118
}
119119

120120
impl GroupDigest for Ed448 {
121-
type K = U28;
121+
type SecurityLevel = U28;
122122
}
123123

124124
/// Decaf448 curve.
@@ -167,5 +167,5 @@ impl elliptic_curve::CurveArithmetic for Decaf448 {
167167
}
168168

169169
impl GroupDigest for Decaf448 {
170-
type K = U28;
170+
type SecurityLevel = U28;
171171
}

hash2curve/src/group_digest.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub trait GroupDigest: MapToCurve {
88
/// The target security level in bytes:
99
/// <https://www.rfc-editor.org/rfc/rfc9380.html#section-8.9-2.2>
1010
/// <https://www.rfc-editor.org/rfc/rfc9380.html#name-target-security-levels>
11-
type K: Unsigned;
11+
type SecurityLevel: Unsigned;
1212

1313
/// Computes the hash to curve routine.
1414
///
@@ -33,7 +33,7 @@ pub trait GroupDigest: MapToCurve {
3333
/// [`ExpandMsgXofError`]: crate::ExpandMsgXofError
3434
fn hash_from_bytes<X>(msg: &[&[u8]], dst: &[&[u8]]) -> Result<ProjectivePoint<Self>, X::Error>
3535
where
36-
X: ExpandMsg<Self::K>,
36+
X: ExpandMsg<Self::SecurityLevel>,
3737
{
3838
let [u0, u1] = hash_to_field::<2, X, _, Self::FieldElement>(msg, dst)?;
3939
let q0 = Self::map_to_curve(u0);
@@ -63,7 +63,7 @@ pub trait GroupDigest: MapToCurve {
6363
/// [`ExpandMsgXofError`]: crate::ExpandMsgXofError
6464
fn encode_from_bytes<X>(msg: &[&[u8]], dst: &[&[u8]]) -> Result<ProjectivePoint<Self>, X::Error>
6565
where
66-
X: ExpandMsg<Self::K>,
66+
X: ExpandMsg<Self::SecurityLevel>,
6767
{
6868
let [u] = hash_to_field::<1, X, _, Self::FieldElement>(msg, dst)?;
6969
let q0 = Self::map_to_curve(u);
@@ -86,7 +86,7 @@ pub trait GroupDigest: MapToCurve {
8686
/// [`ExpandMsgXofError`]: crate::ExpandMsgXofError
8787
fn hash_to_scalar<X>(msg: &[&[u8]], dst: &[&[u8]]) -> Result<Self::Scalar, X::Error>
8888
where
89-
X: ExpandMsg<Self::K>,
89+
X: ExpandMsg<Self::SecurityLevel>,
9090
{
9191
let [u] = hash_to_field::<1, X, _, Self::Scalar>(msg, dst)?;
9292
Ok(u)

hash2curve/src/oprf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ pub trait OprfParameters: GroupDigest + PrimeCurve {
2525
/// and `HashToScalar` as defined in [section 4 of RFC9497][oprf].
2626
///
2727
/// [oprf]: https://www.rfc-editor.org/rfc/rfc9497.html#name-ciphersuites
28-
type ExpandMsg: ExpandMsg<<Self as GroupDigest>::K>;
28+
type ExpandMsg: ExpandMsg<<Self as GroupDigest>::SecurityLevel>;
2929
}

k256/src/arithmetic/hash2curve.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::{AffinePoint, ProjectivePoint, Scalar, Secp256k1};
1212
use super::FieldElement;
1313

1414
impl GroupDigest for Secp256k1 {
15-
type K = U16;
15+
type SecurityLevel = U16;
1616
}
1717

1818
impl FromOkm for FieldElement {
@@ -356,7 +356,7 @@ mod tests {
356356
let u = hash2curve::hash_to_field::<
357357
2,
358358
ExpandMsgXmd<Sha256>,
359-
<Secp256k1 as GroupDigest>::K,
359+
<Secp256k1 as GroupDigest>::SecurityLevel,
360360
FieldElement,
361361
>(&[test_vector.msg], &[DST])
362362
.unwrap();

p256/src/arithmetic/hash2curve.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use elliptic_curve::{
1010
use hash2curve::{FromOkm, GroupDigest, MapToCurve, OsswuMap, OsswuMapParams, Sgn0};
1111

1212
impl GroupDigest for NistP256 {
13-
type K = U16;
13+
type SecurityLevel = U16;
1414
}
1515

1616
impl FromOkm for FieldElement {
@@ -207,7 +207,7 @@ mod tests {
207207
let u = hash2curve::hash_to_field::<
208208
2,
209209
ExpandMsgXmd<Sha256>,
210-
<NistP256 as GroupDigest>::K,
210+
<NistP256 as GroupDigest>::SecurityLevel,
211211
FieldElement,
212212
>(&[test_vector.msg], &[DST])
213213
.unwrap();

p384/src/arithmetic/hash2curve.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use elliptic_curve::{
1111
use hash2curve::{FromOkm, GroupDigest, MapToCurve, OsswuMap, OsswuMapParams, Sgn0};
1212

1313
impl GroupDigest for NistP384 {
14-
type K = U24;
14+
type SecurityLevel = U24;
1515
}
1616

1717
impl FromOkm for FieldElement {
@@ -212,7 +212,7 @@ mod tests {
212212
let u = hash2curve::hash_to_field::<
213213
2,
214214
ExpandMsgXmd<Sha384>,
215-
<NistP384 as GroupDigest>::K,
215+
<NistP384 as GroupDigest>::SecurityLevel,
216216
FieldElement,
217217
>(&[test_vector.msg], &[DST])
218218
.unwrap();

p521/src/arithmetic/hash2curve.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use elliptic_curve::{
1111
use hash2curve::{FromOkm, GroupDigest, MapToCurve, OsswuMap, OsswuMapParams, Sgn0};
1212

1313
impl GroupDigest for NistP521 {
14-
type K = U32;
14+
type SecurityLevel = U32;
1515
}
1616

1717
impl FromOkm for FieldElement {
@@ -215,7 +215,7 @@ mod tests {
215215
let u = hash2curve::hash_to_field::<
216216
2,
217217
ExpandMsgXmd<Sha512>,
218-
<NistP521 as GroupDigest>::K,
218+
<NistP521 as GroupDigest>::SecurityLevel,
219219
FieldElement,
220220
>(&[test_vector.msg], &[DST])
221221
.unwrap();

0 commit comments

Comments
 (0)