Skip to content

Commit fa8b3bb

Browse files
committed
MulByGenerator is now in group::Group
1 parent 66ac8a3 commit fa8b3bb

File tree

9 files changed

+29
-43
lines changed

9 files changed

+29
-43
lines changed

Cargo.lock

+13-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-9
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,8 @@ members = [
1919
opt-level = 2
2020

2121
[patch.crates-io]
22-
# https://github.com/zkcrypto/ff/pull/122
23-
ff = { git = "https://github.com/zkcrypto/ff.git", branch = "release-0.14.0" }
24-
25-
# https://github.com/zkcrypto/group/pull/56
26-
# https://github.com/zkcrypto/group/pull/57
27-
# https://github.com/zkcrypto/group/pull/58
28-
# https://github.com/zkcrypto/group/pull/59
29-
group = { git = "https://github.com/baloo/group.git", branch = "baloo/try_from_rng" }
30-
3122
# https://github.com/RustCrypto/signatures/pull/913
23+
# https://github.com/RustCrypto/signatures/pull/940
3224
ecdsa = { git = "https://github.com/RustCrypto/signatures.git" }
3325
rfc6979 = { git = "https://github.com/RustCrypto/signatures.git" }
3426

bign256/src/ecdsa/signing.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ use crate::{BignP256, FieldBytes, NonZeroScalar, ProjectivePoint, PublicKey, Sca
1919
use belt_hash::{BeltHash, Digest};
2020
use core::fmt::{self, Debug};
2121
use elliptic_curve::{
22-
Curve, Field, FieldBytesEncoding, PrimeField,
22+
Curve, Field, FieldBytesEncoding, Group, PrimeField,
2323
array::{Array, sizes::U32, typenum::Unsigned},
24-
ops::{MulByGenerator, Reduce},
24+
ops::Reduce,
2525
point::AffineCoordinates,
2626
subtle::{Choice, ConstantTimeEq},
2727
};

k256/benches/scalar.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use criterion::{
66
use hex_literal::hex;
77
use k256::{
88
ProjectivePoint, Scalar,
9-
elliptic_curve::{group::ff::PrimeField, ops::LinearCombination, ops::MulByGenerator},
9+
elliptic_curve::{Group, group::ff::PrimeField, ops::LinearCombination},
1010
};
1111

1212
fn test_scalar_x() -> Scalar {

k256/src/arithmetic/mul.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ use crate::arithmetic::{
4747

4848
use core::ops::{Mul, MulAssign};
4949
use elliptic_curve::{
50-
ops::{LinearCombination, MulByGenerator},
50+
ops::LinearCombination,
5151
scalar::IsHigh,
5252
subtle::{Choice, ConditionallySelectable, ConstantTimeEq},
5353
};
@@ -386,16 +386,16 @@ fn precompute_gen_lookup_table() -> [LookupTable; 33] {
386386
res
387387
}
388388

389-
impl MulByGenerator for ProjectivePoint {
389+
impl ProjectivePoint {
390390
/// Calculates `k * G`, where `G` is the generator.
391391
#[cfg(not(feature = "precomputed-tables"))]
392-
fn mul_by_generator(k: &Scalar) -> ProjectivePoint {
392+
pub(super) fn mul_by_generator(k: &Scalar) -> ProjectivePoint {
393393
ProjectivePoint::GENERATOR * k
394394
}
395395

396396
/// Calculates `k * G`, where `G` is the generator.
397397
#[cfg(feature = "precomputed-tables")]
398-
fn mul_by_generator(k: &Scalar) -> ProjectivePoint {
398+
pub(super) fn mul_by_generator(k: &Scalar) -> ProjectivePoint {
399399
let digits = Radix16Decomposition::<65>::new(k);
400400
let table = *GEN_LOOKUP_TABLE;
401401
let mut acc = table[32].select(digits.0[64]);
@@ -460,7 +460,6 @@ mod tests {
460460
use crate::arithmetic::{ProjectivePoint, Scalar};
461461
use elliptic_curve::{
462462
Field, Group,
463-
ops::MulByGenerator,
464463
rand_core::{OsRng, TryRngCore},
465464
};
466465

k256/src/arithmetic/projective.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,10 @@ impl Group for ProjectivePoint {
422422
fn double(&self) -> Self {
423423
Self::double(self)
424424
}
425+
426+
fn mul_by_generator(k: &Scalar) -> Self {
427+
Self::mul_by_generator(k)
428+
}
425429
}
426430

427431
impl GroupEncoding for ProjectivePoint {
@@ -680,7 +684,6 @@ mod tests {
680684
};
681685
use elliptic_curve::Field;
682686
use elliptic_curve::group::{ff::PrimeField, prime::PrimeCurveAffine};
683-
use elliptic_curve::ops::MulByGenerator;
684687
use elliptic_curve::{BatchNormalize, group};
685688
use rand_core::{OsRng, TryRngCore};
686689

primeorder/src/projective.rs

+1-12
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use elliptic_curve::{
1717
cofactor::CofactorGroup,
1818
prime::{PrimeCurve, PrimeGroup},
1919
},
20-
ops::{BatchInvert, LinearCombination, MulByGenerator},
20+
ops::{BatchInvert, LinearCombination},
2121
point::Double,
2222
rand_core::TryRngCore,
2323
sec1::{
@@ -425,17 +425,6 @@ where
425425
// TODO(tarcieri): optimized implementation
426426
}
427427

428-
impl<C> MulByGenerator for ProjectivePoint<C>
429-
where
430-
Self: Double,
431-
C: PrimeCurveParams,
432-
{
433-
fn mul_by_generator(scalar: &Self::Scalar) -> Self {
434-
// TODO(tarcieri): precomputed basepoint tables
435-
Self::generator() * scalar
436-
}
437-
}
438-
439428
impl<C> PrimeGroup for ProjectivePoint<C>
440429
where
441430
Self: Double,

sm2/src/dsa/signing.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ use crate::{
2020
};
2121
use core::fmt::{self, Debug};
2222
use elliptic_curve::{
23-
Curve, FieldBytesEncoding, PrimeField,
23+
Curve, FieldBytesEncoding, Group, PrimeField,
2424
array::typenum::Unsigned,
25-
ops::{MulByGenerator, Reduce},
25+
ops::Reduce,
2626
point::AffineCoordinates,
2727
subtle::{Choice, ConstantTimeEq},
2828
};

sm2/src/pke/encrypting.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use alloc::{borrow::ToOwned, boxed::Box, vec::Vec};
1111
use elliptic_curve::{
1212
Curve, Error, Group, Result,
1313
bigint::{RandomBits, U256, Uint, Zero},
14-
ops::{MulByGenerator, Reduce},
14+
ops::Reduce,
1515
pkcs8::der::Encode,
1616
rand_core::TryCryptoRng,
1717
sec1::ToEncodedPoint,

0 commit comments

Comments
 (0)