pub struct ECVRF { /* private fields */ }Implementations
sourceimpl ECVRF
impl ECVRF
sourcepub fn from_suite(suite: CipherSuite) -> Result<Self, Error>
pub fn from_suite(suite: CipherSuite) -> Result<Self, Error>
Associated function to initialize a ECVRF structure with an initialized context for the given cipher suite.
Arguments:
suite: Identifying ciphersuite
Returns:
- a ECVRF struct if successful
sourcepub fn hash_to_try_and_increment(
&mut self,
public_key: &EcPoint,
alpha_string: &[u8]
) -> Result<EcPoint, Error>
pub fn hash_to_try_and_increment(
&mut self,
public_key: &EcPoint,
alpha_string: &[u8]
) -> Result<EcPoint, Error>
ECVRF_hash_to_curve implementation as specified in Section 5.4.1.1 [VRF-draft-05]
Arguments
public_key: an Elliptical Curve pointalpha_string: value to be hashed, an octet string
Returns:
- a finite EC point in G
sourcepub fn arbitrary_string_to_point(
&mut self,
data: &[u8]
) -> Result<EcPoint, Error>
pub fn arbitrary_string_to_point(
&mut self,
data: &[u8]
) -> Result<EcPoint, Error>
Converts an arbitrary string to a point in the curve as specified in Section 5.5 [VRF-draft-05]
Arguments
data: a 32 octet string to be converted to a point
returns an EcPoint representing the converted point if successful
sourcepub fn generate_nonce(
&mut self,
secret_key: &BigNum,
data: &[u8]
) -> Result<BigNum, Error>
pub fn generate_nonce(
&mut self,
secret_key: &BigNum,
data: &[u8]
) -> Result<BigNum, Error>
Generates a nonce deterministically from the algorithm specified in Section 3.2 RFC6979
Arguments
secret key: a BigNum representing the secret key.data: a slice of octets representing the message
Returns:
- a
BigNumrepresenting the nonce.
sourcepub fn hash_points(&mut self, points: &[&EcPoint]) -> Result<BigNum, Error>
pub fn hash_points(&mut self, points: &[&EcPoint]) -> Result<BigNum, Error>
Hashes a slice of EC points to a BigNum integer as specified in Section 5.4.3 [VRF-draft-05]
Arguments
points: a slice of points that need to be hashed
Returns:
- a
BigNuminteger (0 < x < 2^(8n) - 1) representing the hash of points truncated to lengthn, if successful.
sourcepub fn decode_proof(
&mut self,
pi_string: &[u8]
) -> Result<(EcPoint, BigNum, BigNum), Error>
pub fn decode_proof(
&mut self,
pi_string: &[u8]
) -> Result<(EcPoint, BigNum, BigNum), Error>
Function to decode a proof pi_string produced by EC_prove, to (gamma, c, s) as specified in
Section 5.4.4 [VRF-draft-05]
Arguments
pi_string: a slice of octets representing the generated proof
Returns
gamma: anEcPointc: integer between 0 and 2 ^ (8n) - 1s: integer between 0 and 2 ^ (8qlen) - 1
Trait Implementations
sourceimpl ECVRF<&[u8], &[u8]> for ECVRF
impl ECVRF<&[u8], &[u8]> for ECVRF
sourcefn prove(&mut self, pkey: &[u8], alpha_string: &[u8]) -> Result<Vec<u8>, Error>
fn prove(&mut self, pkey: &[u8], alpha_string: &[u8]) -> Result<Vec<u8>, Error>
Generates proof from a private key and a message as specified in Section 5.1 [VRF-draft-05]
Arguments:
pkey: a private keyalpha_string: octet string message represented by a slice
Returns:
- if successful, a vector of octets representing the proof
pi_string
sourcefn proof_to_hash(&mut self, pi_string: &[u8]) -> Result<Vec<u8>, Error>
fn proof_to_hash(&mut self, pi_string: &[u8]) -> Result<Vec<u8>, Error>
Generates ECVRF hash output from the provided proof
Arguments:
pi_string: generated ECVRF proof
Returns
beta_string: the ECVRF hash output
sourcefn verify(
&mut self,
public_key: &[u8],
alpha_string: &[u8],
pi_string: &[u8]
) -> Result<Vec<u8>, Error>
fn verify(
&mut self,
public_key: &[u8],
alpha_string: &[u8],
pi_string: &[u8]
) -> Result<Vec<u8>, Error>
Verifies the provided VRF proof and computes the VRF hash output
Arguments:
public_key: a slice representing the public key in octetsalpha_string: VRF hash input, an octet stringpi_string: proof to be verified, an octet string
Returns:
- if successful, a vector of octets with the VRF hash output