diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a8aa98..4a7b162 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 0.4.0-pre.2 (April 5, 2022) +* Exposes the derive_key function under the "danger" feature + ## 0.4.0-pre.1 (April 1, 2022) * Updated to be in sync with draft-irtf-cfrg-voprf-09, with the addition of the POPRF mode diff --git a/Cargo.toml b/Cargo.toml index 0ced17d..84b8c0f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ name = "voprf" readme = "README.md" repository = "https://github.com/novifinancial/voprf/" rust-version = "1.57" -version = "0.4.0-pre.1" +version = "0.4.0-pre.2" [features] alloc = [] diff --git a/README.md b/README.md index d076ebe..f2b565b 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Installation Add the following line to the dependencies of your `Cargo.toml`: ``` -voprf = "0.4.0-pre.1" +voprf = "0.4.0-pre.2" ``` ### Minimum Supported Rust Version diff --git a/src/common.rs b/src/common.rs index 628a700..88000f4 100644 --- a/src/common.rs +++ b/src/common.rs @@ -356,7 +356,7 @@ where ///////////////////// /// Can only fail with [`Error::DeriveKeyPair`] and [`Error::Protocol`]. -pub(crate) fn derive_key( +pub(crate) fn derive_key_internal( seed: &[u8], info: &[u8], mode: Mode, @@ -388,6 +388,20 @@ where Err(Error::Protocol) } +/// Can only fail with [`Error::DeriveKeyPair`] and [`Error::Protocol`]. +#[cfg(feature = "danger")] +pub fn derive_key( + seed: &[u8], + info: &[u8], + mode: Mode, +) -> Result<::Scalar, Error> +where + ::OutputSize: + IsLess + IsLessOrEqual<::BlockSize>, +{ + derive_key_internal::(seed, info, mode) +} + type DeriveKeypairResult = ( <::Group as Group>::Scalar, <::Group as Group>::Elem, @@ -403,7 +417,7 @@ where ::OutputSize: IsLess + IsLessOrEqual<::BlockSize>, { - let sk_s = derive_key::(seed, info, mode)?; + let sk_s = derive_key_internal::(seed, info, mode)?; let pk_s = CS::Group::base_elem() * &sk_s; Ok((sk_s, pk_s)) diff --git a/src/lib.rs b/src/lib.rs index 659787b..4fbb998 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -500,6 +500,8 @@ mod tests; // Exports pub use crate::ciphersuite::CipherSuite; +#[cfg(feature = "danger")] +pub use crate::common::derive_key; pub use crate::common::{ BlindedElement, EvaluationElement, Mode, PreparedEvaluationElement, Proof, }; diff --git a/src/oprf.rs b/src/oprf.rs index 48bff0d..f6e23d9 100644 --- a/src/oprf.rs +++ b/src/oprf.rs @@ -17,8 +17,8 @@ use generic_array::GenericArray; use rand_core::{CryptoRng, RngCore}; use crate::common::{ - derive_key, deterministic_blind_unchecked, i2osp_2, BlindedElement, EvaluationElement, Mode, - STR_FINALIZE, + derive_key_internal, deterministic_blind_unchecked, i2osp_2, BlindedElement, EvaluationElement, + Mode, STR_FINALIZE, }; #[cfg(feature = "serde")] use crate::serialization::serde::Scalar; @@ -189,7 +189,7 @@ where /// then `u16::MAX - 3`. /// - [`Error::Protocol`] if the protocol fails and can't be completed. pub fn new_from_seed(seed: &[u8], info: &[u8]) -> Result { - let sk = derive_key::(seed, info, Mode::Oprf)?; + let sk = derive_key_internal::(seed, info, Mode::Oprf)?; Ok(Self { sk }) }