Skip to main content

ServerKey

Struct ServerKey 

Source
pub struct ServerKey { /* private fields */ }
Expand description

A server’s key for one mode.

Implementations§

Source§

impl ServerKey

Source

pub fn generate<R: RandomSource + ?Sized>( mode: Mode, rng: &mut R, ) -> Result<Self>

A fresh key from rng. Pass ic_drbg::Rng.

Source

pub fn derive(mode: Mode, seed: &[u8; 32], info: &[u8]) -> Result<Self>

RFC 9497 section 3.2.1’s DeriveKeyPair: a key from a 32-byte secret seed and a public info.

Source

pub fn from_bytes(mode: Mode, secret: &[u8]) -> Result<Self>

A key from its 32-byte scalar.

Source

pub fn to_bytes(&self) -> Zeroizing<[u8; 32]>

The 32-byte scalar, for storing the key.

Source

pub fn public_key(&self) -> [u8; 33]

The public key, which a VOPRF or POPRF client needs.

Source

pub fn mode(&self) -> Mode

The mode this key serves.

Source

pub fn blind_evaluate<R: RandomSource + ?Sized>( &self, blinded: &[u8; 33], info: &[u8], rng: &mut R, ) -> Result<([u8; 33], Option<[u8; 64]>)>

Evaluate one blinded element; see ServerKey::blind_evaluate_batch.

Source

pub fn blind_evaluate_batch<R: RandomSource + ?Sized>( &self, blinded: &[[u8; 33]], info: &[u8], rng: &mut R, evaluated: &mut [[u8; 33]], ) -> Result<Option<[u8; 64]>>

Evaluate blinded elements, writing one evaluated element for each, and return the batched proof in the verifiable modes.

info is the POPRF’s public input and must be empty in the other two modes. A POPRF info that hashes to the negated key – which only someone who knows the key can find – is refused, as RFC 9497 says, and is a sign the key is known.

Source

pub fn evaluate(&self, input: &[u8], info: &[u8]) -> Result<[u8; 32]>

RFC 9497’s Evaluate: the PRF output for input computed directly with the key, as the client would arrive at it. info is the POPRF’s and must be empty otherwise.

Trait Implementations§

Source§

impl Drop for ServerKey

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.