Skip to content

Commit 0473d9d

Browse files
authored
Bump MSRV to v1.83 (#140)
* Fix Clippy warnings for Rust v1.86 * Bump MSRV to v1.83 Signed-off-by: daxpedda <[email protected]> --------- Signed-off-by: daxpedda <[email protected]>
1 parent f0531f0 commit 0473d9d

File tree

11 files changed

+141
-523
lines changed

11 files changed

+141
-523
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
- --features serde
4444
toolchain:
4545
- stable
46-
- 1.65.0
46+
- 1.83.0
4747
name: test
4848
steps:
4949
- name: Checkout sources

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ license = "MIT"
88
name = "voprf"
99
readme = "README.md"
1010
repository = "https://github.com/facebook/voprf/"
11-
rust-version = "1.65"
11+
rust-version = "1.83"
1212
version = "0.5.0"
1313

1414
[features]

src/common.rs

Lines changed: 22 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ use core::convert::TryFrom;
1212
use core::ops::Add;
1313

1414
use derive_where::derive_where;
15-
use digest::core_api::BlockSizeUser;
16-
use digest::{Digest, Output, OutputSizeUser};
15+
use digest::{Digest, Output};
1716
use generic_array::sequence::Concat;
18-
use generic_array::typenum::{IsLess, IsLessOrEqual, Unsigned, U2, U256, U9};
17+
use generic_array::typenum::{IsLess, Unsigned, U2, U256, U9};
1918
use generic_array::{ArrayLength, GenericArray};
2019
use rand_core::{CryptoRng, RngCore};
2120
use subtle::ConstantTimeEq;
@@ -79,10 +78,7 @@ impl Mode {
7978
pub struct BlindedElement<CS: CipherSuite>(
8079
#[cfg_attr(feature = "serde", serde(with = "Element::<CS::Group>"))]
8180
pub(crate) <CS::Group as Group>::Elem,
82-
)
83-
where
84-
<CS::Hash as OutputSizeUser>::OutputSize:
85-
IsLess<U256> + IsLessOrEqual<<CS::Hash as BlockSizeUser>::BlockSize>;
81+
);
8682

8783
/// The server's response to the [BlindedElement] message from a client (either
8884
/// verifiable or not) to a server (either verifiable or not).
@@ -96,10 +92,7 @@ where
9692
pub struct EvaluationElement<CS: CipherSuite>(
9793
#[cfg_attr(feature = "serde", serde(with = "Element::<CS::Group>"))]
9894
pub(crate) <CS::Group as Group>::Elem,
99-
)
100-
where
101-
<CS::Hash as OutputSizeUser>::OutputSize:
102-
IsLess<U256> + IsLessOrEqual<<CS::Hash as BlockSizeUser>::BlockSize>;
95+
);
10396

10497
/// Contains prepared [`EvaluationElement`]s by a server batch evaluate
10598
/// preparation.
@@ -110,10 +103,7 @@ where
110103
derive(serde::Deserialize, serde::Serialize),
111104
serde(bound = "")
112105
)]
113-
pub struct PreparedEvaluationElement<CS: CipherSuite>(pub(crate) EvaluationElement<CS>)
114-
where
115-
<CS::Hash as OutputSizeUser>::OutputSize:
116-
IsLess<U256> + IsLessOrEqual<<CS::Hash as BlockSizeUser>::BlockSize>;
106+
pub struct PreparedEvaluationElement<CS: CipherSuite>(pub(crate) EvaluationElement<CS>);
117107

118108
/// A proof produced by a server that the OPRF output matches against a server
119109
/// public key.
@@ -124,11 +114,7 @@ where
124114
derive(serde::Deserialize, serde::Serialize),
125115
serde(bound = "")
126116
)]
127-
pub struct Proof<CS: CipherSuite>
128-
where
129-
<CS::Hash as OutputSizeUser>::OutputSize:
130-
IsLess<U256> + IsLessOrEqual<<CS::Hash as BlockSizeUser>::BlockSize>,
131-
{
117+
pub struct Proof<CS: CipherSuite> {
132118
#[cfg_attr(feature = "serde", serde(with = "Scalar::<CS::Group>"))]
133119
pub(crate) c_scalar: <CS::Group as Group>::Scalar,
134120
#[cfg_attr(feature = "serde", serde(with = "Scalar::<CS::Group>"))]
@@ -147,14 +133,10 @@ pub(crate) fn generate_proof<CS: CipherSuite, R: RngCore + CryptoRng>(
147133
k: <CS::Group as Group>::Scalar,
148134
a: <CS::Group as Group>::Elem,
149135
b: <CS::Group as Group>::Elem,
150-
cs: impl Iterator<Item = <CS::Group as Group>::Elem> + ExactSizeIterator,
151-
ds: impl Iterator<Item = <CS::Group as Group>::Elem> + ExactSizeIterator,
136+
cs: impl ExactSizeIterator<Item = <CS::Group as Group>::Elem>,
137+
ds: impl ExactSizeIterator<Item = <CS::Group as Group>::Elem>,
152138
mode: Mode,
153-
) -> Result<Proof<CS>>
154-
where
155-
<CS::Hash as OutputSizeUser>::OutputSize:
156-
IsLess<U256> + IsLessOrEqual<<CS::Hash as BlockSizeUser>::BlockSize>,
157-
{
139+
) -> Result<Proof<CS>> {
158140
// https://www.rfc-editor.org/rfc/rfc9497#section-2.2.1
159141

160142
let (m, z) = compute_composites::<CS, _, _>(Some(k), b, cs, ds, mode)?;
@@ -209,15 +191,11 @@ where
209191
pub(crate) fn verify_proof<CS: CipherSuite>(
210192
a: <CS::Group as Group>::Elem,
211193
b: <CS::Group as Group>::Elem,
212-
cs: impl Iterator<Item = <CS::Group as Group>::Elem> + ExactSizeIterator,
213-
ds: impl Iterator<Item = <CS::Group as Group>::Elem> + ExactSizeIterator,
194+
cs: impl ExactSizeIterator<Item = <CS::Group as Group>::Elem>,
195+
ds: impl ExactSizeIterator<Item = <CS::Group as Group>::Elem>,
214196
proof: &Proof<CS>,
215197
mode: Mode,
216-
) -> Result<()>
217-
where
218-
<CS::Hash as OutputSizeUser>::OutputSize:
219-
IsLess<U256> + IsLessOrEqual<<CS::Hash as BlockSizeUser>::BlockSize>,
220-
{
198+
) -> Result<()> {
221199
// https://www.rfc-editor.org/rfc/rfc9497#section-2.2.2
222200
let (m, z) = compute_composites::<CS, _, _>(None, b, cs, ds, mode)?;
223201
let t2 = (a * &proof.s_scalar) + &(b * &proof.c_scalar);
@@ -282,11 +260,7 @@ fn compute_composites<
282260
c_slice: IC,
283261
d_slice: ID,
284262
mode: Mode,
285-
) -> Result<ComputeCompositesResult<CS>>
286-
where
287-
<CS::Hash as OutputSizeUser>::OutputSize:
288-
IsLess<U256> + IsLessOrEqual<<CS::Hash as BlockSizeUser>::BlockSize>,
289-
{
263+
) -> Result<ComputeCompositesResult<CS>> {
290264
// https://www.rfc-editor.org/rfc/rfc9497#section-2.2.1
291265

292266
let elem_len = <CS::Group as Group>::ElemLen::U16.to_be_bytes();
@@ -362,11 +336,7 @@ pub(crate) fn derive_key_internal<CS: CipherSuite>(
362336
seed: &[u8],
363337
info: &[u8],
364338
mode: Mode,
365-
) -> Result<<CS::Group as Group>::Scalar, Error>
366-
where
367-
<CS::Hash as OutputSizeUser>::OutputSize:
368-
IsLess<U256> + IsLessOrEqual<<CS::Hash as BlockSizeUser>::BlockSize>,
369-
{
339+
) -> Result<<CS::Group as Group>::Scalar, Error> {
370340
let dst = Dst::new::<CS, _, _>(STR_DERIVE_KEYPAIR, mode);
371341

372342
let info_len = i2osp_2(info.len()).map_err(|_| Error::DeriveKeyPair)?;
@@ -400,11 +370,7 @@ pub fn derive_key<CS: CipherSuite>(
400370
seed: &[u8],
401371
info: &[u8],
402372
mode: Mode,
403-
) -> Result<<CS::Group as Group>::Scalar, Error>
404-
where
405-
<CS::Hash as OutputSizeUser>::OutputSize:
406-
IsLess<U256> + IsLessOrEqual<<CS::Hash as BlockSizeUser>::BlockSize>,
407-
{
373+
) -> Result<<CS::Group as Group>::Scalar, Error> {
408374
derive_key_internal::<CS>(seed, info, mode)
409375
}
410376

@@ -418,11 +384,7 @@ pub(crate) fn derive_keypair<CS: CipherSuite>(
418384
seed: &[u8],
419385
info: &[u8],
420386
mode: Mode,
421-
) -> Result<DeriveKeypairResult<CS>, Error>
422-
where
423-
<CS::Hash as OutputSizeUser>::OutputSize:
424-
IsLess<U256> + IsLessOrEqual<<CS::Hash as BlockSizeUser>::BlockSize>,
425-
{
387+
) -> Result<DeriveKeypairResult<CS>, Error> {
426388
let sk_s = derive_key_internal::<CS>(seed, info, mode)?;
427389
let pk_s = CS::Group::base_elem() * &sk_s;
428390

@@ -438,11 +400,7 @@ pub(crate) fn deterministic_blind_unchecked<CS: CipherSuite>(
438400
input: &[u8],
439401
blind: &<CS::Group as Group>::Scalar,
440402
mode: Mode,
441-
) -> Result<<CS::Group as Group>::Elem>
442-
where
443-
<CS::Hash as OutputSizeUser>::OutputSize:
444-
IsLess<U256> + IsLessOrEqual<<CS::Hash as BlockSizeUser>::BlockSize>,
445-
{
403+
) -> Result<<CS::Group as Group>::Elem> {
446404
let hashed_point = hash_to_group::<CS>(input, mode)?;
447405
Ok(hashed_point * blind)
448406
}
@@ -451,11 +409,7 @@ where
451409
pub(crate) fn hash_to_group<CS: CipherSuite>(
452410
input: &[u8],
453411
mode: Mode,
454-
) -> Result<<CS::Group as Group>::Elem>
455-
where
456-
<CS::Hash as OutputSizeUser>::OutputSize:
457-
IsLess<U256> + IsLessOrEqual<<CS::Hash as BlockSizeUser>::BlockSize>,
458-
{
412+
) -> Result<<CS::Group as Group>::Elem> {
459413
let dst = Dst::new::<CS, _, _>(STR_HASH_TO_GROUP, mode);
460414
CS::Group::hash_to_curve::<CS::Hash>(&[input], &dst.as_dst()).map_err(|_| Error::Input)
461415
}
@@ -466,11 +420,7 @@ pub(crate) fn server_evaluate_hash_input<CS: CipherSuite>(
466420
input: &[u8],
467421
info: Option<&[u8]>,
468422
issued_element: GenericArray<u8, <<CS as CipherSuite>::Group as Group>::ElemLen>,
469-
) -> Result<Output<CS::Hash>>
470-
where
471-
<CS::Hash as OutputSizeUser>::OutputSize:
472-
IsLess<U256> + IsLessOrEqual<<CS::Hash as BlockSizeUser>::BlockSize>,
473-
{
423+
) -> Result<Output<CS::Hash>> {
474424
// OPRF & VOPRF
475425
// hashInput = I2OSP(len(input), 2) || input ||
476426
// I2OSP(len(issuedElement), 2) || issuedElement ||
@@ -504,12 +454,11 @@ pub(crate) struct Dst<L: ArrayLength<u8>> {
504454
}
505455

506456
impl<L: ArrayLength<u8>> Dst<L> {
507-
pub(crate) fn new<CS: CipherSuite, T, TL: ArrayLength<u8>>(par_1: T, mode: Mode) -> Self
457+
pub(crate) fn new<CS, T, TL>(par_1: T, mode: Mode) -> Self
508458
where
459+
CS: CipherSuite,
509460
T: Into<GenericArray<u8, TL>>,
510-
TL: Add<U9, Output = L>,
511-
<CS::Hash as OutputSizeUser>::OutputSize:
512-
IsLess<U256> + IsLessOrEqual<<CS::Hash as BlockSizeUser>::BlockSize>,
461+
TL: ArrayLength<u8> + Add<U9, Output = L>,
513462
{
514463
let par_1 = par_1.into();
515464
// Generates the contextString parameter as defined in

src/error.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,4 @@ pub enum InternalError {
4141
I2osp,
4242
}
4343

44-
#[cfg(feature = "std")]
45-
impl std::error::Error for Error {}
44+
impl core::error::Error for Error {}

src/group/elliptic_curve.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
// of this source tree. You may select, at your option, one of the above-listed
77
// licenses.
88

9+
use core::ops::Add;
10+
911
use digest::core_api::BlockSizeUser;
1012
use digest::{FixedOutput, HashMarker};
1113
use elliptic_curve::group::cofactor::CofactorGroup;
@@ -14,28 +16,37 @@ use elliptic_curve::sec1::{FromEncodedPoint, ModulusSize, ToEncodedPoint};
1416
use elliptic_curve::{
1517
AffinePoint, Field, FieldBytesSize, Group as _, ProjectivePoint, PublicKey, Scalar, SecretKey,
1618
};
17-
use generic_array::typenum::{IsLess, IsLessOrEqual, U256};
18-
use generic_array::GenericArray;
19+
use generic_array::typenum::{IsLess, IsLessOrEqual, Sum, U256};
20+
use generic_array::{ArrayLength, GenericArray};
1921
use rand_core::{CryptoRng, RngCore};
2022

2123
use super::Group;
2224
use crate::{Error, InternalError, Result};
2325

26+
type ElemLen<C> = <ScalarLen<C> as ModulusSize>::CompressedPointSize;
27+
type ScalarLen<C> = FieldBytesSize<C>;
28+
2429
impl<C> Group for C
2530
where
2631
C: GroupDigest,
2732
ProjectivePoint<Self>: CofactorGroup + ToEncodedPoint<Self>,
28-
FieldBytesSize<Self>: ModulusSize,
33+
ScalarLen<Self>: ModulusSize,
2934
AffinePoint<Self>: FromEncodedPoint<Self> + ToEncodedPoint<Self>,
3035
Scalar<Self>: FromOkm,
36+
// `VoprfClientLen`, `PoprfClientLen`, `VoprfServerLen`, `PoprfServerLen`
37+
ScalarLen<Self>: Add<ElemLen<Self>>,
38+
Sum<ScalarLen<Self>, ElemLen<Self>>: ArrayLength<u8>,
39+
// `ProofLen`
40+
ScalarLen<Self>: Add<ScalarLen<Self>>,
41+
Sum<ScalarLen<Self>, ScalarLen<Self>>: ArrayLength<u8>,
3142
{
3243
type Elem = ProjectivePoint<Self>;
3344

34-
type ElemLen = <FieldBytesSize<Self> as ModulusSize>::CompressedPointSize;
45+
type ElemLen = ElemLen<Self>;
3546

3647
type Scalar = Scalar<Self>;
3748

38-
type ScalarLen = FieldBytesSize<Self>;
49+
type ScalarLen = ScalarLen<Self>;
3950

4051
// Implements the `hash_to_curve()` function from
4152
// https://www.rfc-editor.org/rfc/rfc9380.html#section-3

src/group/mod.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use core::ops::{Add, Mul, Sub};
1616

1717
use digest::core_api::BlockSizeUser;
1818
use digest::{FixedOutput, HashMarker};
19-
use generic_array::typenum::{IsLess, IsLessOrEqual, U256};
19+
use generic_array::typenum::{IsLess, IsLessOrEqual, Sum, U256};
2020
use generic_array::{ArrayLength, GenericArray};
2121
use rand_core::{CryptoRng, RngCore};
2222
#[cfg(feature = "ristretto255")]
@@ -28,7 +28,15 @@ use crate::{InternalError, Result};
2828

2929
/// A prime-order subgroup of a base field (EC, prime-order field ...). This
3030
/// subgroup is noted additively — as in the RFC — in this trait.
31-
pub trait Group {
31+
pub trait Group
32+
where
33+
// `VoprfClientLen`, `PoprfClientLen`, `VoprfServerLen`, `PoprfServerLen`
34+
Self::ScalarLen: Add<Self::ElemLen>,
35+
Sum<Self::ScalarLen, Self::ElemLen>: ArrayLength<u8>,
36+
// `ProofLen`
37+
Self::ScalarLen: Add<Self::ScalarLen>,
38+
Sum<Self::ScalarLen, Self::ScalarLen>: ArrayLength<u8>,
39+
{
3240
/// The type of group elements
3341
type Elem: ConstantTimeEq
3442
+ Copy

0 commit comments

Comments
 (0)