VrfStruct

Struct VrfStruct 

Source
pub struct VrfStruct<Curve, Hasher> {
    pub curve: Curve,
    pub hasher: Hasher,
    pub suite_id: u8,
}

Fields§

§curve: Curve§hasher: Hasher§suite_id: u8

ECVRF suite string as specific by RFC9381

Implementations§

Source§

impl<C, D> VrfStruct<C, D>

Source

pub const fn cofactor(&self) -> Scalar<C>

Curve cofactor, i.e., number of points on EC divided by prime order of group G.

Source§

impl<C, D> VrfStruct<C, D>

Source

pub fn prove(&self, secret_key: &[u8], alpha: &[u8]) -> Result<Vec<u8>>

Generates a VRF proof from a secret key and message. Spec: ECVRF_prove function (section 5.1).

§Arguments
  • x - A slice representing the secret key in octets.
  • alpha - A slice representing the message in octets.
§Returns
  • If successful, a vector of octets representing the proof of the VRF.
Source

pub fn verify( &self, public_key: &[u8], pi: &[u8], alpha: &[u8], ) -> Result<GenericArray<u8, C::FieldBytesSize>>

Verifies the provided VRF proof and computes the VRF hash output. Spec: ECVRF_verify function (section 5.2).

§Arguments
  • y - A slice representing the public key in octets.
  • pi - A slice of octets representing the VRF proof.
  • alpha - A slice containing the input data, to be hashed.
§Returns
  • If successful, a vector of octets with the VRF hash output.
Source

pub fn proof_to_hash( &self, pi: &[u8], ) -> Result<GenericArray<u8, C::FieldBytesSize>>

Function to compute VRF hash output for a given proof. Spec: ECVRF_proof_to_hash function (steps 4-to 7).

§Arguments
  • proof - A vector of octets representing the proof of the VRF
§Returns
  • A vector of octets with the VRF hash output.
Source§

impl<C: Default, D: Default> VrfStruct<C, D>

Source

pub fn new(suite_id: u8) -> Self

Auto Trait Implementations§

§

impl<Curve, Hasher> Freeze for VrfStruct<Curve, Hasher>
where Curve: Freeze, Hasher: Freeze,

§

impl<Curve, Hasher> RefUnwindSafe for VrfStruct<Curve, Hasher>
where Curve: RefUnwindSafe, Hasher: RefUnwindSafe,

§

impl<Curve, Hasher> Send for VrfStruct<Curve, Hasher>
where Curve: Send, Hasher: Send,

§

impl<Curve, Hasher> Sync for VrfStruct<Curve, Hasher>
where Curve: Sync, Hasher: Sync,

§

impl<Curve, Hasher> Unpin for VrfStruct<Curve, Hasher>
where Curve: Unpin, Hasher: Unpin,

§

impl<Curve, Hasher> UnwindSafe for VrfStruct<Curve, Hasher>
where Curve: UnwindSafe, Hasher: UnwindSafe,

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> Same for T

Source§

type Output = T

Should always be Self
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.