ECVRF

Struct ECVRF 

Source
pub struct ECVRF { /* private fields */ }

Implementations§

Source§

impl ECVRF

Source

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
Source

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 point
  • alpha_string: value to be hashed, an octet string
§Returns:
  • a finite EC point in G
Source

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
Source

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 BigNum representing the nonce.
Source

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 BigNum integer (0 < x < 2^(8n) - 1) representing the hash of points truncated to length n, if successful.
Source

pub fn derive_public_key_point( &mut self, private_key: &BigNum, ) -> Result<EcPoint, Error>

Function to derive public key point given a private key.

§Arguments
  • private_key: a BigNum representing the private key
§Returns:
  • an EcPoint representing the public key, if successful
Source

pub fn derive_public_key( &mut self, private_key: &[u8], ) -> Result<Vec<u8>, Error>

Function to derive public key given a private key.

§Arguments
  • private_key: a slice of octets representing the private key
§Returns:
  • an slice of octets representing the public key, if successful
Source

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: an EcPoint
  • c: integer between 0 and 2 ^ (8n) - 1
  • s: integer between 0 and 2 ^ (8qlen) - 1

Trait Implementations§

Source§

impl ECVRF<&[u8], &[u8]> for ECVRF

Source§

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 key
  • alpha_string: octet string message represented by a slice
§Returns:
  • if successful, a vector of octets representing the proof pi_string
Source§

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
Source§

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 octets
  • alpha_string: VRF hash input, an octet string
  • pi_string: proof to be verified, an octet string
§Returns:
  • if successful, a vector of octets with the VRF hash output
Source§

type Error = Error

Auto Trait Implementations§

§

impl Freeze for ECVRF

§

impl RefUnwindSafe for ECVRF

§

impl Send for ECVRF

§

impl Sync for ECVRF

§

impl Unpin for ECVRF

§

impl UnwindSafe for ECVRF

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.