Exposing the derive_key() function under the danger feature (#73)
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
# Changelog
|
# 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)
|
## 0.4.0-pre.1 (April 1, 2022)
|
||||||
* Updated to be in sync with draft-irtf-cfrg-voprf-09, with
|
* Updated to be in sync with draft-irtf-cfrg-voprf-09, with
|
||||||
the addition of the POPRF mode
|
the addition of the POPRF mode
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@ 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.57"
|
||||||
version = "0.4.0-pre.1"
|
version = "0.4.0-pre.2"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
alloc = []
|
alloc = []
|
||||||
|
|||||||
@@ -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.0-pre.1"
|
voprf = "0.4.0-pre.2"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Minimum Supported Rust Version
|
### Minimum Supported Rust Version
|
||||||
|
|||||||
+16
-2
@@ -356,7 +356,7 @@ where
|
|||||||
/////////////////////
|
/////////////////////
|
||||||
|
|
||||||
/// Can only fail with [`Error::DeriveKeyPair`] and [`Error::Protocol`].
|
/// Can only fail with [`Error::DeriveKeyPair`] and [`Error::Protocol`].
|
||||||
pub(crate) fn derive_key<CS: CipherSuite>(
|
pub(crate) fn derive_key_internal<CS: CipherSuite>(
|
||||||
seed: &[u8],
|
seed: &[u8],
|
||||||
info: &[u8],
|
info: &[u8],
|
||||||
mode: Mode,
|
mode: Mode,
|
||||||
@@ -388,6 +388,20 @@ where
|
|||||||
Err(Error::Protocol)
|
Err(Error::Protocol)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Can only fail with [`Error::DeriveKeyPair`] and [`Error::Protocol`].
|
||||||
|
#[cfg(feature = "danger")]
|
||||||
|
pub fn derive_key<CS: CipherSuite>(
|
||||||
|
seed: &[u8],
|
||||||
|
info: &[u8],
|
||||||
|
mode: Mode,
|
||||||
|
) -> Result<<CS::Group as Group>::Scalar, Error>
|
||||||
|
where
|
||||||
|
<CS::Hash as OutputSizeUser>::OutputSize:
|
||||||
|
IsLess<U256> + IsLessOrEqual<<CS::Hash as BlockSizeUser>::BlockSize>,
|
||||||
|
{
|
||||||
|
derive_key_internal::<CS>(seed, info, mode)
|
||||||
|
}
|
||||||
|
|
||||||
type DeriveKeypairResult<CS> = (
|
type DeriveKeypairResult<CS> = (
|
||||||
<<CS as CipherSuite>::Group as Group>::Scalar,
|
<<CS as CipherSuite>::Group as Group>::Scalar,
|
||||||
<<CS as CipherSuite>::Group as Group>::Elem,
|
<<CS as CipherSuite>::Group as Group>::Elem,
|
||||||
@@ -403,7 +417,7 @@ where
|
|||||||
<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 sk_s = derive_key::<CS>(seed, info, mode)?;
|
let sk_s = derive_key_internal::<CS>(seed, info, mode)?;
|
||||||
let pk_s = CS::Group::base_elem() * &sk_s;
|
let pk_s = CS::Group::base_elem() * &sk_s;
|
||||||
|
|
||||||
Ok((sk_s, pk_s))
|
Ok((sk_s, pk_s))
|
||||||
|
|||||||
@@ -500,6 +500,8 @@ mod tests;
|
|||||||
// Exports
|
// Exports
|
||||||
|
|
||||||
pub use crate::ciphersuite::CipherSuite;
|
pub use crate::ciphersuite::CipherSuite;
|
||||||
|
#[cfg(feature = "danger")]
|
||||||
|
pub use crate::common::derive_key;
|
||||||
pub use crate::common::{
|
pub use crate::common::{
|
||||||
BlindedElement, EvaluationElement, Mode, PreparedEvaluationElement, Proof,
|
BlindedElement, EvaluationElement, Mode, PreparedEvaluationElement, Proof,
|
||||||
};
|
};
|
||||||
|
|||||||
+3
-3
@@ -17,8 +17,8 @@ use generic_array::GenericArray;
|
|||||||
use rand_core::{CryptoRng, RngCore};
|
use rand_core::{CryptoRng, RngCore};
|
||||||
|
|
||||||
use crate::common::{
|
use crate::common::{
|
||||||
derive_key, deterministic_blind_unchecked, i2osp_2, BlindedElement, EvaluationElement, Mode,
|
derive_key_internal, deterministic_blind_unchecked, i2osp_2, BlindedElement, EvaluationElement,
|
||||||
STR_FINALIZE,
|
Mode, STR_FINALIZE,
|
||||||
};
|
};
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
use crate::serialization::serde::Scalar;
|
use crate::serialization::serde::Scalar;
|
||||||
@@ -189,7 +189,7 @@ where
|
|||||||
/// then `u16::MAX - 3`.
|
/// then `u16::MAX - 3`.
|
||||||
/// - [`Error::Protocol`] if the protocol fails and can't be completed.
|
/// - [`Error::Protocol`] if the protocol fails and can't be completed.
|
||||||
pub fn new_from_seed(seed: &[u8], info: &[u8]) -> Result<Self> {
|
pub fn new_from_seed(seed: &[u8], info: &[u8]) -> Result<Self> {
|
||||||
let sk = derive_key::<CS>(seed, info, Mode::Oprf)?;
|
let sk = derive_key_internal::<CS>(seed, info, Mode::Oprf)?;
|
||||||
Ok(Self { sk })
|
Ok(Self { sk })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user