Compare commits

..
23 Commits
Author SHA1 Message Date
Kevin LewiandGitHub ee91c9776c Publishing v0.5.0-pre.6 (#118) 2023-07-24 20:45:18 -07:00
daxpeddaandGitHub 0fdfdfdaee Bump curve25519-dalek to v4 (#116) 2023-07-24 16:39:40 -07:00
Kevin LewiandGitHub eafa134c94 Publishing v0.5.0-pre.5 (#115) 2023-06-27 15:10:37 -07:00
daxpeddaandGitHub 209b957ae4 Bump curve25519-dalek to v4.0.0-rc.3 (#113) 2023-06-26 11:09:06 -07:00
Kevin LewiandGitHub f79ebf9844 Updating dual-license language (#110) 2023-05-22 23:04:39 -07:00
Kevin LewiandGitHub 20a35da7ba Publishing 0.5.0-pre.4 (#109) 2023-05-21 00:29:21 -07:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
4bd2cf466e Update curve25519-dalek requirement from =4.0.0-rc.1 to =4.0.0-rc.2 (#108)
Updates the requirements on [curve25519-dalek](https://github.com/dalek-cryptography/curve25519-dalek) to permit the latest version.
- [Release notes](https://github.com/dalek-cryptography/curve25519-dalek/releases)
- [Changelog](https://github.com/dalek-cryptography/curve25519-dalek/blob/main/CHANGELOG.md)
- [Commits](https://github.com/dalek-cryptography/curve25519-dalek/compare/4.0.0-rc.1...4.0.0-rc.2)

---
updated-dependencies:
- dependency-name: curve25519-dalek
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-04-02 11:21:28 +09:00
Kevin LewiandGitHub 829c6add0f Publishing 0.5.0-pre.3 (#107) 2023-03-04 15:09:02 -08:00
daxpeddaandGitHub 8b895cc631 Update RustCrypto dependencies to v0.13 (#106) 2023-03-04 14:54:13 -08:00
daxpeddaandGitHub 83eb78b232 Test P-384 (#84) 2023-02-08 15:48:12 -08:00
daxpeddaandGitHub 5badeff8d2 Update to draft 19 (#101) 2023-02-08 00:18:04 -08:00
Kevin LewiandGitHub 40d81294db Publishing 0.5.0-pre.2 (#104) 2023-02-03 13:26:11 -08:00
daxpeddaandGitHub 8363d26f6f Bump curve25519-dalek to v4.0.0-rc.1 (#102) 2023-02-03 11:19:00 -08:00
daxpeddaandGitHub 5bce3e3206 Use explicit crate features (#100) 2023-02-01 11:37:47 -08:00
daxpeddaandGitHub 2787151e1d Update curve25519-dalek (#94) 2023-01-31 14:19:48 -08:00
daxpeddaandGitHub 0409db6f40 Depend on ProjectivePoint: ToEncodedPoint (#95) 2023-01-31 14:19:33 -08:00
daxpeddaandGitHub 74eaebe446 Fix Clippy (#96) 2023-01-31 10:31:13 -08:00
daxpeddaandGitHub c8de51672b Replace json with serde_json (#92) 2023-01-19 14:17:49 -08:00
daxpeddaandGitHub daa8dc048f Upgrade p256 to v0.12 (#90)
* Upgrade `p256` to v0.12

* Upgrade MSRV to 1.60
2023-01-19 11:11:56 -08:00
Kevin LewiandGitHub 2a351ceb4d Publishing 0.5.0-pre.1 (#88) 2022-12-19 13:17:58 -08:00
Kevin LewiandGitHub 8f60a10b8d Adding all-features CI test (#87) 2022-12-17 18:20:57 -08:00
daxpeddaandGitHub 1691125b09 Update curve25519-dalek to 4.0.0-pre.5 (#86)
* Update `curve25519-dalek`

* Improve documentation
2022-12-17 18:12:23 -08:00
daxpeddaandGitHub 6913b5deaa Fix Clippy (#85) 2022-12-10 14:21:04 -08:00
16 changed files with 957 additions and 1017 deletions
+11 -12
View File
@@ -3,9 +3,8 @@ on:
push: push:
branches: branches:
- main - main
- v0.4
pull_request: pull_request:
types: [opened, reopened, synchronize] types: [opened, repoened, synchronize]
jobs: jobs:
cargo-audit: cargo-audit:
@@ -13,7 +12,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Cache cargo-audit - name: Cache cargo-audit
uses: actions/cache@v4 uses: actions/cache@v3
with: with:
path: | path: |
~/.cargo/.crates.toml ~/.cargo/.crates.toml
@@ -25,7 +24,7 @@ jobs:
run: cargo install cargo-audit run: cargo install cargo-audit
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Run cargo audit - name: Run cargo audit
run: cargo audit -D warnings run: cargo audit -D warnings
@@ -48,7 +47,7 @@ jobs:
name: test name: test
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Install ${{ matrix.toolchain }} toolchain - name: Install ${{ matrix.toolchain }} toolchain
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
@@ -100,8 +99,8 @@ jobs:
- --features danger - --features danger
- --features serde - --features serde
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- uses: hecrj/setup-rust-action@v2 - uses: hecrj/setup-rust-action@v1
- run: rustup target add ${{ matrix.target }} - run: rustup target add ${{ matrix.target }}
- run: cargo build --verbose --target=${{ matrix.target }} --no-default-features ${{ matrix.frontend_feature }} ${{ matrix.backend_feature }} - run: cargo build --verbose --target=${{ matrix.target }} --no-default-features ${{ matrix.frontend_feature }} ${{ matrix.backend_feature }}
@@ -111,7 +110,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Install stable toolchain - name: Install stable toolchain
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
@@ -141,7 +140,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Install nightly toolchain - name: Install nightly toolchain
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
@@ -162,7 +161,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Cache - name: Cache
uses: actions/cache@v4 uses: actions/cache@v3
with: with:
path: | path: |
~/.cargo/.crates.toml ~/.cargo/.crates.toml
@@ -171,10 +170,10 @@ jobs:
key: taplo key: taplo
- name: Install Taplo - name: Install Taplo
run: cargo install taplo-cli --locked run: cargo install taplo-cli
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Run Taplo - name: Run Taplo
run: taplo fmt --check run: taplo fmt --check
+1 -2
View File
@@ -10,10 +10,9 @@ jobs:
strategy: strategy:
matrix: matrix:
os: [ubuntu-latest] os: [ubuntu-latest]
rust: [stable]
steps: steps:
- uses: hecrj/setup-rust-action@v2 - uses: hecrj/setup-rust-action@v1
with: with:
rust-version: ${{ matrix.rust }} rust-version: ${{ matrix.rust }}
- uses: actions/checkout@master - uses: actions/checkout@master
-4
View File
@@ -8,7 +8,3 @@ Cargo.lock
# These are backup files generated by rustfmt # These are backup files generated by rustfmt
**/*.rs.bk **/*.rs.bk
# Editors
.idea
.vscode
+22 -4
View File
@@ -1,9 +1,27 @@
# Changelog # Changelog
## 0.4.1 (September 24, 2024) ## 0.5.0-pre.6 (July 24, 2023)
* Backport all non-protocol-breaking changes from versions 0.5+ * Updated curve25519-dalek dependency to 4
* Fixes Rust 1.81+ compatibility, compatible with 0.4.0 (draft 11), incompatible with 0.5+ (final RFC)
* Updated dependencies ## 0.5.0-pre.5 (June 27, 2023)
* Updated curve25519-dalek dependency to 4.0.0-rc.3
## 0.5.0-pre.4 (May 20, 2023)
* Updated curve25519-dalek dependency to 4.0.0-rc.2
## 0.5.0-pre.3 (March 4, 2023)
* Updated to be in sync with draft-irtf-cfrg-voprf-19
* Increased MSRV to 1.65
* Updated p256 dependency to v0.13
* Added p384 tests
## 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
+3 -7
View File
@@ -9,7 +9,7 @@ name = "voprf"
readme = "README.md" readme = "README.md"
repository = "https://github.com/facebook/voprf/" repository = "https://github.com/facebook/voprf/"
rust-version = "1.65" rust-version = "1.65"
version = "0.4.1" version = "0.5.0-pre.6"
[features] [features]
alloc = [] alloc = []
@@ -39,8 +39,8 @@ 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 }
subtle = { version = "2.6", default-features = false } subtle = { version = "2.3", default-features = false }
zeroize = { version = "1.8", default-features = false } 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"] }
@@ -53,10 +53,6 @@ p384 = { version = "0.13", default-features = false, features = [
"hash2curve", "hash2curve",
"voprf", "voprf",
] } ] }
p521 = { version = "0.13.3", default-features = false, features = [
"hash2curve",
"voprf",
] }
proptest = "1" proptest = "1"
rand = "0.8" rand = "0.8"
regex = "1" regex = "1"
+2 -2
View File
@@ -1,4 +1,4 @@
# voprf ![Build Status](https://github.com/facebook/voprf/workflows/Rust%20CI/badge.svg) # voprf ![Build Status](https://github.com/novifinancial/voprf/workflows/Rust%20CI/badge.svg)
An implementation of a (verifiable) oblivious pseudorandom function (VOPRF) An implementation of a (verifiable) oblivious pseudorandom function (VOPRF)
A VOPRF is a verifiable oblivious pseudorandom function, a protocol between a client and a server. The regular (non-verifiable) OPRF is also supported in this implementation. A VOPRF is a verifiable oblivious pseudorandom function, a protocol between a client and a server. The regular (non-verifiable) OPRF is also supported in this implementation.
@@ -16,7 +16,7 @@ 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.1" voprf = "0.5.0-pre.6"
``` ```
### Minimum Supported Rust Version ### Minimum Supported Rust Version
+17 -23
View File
@@ -35,7 +35,7 @@ pub(crate) const STR_DERIVE_KEYPAIR: [u8; 13] = *b"DeriveKeyPair";
pub(crate) const STR_COMPOSITE: [u8; 9] = *b"Composite"; pub(crate) const STR_COMPOSITE: [u8; 9] = *b"Composite";
pub(crate) const STR_CHALLENGE: [u8; 9] = *b"Challenge"; pub(crate) const STR_CHALLENGE: [u8; 9] = *b"Challenge";
pub(crate) const STR_INFO: [u8; 4] = *b"Info"; pub(crate) const STR_INFO: [u8; 4] = *b"Info";
pub(crate) const STR_VOPRF: [u8; 8] = *b"VOPRF10-"; pub(crate) const STR_OPRF: [u8; 7] = *b"OPRFV1-";
pub(crate) const STR_HASH_TO_SCALAR: [u8; 13] = *b"HashToScalar-"; pub(crate) const STR_HASH_TO_SCALAR: [u8; 13] = *b"HashToScalar-";
pub(crate) const STR_HASH_TO_GROUP: [u8; 12] = *b"HashToGroup-"; pub(crate) const STR_HASH_TO_GROUP: [u8; 12] = *b"HashToGroup-";
@@ -147,8 +147,8 @@ pub(crate) fn generate_proof<CS: CipherSuite, R: RngCore + CryptoRng>(
k: <CS::Group as Group>::Scalar, k: <CS::Group as Group>::Scalar,
a: <CS::Group as Group>::Elem, a: <CS::Group as Group>::Elem,
b: <CS::Group as Group>::Elem, b: <CS::Group as Group>::Elem,
cs: impl ExactSizeIterator<Item = <CS::Group as Group>::Elem>, cs: impl Iterator<Item = <CS::Group as Group>::Elem> + ExactSizeIterator,
ds: impl ExactSizeIterator<Item = <CS::Group as Group>::Elem>, ds: impl Iterator<Item = <CS::Group as Group>::Elem> + ExactSizeIterator,
mode: Mode, mode: Mode,
) -> Result<Proof<CS>> ) -> Result<Proof<CS>>
where where
@@ -209,8 +209,8 @@ where
pub(crate) fn verify_proof<CS: CipherSuite>( pub(crate) fn verify_proof<CS: CipherSuite>(
a: <CS::Group as Group>::Elem, a: <CS::Group as Group>::Elem,
b: <CS::Group as Group>::Elem, b: <CS::Group as Group>::Elem,
cs: impl ExactSizeIterator<Item = <CS::Group as Group>::Elem>, cs: impl Iterator<Item = <CS::Group as Group>::Elem> + ExactSizeIterator,
ds: impl ExactSizeIterator<Item = <CS::Group as Group>::Elem>, ds: impl Iterator<Item = <CS::Group as Group>::Elem> + ExactSizeIterator,
proof: &Proof<CS>, proof: &Proof<CS>,
mode: Mode, mode: Mode,
) -> Result<()> ) -> Result<()>
@@ -500,37 +500,29 @@ where
pub(crate) struct Dst<L: ArrayLength<u8>> { pub(crate) struct Dst<L: ArrayLength<u8>> {
dst_1: GenericArray<u8, L>, dst_1: GenericArray<u8, L>,
dst_2: [u8; 2], dst_2: &'static str,
} }
impl<L: ArrayLength<u8>> Dst<L> { impl<L: ArrayLength<u8>> Dst<L> {
pub(crate) fn new<CS: CipherSuite, T, TL>(par_1: T, mode: Mode) -> Self pub(crate) fn new<CS: CipherSuite, T, TL: ArrayLength<u8>>(par_1: T, mode: Mode) -> Self
where where
T: Into<GenericArray<u8, TL>>, T: Into<GenericArray<u8, TL>>,
TL: ArrayLength<u8> + Add<U9, Output = L>, TL: Add<U9, Output = L>,
<CS::Hash as OutputSizeUser>::OutputSize: <CS::Hash as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<CS::Hash as BlockSizeUser>::BlockSize>, IsLess<U256> + IsLessOrEqual<<CS::Hash as BlockSizeUser>::BlockSize>,
{ {
let par_1 = par_1.into(); let par_1 = par_1.into();
// Generates the contextString parameter as defined in // Generates the contextString parameter as defined in
// <https://datatracker.ietf.org/doc/draft-irtf-cfrg-voprf/> // <https://datatracker.ietf.org/doc/draft-irtf-cfrg-voprf/>
let par_2 = GenericArray::from(STR_VOPRF).concat([mode.to_u8()].into()); let par_2 = GenericArray::from(STR_OPRF)
.concat([mode.to_u8()].into())
// See <https://www.ietf.org/archive/id/draft-irtf-cfrg-voprf-11.html#section-4.1> .concat([b'-'].into());
let cs_id_u16: u16 = match CS::ID {
"ristretto255-SHA512" => 0x0001,
"decaf448-SHAKE256" => 0x0002,
"P256-SHA256" => 0x0003,
"P384-SHA384" => 0x0004,
"P521-SHA512" => 0x0005,
_ => panic!("Incompatible ciphersuite: {}", CS::ID),
};
let dst_1 = par_1.concat(par_2); let dst_1 = par_1.concat(par_2);
let dst_2 = cs_id_u16.to_be_bytes(); let dst_2 = CS::ID;
assert!( assert!(
L::USIZE + 2 <= u16::MAX.into(), L::USIZE + dst_2.len() <= u16::MAX.into(),
"constructed DST longer then {}", "constructed DST longer then {}",
u16::MAX u16::MAX
); );
@@ -539,11 +531,13 @@ impl<L: ArrayLength<u8>> Dst<L> {
} }
pub(crate) fn as_dst(&self) -> [&[u8]; 2] { pub(crate) fn as_dst(&self) -> [&[u8]; 2] {
[&self.dst_1, &self.dst_2] [&self.dst_1, self.dst_2.as_bytes()]
} }
pub(crate) fn i2osp_2(&self) -> [u8; 2] { pub(crate) fn i2osp_2(&self) -> [u8; 2] {
u16::try_from(L::USIZE + 2).unwrap().to_be_bytes() u16::try_from(L::USIZE + self.dst_2.len())
.unwrap()
.to_be_bytes()
} }
} }
-4
View File
@@ -17,7 +17,6 @@ use crate::{Error, Group, Result};
fn test_group_properties() -> Result<()> { fn test_group_properties() -> Result<()> {
use p256::NistP256; use p256::NistP256;
use p384::NistP384; use p384::NistP384;
use p521::NistP521;
#[cfg(feature = "ristretto255")] #[cfg(feature = "ristretto255")]
{ {
@@ -33,9 +32,6 @@ fn test_group_properties() -> Result<()> {
test_identity_element_error::<NistP384>()?; test_identity_element_error::<NistP384>()?;
test_zero_scalar_error::<NistP384>()?; test_zero_scalar_error::<NistP384>()?;
test_identity_element_error::<NistP521>()?;
test_zero_scalar_error::<NistP521>()?;
Ok(()) Ok(())
} }
+1 -1
View File
@@ -9,7 +9,7 @@
//! An implementation of a verifiable oblivious pseudorandom function (VOPRF) //! An implementation of a verifiable oblivious pseudorandom function (VOPRF)
//! //!
//! Note: This implementation is in sync with //! Note: This implementation is in sync with
//! [draft-irtf-cfrg-voprf-11](https://www.ietf.org/archive/id/draft-irtf-cfrg-voprf-11.html), //! [draft-irtf-cfrg-voprf-19](https://www.ietf.org/archive/id/draft-irtf-cfrg-voprf-19.html),
//! but this specification is subject to change, until the final version //! but this specification is subject to change, until the final version
//! published by the IETF. //! published by the IETF.
//! //!
-8
View File
@@ -427,7 +427,6 @@ mod tests {
fn test_functionality() -> Result<()> { fn test_functionality() -> Result<()> {
use p256::NistP256; use p256::NistP256;
use p384::NistP384; use p384::NistP384;
use p521::NistP521;
#[cfg(feature = "ristretto255")] #[cfg(feature = "ristretto255")]
{ {
@@ -455,13 +454,6 @@ mod tests {
zeroize_oprf_client::<NistP384>(); zeroize_oprf_client::<NistP384>();
zeroize_oprf_server::<NistP384>(); zeroize_oprf_server::<NistP384>();
base_retrieval::<NistP521>();
base_inversion_unsalted::<NistP521>();
server_evaluate::<NistP521>();
zeroize_oprf_client::<NistP521>();
zeroize_oprf_server::<NistP521>();
Ok(()) Ok(())
} }
} }
+1 -9
View File
@@ -720,7 +720,7 @@ where
)?; )?;
Ok(blinds Ok(blinds
.zip(messages) .zip(messages.into_iter())
.map(|(blind, x)| x.0 * &CS::Group::invert_scalar(blind))) .map(|(blind, x)| x.0 * &CS::Group::invert_scalar(blind)))
} }
@@ -967,7 +967,6 @@ mod tests {
fn test_functionality() -> Result<()> { fn test_functionality() -> Result<()> {
use p256::NistP256; use p256::NistP256;
use p384::NistP384; use p384::NistP384;
use p521::NistP521;
#[cfg(feature = "ristretto255")] #[cfg(feature = "ristretto255")]
{ {
@@ -995,13 +994,6 @@ mod tests {
zeroize_verifiable_client::<NistP384>(); zeroize_verifiable_client::<NistP384>();
zeroize_verifiable_server::<NistP384>(); zeroize_verifiable_server::<NistP384>();
verifiable_retrieval::<NistP521>();
verifiable_bad_public_key::<NistP521>();
verifiable_server_evaluate::<NistP521>();
zeroize_verifiable_client::<NistP521>();
zeroize_verifiable_server::<NistP521>();
Ok(()) Ok(())
} }
} }
+2 -3
View File
@@ -307,11 +307,11 @@ fn deserialize_scalar<G: Group>(input: &mut &[u8]) -> Result<G::Scalar> {
} }
trait SliceExt { trait SliceExt {
fn take_ext<'a>(self: &mut &'a Self, take: usize) -> Option<&'a Self>; fn take_ext(self: &mut &Self, take: usize) -> Option<&Self>;
} }
impl<T> SliceExt for [T] { impl<T> SliceExt for [T] {
fn take_ext<'a>(self: &mut &'a Self, take: usize) -> Option<&'a Self> { fn take_ext(self: &mut &Self, take: usize) -> Option<&Self> {
if take > self.len() { if take > self.len() {
return None; return None;
} }
@@ -391,7 +391,6 @@ mod test {
let _ = $item::<p256::NistP256>::deserialize(&$bytes[..]); let _ = $item::<p256::NistP256>::deserialize(&$bytes[..]);
let _ = $item::<p384::NistP384>::deserialize(&$bytes[..]); let _ = $item::<p384::NistP384>::deserialize(&$bytes[..]);
let _ = $item::<p521::NistP521>::deserialize(&$bytes[..]);
}; };
} }
+884 -887
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -15,7 +15,7 @@ pub(crate) fn rfc_to_json(input: &str) -> String {
} }
fn parse_ciphersuites(input: &str) -> String { fn parse_ciphersuites(input: &str) -> String {
let re = regex::Regex::new(r"## OPRF\((?P<ciphersuite>.+?)\)").unwrap(); let re = regex::Regex::new(r"\n## (?P<ciphersuite>.+?)\n").unwrap();
let mut ciphersuites = vec![]; let mut ciphersuites = vec![];
let chunks: Vec<&str> = re.split(input).collect(); let chunks: Vec<&str> = re.split(input).collect();
+9 -37
View File
@@ -89,7 +89,6 @@ macro_rules! json_to_test_vectors {
fn test_vectors() -> Result<()> { fn test_vectors() -> Result<()> {
use p256::NistP256; use p256::NistP256;
use p384::NistP384; use p384::NistP384;
use p521::NistP521;
let rfc: Value = serde_json::from_str(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");
@@ -100,7 +99,7 @@ fn test_vectors() -> Result<()> {
let ristretto_oprf_tvs = json_to_test_vectors!( let ristretto_oprf_tvs = json_to_test_vectors!(
rfc, rfc,
String::from("ristretto255, SHA-512"), String::from("ristretto255-SHA512"),
String::from("OPRF") String::from("OPRF")
); );
assert_ne!(ristretto_oprf_tvs.len(), 0); assert_ne!(ristretto_oprf_tvs.len(), 0);
@@ -112,7 +111,7 @@ fn test_vectors() -> Result<()> {
let ristretto_voprf_tvs = json_to_test_vectors!( let ristretto_voprf_tvs = json_to_test_vectors!(
rfc, rfc,
String::from("ristretto255, SHA-512"), String::from("ristretto255-SHA512"),
String::from("VOPRF") String::from("VOPRF")
); );
assert_ne!(ristretto_voprf_tvs.len(), 0); assert_ne!(ristretto_voprf_tvs.len(), 0);
@@ -124,7 +123,7 @@ fn test_vectors() -> Result<()> {
let ristretto_poprf_tvs = json_to_test_vectors!( let ristretto_poprf_tvs = json_to_test_vectors!(
rfc, rfc,
String::from("ristretto255, SHA-512"), String::from("ristretto255-SHA512"),
String::from("POPRF") String::from("POPRF")
); );
assert_ne!(ristretto_poprf_tvs.len(), 0); assert_ne!(ristretto_poprf_tvs.len(), 0);
@@ -136,7 +135,7 @@ fn test_vectors() -> Result<()> {
} }
let p256_oprf_tvs = let p256_oprf_tvs =
json_to_test_vectors!(rfc, String::from("P-256, SHA-256"), String::from("OPRF")); json_to_test_vectors!(rfc, String::from("P256-SHA256"), String::from("OPRF"));
assert_ne!(p256_oprf_tvs.len(), 0); assert_ne!(p256_oprf_tvs.len(), 0);
test_oprf_seed_to_key::<NistP256>(&p256_oprf_tvs)?; test_oprf_seed_to_key::<NistP256>(&p256_oprf_tvs)?;
test_oprf_blind::<NistP256>(&p256_oprf_tvs)?; test_oprf_blind::<NistP256>(&p256_oprf_tvs)?;
@@ -145,7 +144,7 @@ fn test_vectors() -> Result<()> {
test_oprf_evaluate::<NistP256>(&p256_oprf_tvs)?; test_oprf_evaluate::<NistP256>(&p256_oprf_tvs)?;
let p256_voprf_tvs = let p256_voprf_tvs =
json_to_test_vectors!(rfc, String::from("P-256, SHA-256"), String::from("VOPRF")); json_to_test_vectors!(rfc, String::from("P256-SHA256"), String::from("VOPRF"));
assert_ne!(p256_voprf_tvs.len(), 0); assert_ne!(p256_voprf_tvs.len(), 0);
test_voprf_seed_to_key::<NistP256>(&p256_voprf_tvs)?; test_voprf_seed_to_key::<NistP256>(&p256_voprf_tvs)?;
test_voprf_blind::<NistP256>(&p256_voprf_tvs)?; test_voprf_blind::<NistP256>(&p256_voprf_tvs)?;
@@ -154,7 +153,7 @@ fn test_vectors() -> Result<()> {
test_voprf_evaluate::<NistP256>(&p256_voprf_tvs)?; test_voprf_evaluate::<NistP256>(&p256_voprf_tvs)?;
let p256_poprf_tvs = let p256_poprf_tvs =
json_to_test_vectors!(rfc, String::from("P-256, SHA-256"), String::from("POPRF")); json_to_test_vectors!(rfc, String::from("P256-SHA256"), String::from("POPRF"));
assert_ne!(p256_poprf_tvs.len(), 0); assert_ne!(p256_poprf_tvs.len(), 0);
test_poprf_seed_to_key::<NistP256>(&p256_poprf_tvs)?; test_poprf_seed_to_key::<NistP256>(&p256_poprf_tvs)?;
test_poprf_blind::<NistP256>(&p256_poprf_tvs)?; test_poprf_blind::<NistP256>(&p256_poprf_tvs)?;
@@ -163,7 +162,7 @@ fn test_vectors() -> Result<()> {
test_poprf_evaluate::<NistP256>(&p256_poprf_tvs)?; test_poprf_evaluate::<NistP256>(&p256_poprf_tvs)?;
let p384_oprf_tvs = let p384_oprf_tvs =
json_to_test_vectors!(rfc, String::from("P-384, SHA-384"), String::from("OPRF")); json_to_test_vectors!(rfc, String::from("P384-SHA384"), String::from("OPRF"));
assert_ne!(p384_oprf_tvs.len(), 0); assert_ne!(p384_oprf_tvs.len(), 0);
test_oprf_seed_to_key::<NistP384>(&p384_oprf_tvs)?; test_oprf_seed_to_key::<NistP384>(&p384_oprf_tvs)?;
test_oprf_blind::<NistP384>(&p384_oprf_tvs)?; test_oprf_blind::<NistP384>(&p384_oprf_tvs)?;
@@ -172,7 +171,7 @@ fn test_vectors() -> Result<()> {
test_oprf_evaluate::<NistP384>(&p384_oprf_tvs)?; test_oprf_evaluate::<NistP384>(&p384_oprf_tvs)?;
let p384_voprf_tvs = let p384_voprf_tvs =
json_to_test_vectors!(rfc, String::from("P-384, SHA-384"), String::from("VOPRF")); json_to_test_vectors!(rfc, String::from("P384-SHA384"), String::from("VOPRF"));
assert_ne!(p384_voprf_tvs.len(), 0); assert_ne!(p384_voprf_tvs.len(), 0);
test_voprf_seed_to_key::<NistP384>(&p384_voprf_tvs)?; test_voprf_seed_to_key::<NistP384>(&p384_voprf_tvs)?;
test_voprf_blind::<NistP384>(&p384_voprf_tvs)?; test_voprf_blind::<NistP384>(&p384_voprf_tvs)?;
@@ -181,7 +180,7 @@ fn test_vectors() -> Result<()> {
test_voprf_evaluate::<NistP384>(&p384_voprf_tvs)?; test_voprf_evaluate::<NistP384>(&p384_voprf_tvs)?;
let p384_poprf_tvs = let p384_poprf_tvs =
json_to_test_vectors!(rfc, String::from("P-384, SHA-384"), String::from("POPRF")); json_to_test_vectors!(rfc, String::from("P384-SHA384"), String::from("POPRF"));
assert_ne!(p384_poprf_tvs.len(), 0); assert_ne!(p384_poprf_tvs.len(), 0);
test_poprf_seed_to_key::<NistP384>(&p384_poprf_tvs)?; test_poprf_seed_to_key::<NistP384>(&p384_poprf_tvs)?;
test_poprf_blind::<NistP384>(&p384_poprf_tvs)?; test_poprf_blind::<NistP384>(&p384_poprf_tvs)?;
@@ -189,33 +188,6 @@ fn test_vectors() -> Result<()> {
test_poprf_finalize::<NistP384>(&p384_poprf_tvs)?; test_poprf_finalize::<NistP384>(&p384_poprf_tvs)?;
test_poprf_evaluate::<NistP384>(&p384_poprf_tvs)?; test_poprf_evaluate::<NistP384>(&p384_poprf_tvs)?;
let p521_oprf_tvs =
json_to_test_vectors!(rfc, String::from("P-521, SHA-512"), String::from("OPRF"));
assert_ne!(p521_oprf_tvs.len(), 0);
test_oprf_seed_to_key::<NistP521>(&p521_oprf_tvs)?;
test_oprf_blind::<NistP521>(&p521_oprf_tvs)?;
test_oprf_blind_evaluate::<NistP521>(&p521_oprf_tvs)?;
test_oprf_finalize::<NistP521>(&p521_oprf_tvs)?;
test_oprf_evaluate::<NistP521>(&p521_oprf_tvs)?;
let p521_voprf_tvs =
json_to_test_vectors!(rfc, String::from("P-521, SHA-512"), String::from("VOPRF"));
assert_ne!(p521_voprf_tvs.len(), 0);
test_voprf_seed_to_key::<NistP521>(&p521_voprf_tvs)?;
test_voprf_blind::<NistP521>(&p521_voprf_tvs)?;
test_voprf_blind_evaluate::<NistP521>(&p521_voprf_tvs)?;
test_voprf_finalize::<NistP521>(&p521_voprf_tvs)?;
test_voprf_evaluate::<NistP521>(&p521_voprf_tvs)?;
let p521_poprf_tvs =
json_to_test_vectors!(rfc, String::from("P-521, SHA-512"), String::from("POPRF"));
assert_ne!(p521_poprf_tvs.len(), 0);
test_poprf_seed_to_key::<NistP521>(&p521_poprf_tvs)?;
test_poprf_blind::<NistP521>(&p521_poprf_tvs)?;
test_poprf_blind_evaluate::<NistP521>(&p521_poprf_tvs)?;
test_poprf_finalize::<NistP521>(&p521_poprf_tvs)?;
test_poprf_evaluate::<NistP521>(&p521_poprf_tvs)?;
Ok(()) Ok(())
} }
+3 -13
View File
@@ -161,7 +161,7 @@ where
/// ///
/// The resulting messages can each fail individually with [`Error::Input`] /// The resulting messages can each fail individually with [`Error::Input`]
/// if the `input` is empty or longer then [`u16::MAX`]. /// if the `input` is empty or longer then [`u16::MAX`].
pub fn batch_finalize<'a, I, II, IC, IM>( pub fn batch_finalize<'a, I: 'a, II, IC, IM>(
inputs: &'a II, inputs: &'a II,
clients: &'a IC, clients: &'a IC,
messages: &'a IM, messages: &'a IM,
@@ -170,7 +170,7 @@ where
) -> Result<VoprfClientBatchFinalizeResult<'a, CS, I, II, IC, IM>> ) -> Result<VoprfClientBatchFinalizeResult<'a, CS, I, II, IC, IM>>
where where
CS: 'a, CS: 'a,
I: 'a + AsRef<[u8]>, I: AsRef<[u8]>,
&'a II: 'a + IntoIterator<Item = I>, &'a II: 'a + IntoIterator<Item = I>,
<&'a II as IntoIterator>::IntoIter: ExactSizeIterator, <&'a II as IntoIterator>::IntoIter: ExactSizeIterator,
&'a IC: 'a + IntoIterator<Item = &'a VoprfClient<CS>>, &'a IC: 'a + IntoIterator<Item = &'a VoprfClient<CS>>,
@@ -537,7 +537,7 @@ where
)?; )?;
Ok(blinds Ok(blinds
.zip(messages) .zip(messages.into_iter())
.map(|(blind, x)| x.0 * &CS::Group::invert_scalar(blind))) .map(|(blind, x)| x.0 * &CS::Group::invert_scalar(blind)))
} }
@@ -836,7 +836,6 @@ mod tests {
fn test_functionality() -> Result<()> { fn test_functionality() -> Result<()> {
use p256::NistP256; use p256::NistP256;
use p384::NistP384; use p384::NistP384;
use p521::NistP521;
#[cfg(feature = "ristretto255")] #[cfg(feature = "ristretto255")]
{ {
@@ -870,15 +869,6 @@ mod tests {
zeroize_voprf_client::<NistP384>(); zeroize_voprf_client::<NistP384>();
zeroize_voprf_server::<NistP384>(); zeroize_voprf_server::<NistP384>();
verifiable_retrieval::<NistP521>();
verifiable_batch_retrieval::<NistP521>();
verifiable_bad_public_key::<NistP521>();
verifiable_batch_bad_public_key::<NistP521>();
verifiable_server_evaluate::<NistP521>();
zeroize_voprf_client::<NistP521>();
zeroize_voprf_server::<NistP521>();
Ok(()) Ok(())
} }
} }