Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
40d81294db | ||
|
|
8363d26f6f | ||
|
|
5bce3e3206 | ||
|
|
2787151e1d | ||
|
|
0409db6f40 | ||
|
|
74eaebe446 | ||
|
|
c8de51672b | ||
|
|
daa8dc048f | ||
|
|
2a351ceb4d | ||
|
|
8f60a10b8d | ||
|
|
1691125b09 | ||
|
|
6913b5deaa |
@@ -35,8 +35,7 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
backend_feature:
|
backend_feature:
|
||||||
- --features ristretto255-ciphersuite,ristretto255-u64
|
- --features ristretto255-ciphersuite
|
||||||
- --features ristretto255-ciphersuite,ristretto255-u32
|
|
||||||
-
|
-
|
||||||
frontend_feature:
|
frontend_feature:
|
||||||
-
|
-
|
||||||
@@ -44,7 +43,7 @@ jobs:
|
|||||||
- --features serde
|
- --features serde
|
||||||
toolchain:
|
toolchain:
|
||||||
- stable
|
- stable
|
||||||
- 1.57.0
|
- 1.60.0
|
||||||
name: test
|
name: test
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
@@ -75,6 +74,12 @@ jobs:
|
|||||||
command: test
|
command: test
|
||||||
args: --no-default-features ${{ matrix.frontend_feature }},std ${{ matrix.backend_feature }}
|
args: --no-default-features ${{ matrix.frontend_feature }},std ${{ matrix.backend_feature }}
|
||||||
|
|
||||||
|
- name: Run cargo test with all features enabled
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: test
|
||||||
|
args: --all-features
|
||||||
|
|
||||||
build-no-std:
|
build-no-std:
|
||||||
name: Build with no-std on ${{ matrix.target }}
|
name: Build with no-std on ${{ matrix.target }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -88,8 +93,7 @@ jobs:
|
|||||||
- thumbv6m-none-eabi
|
- thumbv6m-none-eabi
|
||||||
backend_feature:
|
backend_feature:
|
||||||
-
|
-
|
||||||
- --features ristretto255-ciphersuite,ristretto255-u64
|
- --features ristretto255-ciphersuite
|
||||||
- --features ristretto255-ciphersuite,ristretto255-u32
|
|
||||||
frontend_feature:
|
frontend_feature:
|
||||||
-
|
-
|
||||||
- --features danger
|
- --features danger
|
||||||
@@ -120,7 +124,7 @@ jobs:
|
|||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: clippy
|
command: clippy
|
||||||
args: --all-targets -- -D warnings
|
args: --all-features --all-targets -- -D warnings
|
||||||
|
|
||||||
- name: Run cargo doc
|
- name: Run cargo doc
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 0.5.0-pre.2 (February 3, 2023)
|
||||||
|
* Increased MSRV to 1.60
|
||||||
|
* Updated p256 dependency to v0.12
|
||||||
|
* Updated curve25519-dalek dependency to 4.0.0-rc.1
|
||||||
|
|
||||||
|
## 0.5.0-pre.1 (December 19, 2022)
|
||||||
|
* Updated curve25519-dalek dependency to 4.0.0-pre.5
|
||||||
|
|
||||||
## 0.4.0 (September 15, 2022)
|
## 0.4.0 (September 15, 2022)
|
||||||
* Updated to be in sync with draft-irtf-cfrg-voprf-11, with
|
* Updated to be in sync with draft-irtf-cfrg-voprf-11, with
|
||||||
the addition of the POPRF mode
|
the addition of the POPRF mode
|
||||||
|
|||||||
+15
-16
@@ -8,25 +8,23 @@ license = "MIT"
|
|||||||
name = "voprf"
|
name = "voprf"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
repository = "https://github.com/novifinancial/voprf/"
|
repository = "https://github.com/novifinancial/voprf/"
|
||||||
rust-version = "1.57"
|
rust-version = "1.60"
|
||||||
version = "0.4.0"
|
version = "0.5.0-pre.2"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
alloc = []
|
alloc = []
|
||||||
danger = []
|
danger = []
|
||||||
default = ["ristretto255-ciphersuite", "ristretto255-u64", "serde"]
|
default = ["ristretto255-ciphersuite", "dep:serde"]
|
||||||
ristretto255 = ["curve25519-dalek", "generic-array/more_lengths"]
|
ristretto255 = ["dep:curve25519-dalek", "generic-array/more_lengths"]
|
||||||
ristretto255-ciphersuite = ["ristretto255", "sha2"]
|
ristretto255-ciphersuite = ["ristretto255", "dep:sha2"]
|
||||||
ristretto255-fiat-u32 = ["curve25519-dalek/fiat_u32_backend", "ristretto255"]
|
serde = ["generic-array/serde", "dep:serde"]
|
||||||
ristretto255-fiat-u64 = ["curve25519-dalek/fiat_u64_backend", "ristretto255"]
|
|
||||||
ristretto255-simd = ["curve25519-dalek/simd_backend", "ristretto255"]
|
|
||||||
ristretto255-u32 = ["curve25519-dalek/u32_backend", "ristretto255"]
|
|
||||||
ristretto255-u64 = ["curve25519-dalek/u64_backend", "ristretto255"]
|
|
||||||
serde = ["generic-array/serde", "serde_"]
|
|
||||||
std = ["alloc"]
|
std = ["alloc"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
curve25519-dalek = { version = "=4.0.0-pre.1", default-features = false, optional = true }
|
curve25519-dalek = { version = "=4.0.0-rc.1", default-features = false, features = [
|
||||||
|
"rand_core",
|
||||||
|
"zeroize",
|
||||||
|
], optional = true }
|
||||||
derive-where = { version = "1", features = ["zeroize-on-drop"] }
|
derive-where = { version = "1", features = ["zeroize-on-drop"] }
|
||||||
digest = "0.10"
|
digest = "0.10"
|
||||||
displaydoc = { version = "0.2", default-features = false }
|
displaydoc = { version = "0.2", default-features = false }
|
||||||
@@ -37,7 +35,7 @@ elliptic-curve = { version = "0.12", features = [
|
|||||||
] }
|
] }
|
||||||
generic-array = "0.14"
|
generic-array = "0.14"
|
||||||
rand_core = { version = "0.6", default-features = false }
|
rand_core = { version = "0.6", default-features = false }
|
||||||
serde_ = { version = "1", package = "serde", default-features = false, features = [
|
serde = { version = "1", default-features = false, features = [
|
||||||
"derive",
|
"derive",
|
||||||
], optional = true }
|
], optional = true }
|
||||||
sha2 = { version = "0.10", default-features = false, optional = true }
|
sha2 = { version = "0.10", default-features = false, optional = true }
|
||||||
@@ -47,16 +45,17 @@ zeroize = { version = "1.5", default-features = false }
|
|||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
generic-array = { version = "0.14", features = ["more_lengths"] }
|
generic-array = { version = "0.14", features = ["more_lengths"] }
|
||||||
hex = "0.4"
|
hex = "0.4"
|
||||||
json = "0.12"
|
p256 = { version = "0.12", default-features = false, features = [
|
||||||
p256 = { version = "0.11", default-features = false, features = [
|
|
||||||
"hash2curve",
|
"hash2curve",
|
||||||
"voprf",
|
"voprf",
|
||||||
] }
|
] }
|
||||||
proptest = "1"
|
proptest = "1"
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
regex = "1"
|
regex = "1"
|
||||||
|
serde_json = "1"
|
||||||
sha2 = "0.10"
|
sha2 = "0.10"
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
features = ["danger", "std"]
|
all-features = true
|
||||||
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
targets = []
|
targets = []
|
||||||
|
|||||||
@@ -16,12 +16,12 @@ Installation
|
|||||||
Add the following line to the dependencies of your `Cargo.toml`:
|
Add the following line to the dependencies of your `Cargo.toml`:
|
||||||
|
|
||||||
```
|
```
|
||||||
voprf = "0.4"
|
voprf = "0.5.0-pre.2"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Minimum Supported Rust Version
|
### Minimum Supported Rust Version
|
||||||
|
|
||||||
Rust **1.57** or higher.
|
Rust **1.60** or higher.
|
||||||
|
|
||||||
Contributors
|
Contributors
|
||||||
------------
|
------------
|
||||||
|
|||||||
+11
-6
@@ -72,7 +72,7 @@ impl Mode {
|
|||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serde",
|
feature = "serde",
|
||||||
derive(serde::Deserialize, serde::Serialize),
|
derive(serde::Deserialize, serde::Serialize),
|
||||||
serde(crate = "serde", bound = "")
|
serde(bound = "")
|
||||||
)]
|
)]
|
||||||
pub struct BlindedElement<CS: CipherSuite>(
|
pub struct BlindedElement<CS: CipherSuite>(
|
||||||
#[cfg_attr(feature = "serde", serde(with = "Element::<CS::Group>"))]
|
#[cfg_attr(feature = "serde", serde(with = "Element::<CS::Group>"))]
|
||||||
@@ -89,7 +89,7 @@ where
|
|||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serde",
|
feature = "serde",
|
||||||
derive(serde::Deserialize, serde::Serialize),
|
derive(serde::Deserialize, serde::Serialize),
|
||||||
serde(crate = "serde", bound = "")
|
serde(bound = "")
|
||||||
)]
|
)]
|
||||||
pub struct EvaluationElement<CS: CipherSuite>(
|
pub struct EvaluationElement<CS: CipherSuite>(
|
||||||
#[cfg_attr(feature = "serde", serde(with = "Element::<CS::Group>"))]
|
#[cfg_attr(feature = "serde", serde(with = "Element::<CS::Group>"))]
|
||||||
@@ -106,7 +106,7 @@ where
|
|||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serde",
|
feature = "serde",
|
||||||
derive(serde::Deserialize, serde::Serialize),
|
derive(serde::Deserialize, serde::Serialize),
|
||||||
serde(crate = "serde", bound = "")
|
serde(bound = "")
|
||||||
)]
|
)]
|
||||||
pub struct PreparedEvaluationElement<CS: CipherSuite>(pub(crate) EvaluationElement<CS>)
|
pub struct PreparedEvaluationElement<CS: CipherSuite>(pub(crate) EvaluationElement<CS>)
|
||||||
where
|
where
|
||||||
@@ -120,7 +120,7 @@ where
|
|||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serde",
|
feature = "serde",
|
||||||
derive(serde::Deserialize, serde::Serialize),
|
derive(serde::Deserialize, serde::Serialize),
|
||||||
serde(crate = "serde", bound = "")
|
serde(bound = "")
|
||||||
)]
|
)]
|
||||||
pub struct Proof<CS: CipherSuite>
|
pub struct Proof<CS: CipherSuite>
|
||||||
where
|
where
|
||||||
@@ -302,7 +302,7 @@ where
|
|||||||
// I2OSP(len(seedDST), 2) || seedDST
|
// I2OSP(len(seedDST), 2) || seedDST
|
||||||
// seed = Hash(h1Input)
|
// seed = Hash(h1Input)
|
||||||
let seed = CS::Hash::new()
|
let seed = CS::Hash::new()
|
||||||
.chain_update(&elem_len)
|
.chain_update(elem_len)
|
||||||
.chain_update(CS::Group::serialize_elem(b))
|
.chain_update(CS::Group::serialize_elem(b))
|
||||||
.chain_update(i2osp_2_array(&seed_dst))
|
.chain_update(i2osp_2_array(&seed_dst))
|
||||||
.chain_update(seed_dst)
|
.chain_update(seed_dst)
|
||||||
@@ -388,7 +388,12 @@ where
|
|||||||
Err(Error::Protocol)
|
Err(Error::Protocol)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Can only fail with [`Error::DeriveKeyPair`] and [`Error::Protocol`].
|
/// Corresponds to DeriveKeyPair() function from the VOPRF specification.
|
||||||
|
///
|
||||||
|
/// # Errors
|
||||||
|
/// - [`Error::DeriveKeyPair`] if the `input` and `seed` together are longer
|
||||||
|
/// then `u16::MAX - 3`.
|
||||||
|
/// - [`Error::Protocol`] if the protocol fails and can't be completed.
|
||||||
#[cfg(feature = "danger")]
|
#[cfg(feature = "danger")]
|
||||||
pub fn derive_key<CS: CipherSuite>(
|
pub fn derive_key<CS: CipherSuite>(
|
||||||
seed: &[u8],
|
seed: &[u8],
|
||||||
|
|||||||
+6
-13
@@ -22,8 +22,6 @@ use crate::{Error, InternalError, Result};
|
|||||||
|
|
||||||
/// [`Group`] implementation for Ristretto255.
|
/// [`Group`] implementation for Ristretto255.
|
||||||
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
||||||
// `cfg` here is only needed because of a bug in Rust's crate feature documentation. See: https://github.com/rust-lang/rust/issues/83428
|
|
||||||
#[cfg(feature = "ristretto255")]
|
|
||||||
pub struct Ristretto255;
|
pub struct Ristretto255;
|
||||||
|
|
||||||
#[cfg(feature = "ristretto255-ciphersuite")]
|
#[cfg(feature = "ristretto255-ciphersuite")]
|
||||||
@@ -35,8 +33,6 @@ impl crate::CipherSuite for Ristretto255 {
|
|||||||
type Hash = sha2::Sha512;
|
type Hash = sha2::Sha512;
|
||||||
}
|
}
|
||||||
|
|
||||||
// `cfg` here is only needed because of a bug in Rust's crate feature documentation. See: https://github.com/rust-lang/rust/issues/83428
|
|
||||||
#[cfg(feature = "ristretto255")]
|
|
||||||
impl Group for Ristretto255 {
|
impl Group for Ristretto255 {
|
||||||
type Elem = RistrettoPoint;
|
type Elem = RistrettoPoint;
|
||||||
|
|
||||||
@@ -90,11 +86,8 @@ impl Group for Ristretto255 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn deserialize_elem(element_bits: &[u8]) -> Result<Self::Elem> {
|
fn deserialize_elem(element_bits: &[u8]) -> Result<Self::Elem> {
|
||||||
if element_bits.len() != 32 {
|
|
||||||
return Err(Error::Deserialization);
|
|
||||||
}
|
|
||||||
|
|
||||||
CompressedRistretto::from_slice(element_bits)
|
CompressedRistretto::from_slice(element_bits)
|
||||||
|
.map_err(|_| Error::Deserialization)?
|
||||||
.decompress()
|
.decompress()
|
||||||
.filter(|point| point != &RistrettoPoint::identity())
|
.filter(|point| point != &RistrettoPoint::identity())
|
||||||
.ok_or(Error::Deserialization)
|
.ok_or(Error::Deserialization)
|
||||||
@@ -104,7 +97,7 @@ impl Group for Ristretto255 {
|
|||||||
loop {
|
loop {
|
||||||
let scalar = Scalar::random(rng);
|
let scalar = Scalar::random(rng);
|
||||||
|
|
||||||
if scalar != Scalar::zero() {
|
if scalar != Scalar::ZERO {
|
||||||
break scalar;
|
break scalar;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -115,12 +108,12 @@ impl Group for Ristretto255 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn is_zero_scalar(scalar: Self::Scalar) -> subtle::Choice {
|
fn is_zero_scalar(scalar: Self::Scalar) -> subtle::Choice {
|
||||||
scalar.ct_eq(&Scalar::zero())
|
scalar.ct_eq(&Scalar::ZERO)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
fn zero_scalar() -> Self::Scalar {
|
fn zero_scalar() -> Self::Scalar {
|
||||||
Scalar::zero()
|
Scalar::ZERO
|
||||||
}
|
}
|
||||||
|
|
||||||
fn serialize_scalar(scalar: Self::Scalar) -> GenericArray<u8, Self::ScalarLen> {
|
fn serialize_scalar(scalar: Self::Scalar) -> GenericArray<u8, Self::ScalarLen> {
|
||||||
@@ -131,8 +124,8 @@ impl Group for Ristretto255 {
|
|||||||
scalar_bits
|
scalar_bits
|
||||||
.try_into()
|
.try_into()
|
||||||
.ok()
|
.ok()
|
||||||
.and_then(Scalar::from_canonical_bytes)
|
.and_then(|bytes| Scalar::from_canonical_bytes(bytes).into())
|
||||||
.filter(|scalar| scalar != &Scalar::zero())
|
.filter(|scalar| scalar != &Scalar::ZERO)
|
||||||
.ok_or(Error::Deserialization)
|
.ok_or(Error::Deserialization)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-17
@@ -532,24 +532,15 @@
|
|||||||
//! a [`CipherSuite`].
|
//! a [`CipherSuite`].
|
||||||
//!
|
//!
|
||||||
//! - The `ristretto255` feature enables using [`Ristretto255`] as the
|
//! - The `ristretto255` feature enables using [`Ristretto255`] as the
|
||||||
//! underlying group for the [Group] choice. A backend feature, which are
|
//! underlying group for the [Group] choice. To select a specific backend see
|
||||||
//! re-exported from [curve25519-dalek] and allow for selecting the
|
//! the [curve25519-dalek] documentation.
|
||||||
//! corresponding backend for the curve arithmetic used, has to be selected,
|
|
||||||
//! otherwise compilation will fail. The `ristretto255-u64` feature is
|
|
||||||
//! included as the default. Other features are mapped as `ristretto255-u32`,
|
|
||||||
//! `ristretto255-fiat-u64` and `ristretto255-fiat-u32`. Any `ristretto255-*`
|
|
||||||
//! backend feature will enable the `ristretto255` feature.
|
|
||||||
//!
|
|
||||||
//! - The `ristretto255-simd` feature is re-exported from [curve25519-dalek] and
|
|
||||||
//! enables parallel formulas, using either AVX2 or AVX512-IFMA. This will
|
|
||||||
//! automatically enable the `ristretto255-u64` feature and requires Rust
|
|
||||||
//! nightly.
|
|
||||||
//!
|
//!
|
||||||
//! [curve25519-dalek]:
|
//! [curve25519-dalek]:
|
||||||
//! (https://doc.dalek.rs/curve25519_dalek/index.html#backends-and-features)
|
//! (https://docs.rs/curve25519-dalek/4.0.0-pre.5/curve25519_dalek/index.html#backends)
|
||||||
|
|
||||||
#![cfg_attr(not(test), deny(unsafe_code))]
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
||||||
|
#![cfg_attr(not(test), deny(unsafe_code))]
|
||||||
#![warn(
|
#![warn(
|
||||||
clippy::cargo,
|
clippy::cargo,
|
||||||
clippy::missing_errors_doc,
|
clippy::missing_errors_doc,
|
||||||
@@ -564,9 +555,6 @@ extern crate alloc;
|
|||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
extern crate std;
|
extern crate std;
|
||||||
|
|
||||||
#[cfg(feature = "serde")]
|
|
||||||
extern crate serde_ as serde;
|
|
||||||
|
|
||||||
mod ciphersuite;
|
mod ciphersuite;
|
||||||
mod common;
|
mod common;
|
||||||
mod error;
|
mod error;
|
||||||
|
|||||||
+3
-3
@@ -41,7 +41,7 @@ use crate::{CipherSuite, Error, Group, Result};
|
|||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serde",
|
feature = "serde",
|
||||||
derive(serde::Deserialize, serde::Serialize),
|
derive(serde::Deserialize, serde::Serialize),
|
||||||
serde(crate = "serde", bound = "")
|
serde(bound = "")
|
||||||
)]
|
)]
|
||||||
pub struct OprfClient<CS: CipherSuite>
|
pub struct OprfClient<CS: CipherSuite>
|
||||||
where
|
where
|
||||||
@@ -59,7 +59,7 @@ where
|
|||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serde",
|
feature = "serde",
|
||||||
derive(serde::Deserialize, serde::Serialize),
|
derive(serde::Deserialize, serde::Serialize),
|
||||||
serde(crate = "serde", bound = "")
|
serde(bound = "")
|
||||||
)]
|
)]
|
||||||
pub struct OprfServer<CS: CipherSuite>
|
pub struct OprfServer<CS: CipherSuite>
|
||||||
where
|
where
|
||||||
@@ -277,7 +277,7 @@ where
|
|||||||
.chain_update(input.as_ref())
|
.chain_update(input.as_ref())
|
||||||
.chain_update(elem_len)
|
.chain_update(elem_len)
|
||||||
.chain_update(CS::Group::serialize_elem(unblinded_element))
|
.chain_update(CS::Group::serialize_elem(unblinded_element))
|
||||||
.chain_update(&STR_FINALIZE)
|
.chain_update(STR_FINALIZE)
|
||||||
.finalize())
|
.finalize())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -41,7 +41,7 @@ use crate::{CipherSuite, Error, Group, Result};
|
|||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serde",
|
feature = "serde",
|
||||||
derive(serde::Deserialize, serde::Serialize),
|
derive(serde::Deserialize, serde::Serialize),
|
||||||
serde(crate = "serde", bound = "")
|
serde(bound = "")
|
||||||
)]
|
)]
|
||||||
pub struct PoprfClient<CS: CipherSuite>
|
pub struct PoprfClient<CS: CipherSuite>
|
||||||
where
|
where
|
||||||
@@ -61,7 +61,7 @@ where
|
|||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serde",
|
feature = "serde",
|
||||||
derive(serde::Deserialize, serde::Serialize),
|
derive(serde::Deserialize, serde::Serialize),
|
||||||
serde(crate = "serde", bound = "")
|
serde(bound = "")
|
||||||
)]
|
)]
|
||||||
pub struct PoprfServer<CS: CipherSuite>
|
pub struct PoprfServer<CS: CipherSuite>
|
||||||
where
|
where
|
||||||
@@ -541,7 +541,7 @@ pub type PoprfServerBatchEvaluatePreparedEvaluationElements<CS, I> = Map<
|
|||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serde",
|
feature = "serde",
|
||||||
derive(serde::Deserialize, serde::Serialize),
|
derive(serde::Deserialize, serde::Serialize),
|
||||||
serde(crate = "serde", bound = "")
|
serde(bound = "")
|
||||||
)]
|
)]
|
||||||
pub struct PoprfPreparedTweak<CS: CipherSuite>(
|
pub struct PoprfPreparedTweak<CS: CipherSuite>(
|
||||||
#[cfg_attr(feature = "serde", serde(with = "Scalar::<CS::Group>"))]
|
#[cfg_attr(feature = "serde", serde(with = "Scalar::<CS::Group>"))]
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ impl RngCore for CycleRng {
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn fill_bytes(&mut self, dest: &mut [u8]) {
|
fn fill_bytes(&mut self, dest: &mut [u8]) {
|
||||||
let len = min(self.v.len(), dest.len());
|
let len = min(self.v.len(), dest.len());
|
||||||
(&mut dest[..len]).copy_from_slice(&self.v[..len]);
|
dest[..len].copy_from_slice(&self.v[..len]);
|
||||||
rotate_left(&mut self.v, len);
|
rotate_left(&mut self.v, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -96,7 +96,7 @@ fn parse_params(input: &str) -> String {
|
|||||||
let key = iter.next().unwrap().split_whitespace().next().unwrap();
|
let key = iter.next().unwrap().split_whitespace().next().unwrap();
|
||||||
let val = iter.next().unwrap().split_whitespace().next().unwrap();
|
let val = iter.next().unwrap().split_whitespace().next().unwrap();
|
||||||
|
|
||||||
param = format!(" \"{}\": \"{}", key, val);
|
param = format!(" \"{key}\": \"{val}");
|
||||||
} else {
|
} else {
|
||||||
let s = line.trim().to_string();
|
let s = line.trim().to_string();
|
||||||
if s.contains('~') || s.contains('#') {
|
if s.contains('~') || s.contains('#') {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use digest::core_api::BlockSizeUser;
|
|||||||
use digest::OutputSizeUser;
|
use digest::OutputSizeUser;
|
||||||
use generic_array::typenum::{IsLess, IsLessOrEqual, Sum, U256};
|
use generic_array::typenum::{IsLess, IsLessOrEqual, Sum, U256};
|
||||||
use generic_array::ArrayLength;
|
use generic_array::ArrayLength;
|
||||||
use json::JsonValue;
|
use serde_json::Value;
|
||||||
|
|
||||||
use crate::tests::mock_rng::CycleRng;
|
use crate::tests::mock_rng::CycleRng;
|
||||||
use crate::tests::parser::*;
|
use crate::tests::parser::*;
|
||||||
@@ -40,7 +40,7 @@ struct VOPRFTestVectorParameters {
|
|||||||
output: Vec<Vec<u8>>,
|
output: Vec<Vec<u8>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn populate_test_vectors(values: &JsonValue) -> VOPRFTestVectorParameters {
|
fn populate_test_vectors(values: &Value) -> VOPRFTestVectorParameters {
|
||||||
VOPRFTestVectorParameters {
|
VOPRFTestVectorParameters {
|
||||||
seed: decode(values, "Seed"),
|
seed: decode(values, "Seed"),
|
||||||
sksm: decode(values, "skSm"),
|
sksm: decode(values, "skSm"),
|
||||||
@@ -57,18 +57,18 @@ fn populate_test_vectors(values: &JsonValue) -> VOPRFTestVectorParameters {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn decode(values: &JsonValue, key: &str) -> Vec<u8> {
|
fn decode(values: &Value, key: &str) -> Vec<u8> {
|
||||||
values[key]
|
values[key]
|
||||||
.as_str()
|
.as_str()
|
||||||
.and_then(|s| hex::decode(&s).ok())
|
.and_then(|s| hex::decode(s).ok())
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn decode_vec(values: &JsonValue, key: &str) -> Vec<Vec<u8>> {
|
fn decode_vec(values: &Value, key: &str) -> Vec<Vec<u8>> {
|
||||||
let s = values[key].as_str().unwrap();
|
let s = values[key].as_str().unwrap();
|
||||||
let res = match s.contains(',') {
|
let res = match s.contains(',') {
|
||||||
true => Some(s.split(',').map(|x| hex::decode(&x).unwrap()).collect()),
|
true => Some(s.split(',').map(|x| hex::decode(x).unwrap()).collect()),
|
||||||
false => Some(vec![hex::decode(&s).unwrap()]),
|
false => Some(vec![hex::decode(s).unwrap()]),
|
||||||
};
|
};
|
||||||
res.unwrap()
|
res.unwrap()
|
||||||
}
|
}
|
||||||
@@ -76,8 +76,10 @@ fn decode_vec(values: &JsonValue, key: &str) -> Vec<Vec<u8>> {
|
|||||||
macro_rules! json_to_test_vectors {
|
macro_rules! json_to_test_vectors {
|
||||||
( $v:ident, $cs:expr, $mode:expr ) => {
|
( $v:ident, $cs:expr, $mode:expr ) => {
|
||||||
$v[$cs][$mode]
|
$v[$cs][$mode]
|
||||||
.members()
|
.as_array()
|
||||||
.map(|x| populate_test_vectors(&x))
|
.into_iter()
|
||||||
|
.flatten()
|
||||||
|
.map(populate_test_vectors)
|
||||||
.collect::<Vec<VOPRFTestVectorParameters>>()
|
.collect::<Vec<VOPRFTestVectorParameters>>()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -86,7 +88,7 @@ macro_rules! json_to_test_vectors {
|
|||||||
fn test_vectors() -> Result<()> {
|
fn test_vectors() -> Result<()> {
|
||||||
use p256::NistP256;
|
use p256::NistP256;
|
||||||
|
|
||||||
let rfc = json::parse(rfc_to_json(super::cfrg_vectors::VECTORS).as_str())
|
let rfc: Value = serde_json::from_str(rfc_to_json(super::cfrg_vectors::VECTORS).as_str())
|
||||||
.expect("Could not parse json");
|
.expect("Could not parse json");
|
||||||
|
|
||||||
#[cfg(feature = "ristretto255")]
|
#[cfg(feature = "ristretto255")]
|
||||||
|
|||||||
+2
-2
@@ -39,7 +39,7 @@ use crate::{CipherSuite, Error, Group, Result};
|
|||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serde",
|
feature = "serde",
|
||||||
derive(serde::Deserialize, serde::Serialize),
|
derive(serde::Deserialize, serde::Serialize),
|
||||||
serde(crate = "serde", bound = "")
|
serde(bound = "")
|
||||||
)]
|
)]
|
||||||
pub struct VoprfClient<CS: CipherSuite>
|
pub struct VoprfClient<CS: CipherSuite>
|
||||||
where
|
where
|
||||||
@@ -59,7 +59,7 @@ where
|
|||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serde",
|
feature = "serde",
|
||||||
derive(serde::Deserialize, serde::Serialize),
|
derive(serde::Deserialize, serde::Serialize),
|
||||||
serde(crate = "serde", bound = "")
|
serde(bound = "")
|
||||||
)]
|
)]
|
||||||
pub struct VoprfServer<CS: CipherSuite>
|
pub struct VoprfServer<CS: CipherSuite>
|
||||||
where
|
where
|
||||||
|
|||||||
Reference in New Issue
Block a user