pub struct PoprfServer<CS: CipherSuite> { /* private fields */ }Expand description
A server which engages with a PoprfClient in verifiable mode, meaning that the OPRF outputs can be checked against a server public key.
Implementations§
Source§impl<CS: CipherSuite> PoprfServer<CS>
impl<CS: CipherSuite> PoprfServer<CS>
Sourcepub fn new<R: TryRng + TryCryptoRng>(rng: &mut R) -> Result<Self>
pub fn new<R: TryRng + TryCryptoRng>(rng: &mut R) -> Result<Self>
Produces a new instance of a PoprfServer using a supplied RNG
§Errors
Error::Protocol if the protocol fails and can’t be completed.
Sourcepub fn new_with_key(key: &[u8]) -> Result<Self>
pub fn new_with_key(key: &[u8]) -> Result<Self>
Produces a new instance of a PoprfServer using a supplied set of bytes to represent the server’s private key
§Errors
Error::Deserialization if the private key is not a valid point on
the group or zero.
Sourcepub fn new_from_seed(seed: &[u8], info: &[u8]) -> Result<Self>
pub fn new_from_seed(seed: &[u8], info: &[u8]) -> Result<Self>
Produces a new instance of a PoprfServer using a supplied set of bytes which are used as a seed to derive the server’s private key.
Corresponds to DeriveKeyPair() function from the VOPRF specification.
§Errors
Error::DeriveKeyPairif theinputandseedtogether are longer thenu16::MAX - 3.Error::Protocolif the protocol fails and can’t be completed.
Sourcepub fn blind_evaluate<R: TryRng + TryCryptoRng>(
&self,
rng: &mut R,
blinded_element: &BlindedElement<CS>,
info: Option<&[u8]>,
) -> Result<PoprfServerEvaluateResult<CS>>
pub fn blind_evaluate<R: TryRng + TryCryptoRng>( &self, rng: &mut R, blinded_element: &BlindedElement<CS>, info: Option<&[u8]>, ) -> Result<PoprfServerEvaluateResult<CS>>
Computes the second step for the multiplicative blinding version of DH-OPRF. This message is sent from the server (who holds the OPRF key) to the client.
§Errors
Error::Infoif theinfois longer thanu16::MAX.Error::Protocolif the protocol fails and can’t be completed.
Sourcepub fn batch_blind_evaluate<'a, R: TryRng + TryCryptoRng, IE>(
&self,
rng: &mut R,
blinded_elements: &'a IE,
info: Option<&[u8]>,
) -> Result<PoprfServerBatchEvaluateResult<CS>>where
CS: 'a,
&'a IE: 'a + IntoIterator<Item = &'a BlindedElement<CS>>,
<&'a IE as IntoIterator>::IntoIter: ExactSizeIterator,
Available on crate feature alloc only.
pub fn batch_blind_evaluate<'a, R: TryRng + TryCryptoRng, IE>(
&self,
rng: &mut R,
blinded_elements: &'a IE,
info: Option<&[u8]>,
) -> Result<PoprfServerBatchEvaluateResult<CS>>where
CS: 'a,
&'a IE: 'a + IntoIterator<Item = &'a BlindedElement<CS>>,
<&'a IE as IntoIterator>::IntoIter: ExactSizeIterator,
alloc only.Allows for batching of the evaluation of multiple BlindedElement messages from a PoprfClient
§Errors
Error::Infoif theinfois longer thanu16::MAX.Error::Protocolif the protocol fails and can’t be completed.
Sourcepub fn batch_blind_evaluate_prepare<'a, I: Iterator<Item = &'a BlindedElement<CS>>>(
&self,
blinded_elements: I,
info: Option<&[u8]>,
) -> Result<PoprfServerBatchEvaluatePrepareResult<CS, I>>where
CS: 'a,
pub fn batch_blind_evaluate_prepare<'a, I: Iterator<Item = &'a BlindedElement<CS>>>(
&self,
blinded_elements: I,
info: Option<&[u8]>,
) -> Result<PoprfServerBatchEvaluatePrepareResult<CS, I>>where
CS: 'a,
Alternative version of batch_blind_evaluate without
memory allocation. Returned PreparedEvaluationElement have to
be collected and passed into
batch_blind_evaluate_finish.
§Errors
Error::Infoif theinfois longer thanu16::MAX.Error::Protocolif the protocol fails and can’t be completed.
Sourcepub fn batch_blind_evaluate_finish<'a, 'b, R: TryRng + TryCryptoRng, IB: Iterator<Item = &'a BlindedElement<CS>> + ExactSizeIterator, IE>(
rng: &mut R,
blinded_elements: IB,
prepared_evaluation_elements: &'b IE,
prepared_tweak: &PoprfPreparedTweak<CS>,
) -> Result<PoprfServerBatchEvaluateFinishResult<'b, CS, IE>>where
CS: 'a,
&'b IE: IntoIterator<Item = &'b PreparedEvaluationElement<CS>>,
<&'b IE as IntoIterator>::IntoIter: ExactSizeIterator,
pub fn batch_blind_evaluate_finish<'a, 'b, R: TryRng + TryCryptoRng, IB: Iterator<Item = &'a BlindedElement<CS>> + ExactSizeIterator, IE>(
rng: &mut R,
blinded_elements: IB,
prepared_evaluation_elements: &'b IE,
prepared_tweak: &PoprfPreparedTweak<CS>,
) -> Result<PoprfServerBatchEvaluateFinishResult<'b, CS, IE>>where
CS: 'a,
&'b IE: IntoIterator<Item = &'b PreparedEvaluationElement<CS>>,
<&'b IE as IntoIterator>::IntoIter: ExactSizeIterator,
See batch_blind_evaluate_prepare
for more details.
§Errors
Error::Batch if the number of blinded_elements and
prepared_evaluation_elements don’t match or is longer then
u16::MAX
Sourcepub fn evaluate(
&self,
input: &[u8],
info: Option<&[u8]>,
) -> Result<Output<<CS as CipherSuite>::Hash>>
pub fn evaluate( &self, input: &[u8], info: Option<&[u8]>, ) -> Result<Output<<CS as CipherSuite>::Hash>>
Computes the output of the VOPRF on the server side
§Errors
Error::Input if the input is longer then u16::MAX.
Sourcepub fn get_public_key(&self) -> <CS::Group as Group>::Elem
pub fn get_public_key(&self) -> <CS::Group as Group>::Elem
Retrieves the server’s public key
Source§impl<CS: CipherSuite> PoprfServer<CS>
impl<CS: CipherSuite> PoprfServer<CS>
Sourcepub fn serialize(&self) -> Array<u8, PoprfServerLen<CS>>
pub fn serialize(&self) -> Array<u8, PoprfServerLen<CS>>
Serialization into bytes