Skip to main content

Hints

Struct Hints 

pub struct Hints<H, const S: usize> { /* private fields */ }
Expand description

Batch of Hints that enforces inner vector size. In addition, Hints::new shuffles inputs, and also mitigates some timing leaks, while all constructors ensure uniqueness of supplied blinded public keys.

  1. If fewer HintSeed items than S are supplied during creation, decoy HintSeeds will fill the remaining slots.
  2. A new temporary K::SecretKey is generated, which is used as a one-off contribution to the group secrets used to encrypt the respective Hint’s messages.
  3. In order to make sure passive attackers don’t know which Hint to brute force, the Hints order should not be deterministic, so decoy and real Hints get shuffled before the result is returned.
  4. Before a Hints batch gets constructed, all the supplied HintSeeds are checked for duplicate K::PublicKeys.

In aggregate, this ensures that even if the same HintSeed set is used to create multiple Hints instances, they are indistinguishable to passive observers that want to infer communication patterns by repeatedly polling a server or other intermediary.

Implementations§

§

impl<K: KeyPair, A: Aead + KeyInit, L: ArraySize, const S: usize> Hints<Hint<K, A, L>, S>
where Hint<K, A, L>: HintSized<K, A, L> + Hinting<K, L>,

pub fn new( hint_seeds: &[HintSeed<K, L>], context: &[u8], csprng: &mut impl CryptoRng, ) -> Result<Self, Error>

Build shuffled batch of Hint instances from a HintSeed slice containing at most S items, context, and an RNG, resulting in Hints with size S.

§Security

Although this method mitigates leaking execution timing as best as feasible and can be broadly described as having O(1) complexity, it also dynamically creates decoy hint seeds, which forces access patterns over non-contigouos memory and in turn cannot provide resistance to various side channel attacks. It should only be used in settings where your threat model does not include local adversaries.

pub fn from_pre_shuffled<V: Validation>( hint_seeds: &[&HintSeed<K, L>], context: &[u8], csprng: &mut impl CryptoRng, ) -> Result<Self, Error>

Build batch of Hint instances from a pre-shuffled HintSeed slice with length of S, context, and an RNG.

§Security

Requires supplying either Validate or, if the hazmat feature is enabled, hazmat::Passthru as a type parameter. The former ensures inputs do not risk accidental disclosure, the latter skips validation altogether and may leak information.

Note: Even when validating the supplied hint seeds slice, it cannot test whether inputs are pre-shuffled, hence it merely checks if the inputs have the expected length and don’t contain duplicates. However, provided the input’s memory layout is contiguous and underlying primitives used have constant-time implementations, this method inherits the properties of the cryptographic libraries used with the input types.

pub fn validate_hint_seeds(hint_seeds: &[&HintSeed<K, L>]) -> Result<(), Error>

Validate that the supplied slice of HintSeeds only contains BlindedPublicKeys

pub fn as_slice(&self) -> &[Hint<K, A, L>]

View as slice.

pub fn from_bytes(bytes: &[u8]) -> Result<Self, Error>

Deserialize from byte slice.

pub fn to_bytes(self) -> Vec<u8> ⓘ

Serialize to byte vector.

Trait Implementations§

§

impl<H: Clone, const S: usize> Clone for Hints<H, S>

§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<H: Debug, const S: usize> Debug for Hints<H, S>

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<H, const S: usize> Freeze for Hints<H, S>
where Vec<H>: Freeze,

§

impl<H, const S: usize> RefUnwindSafe for Hints<H, S>
where Vec<H>: RefUnwindSafe,

§

impl<H, const S: usize> Send for Hints<H, S>
where Vec<H>: Send,

§

impl<H, const S: usize> Sync for Hints<H, S>
where Vec<H>: Sync,

§

impl<H, const S: usize> Unpin for Hints<H, S>
where Vec<H>: Unpin,

§

impl<H, const S: usize> UnsafeUnpin for Hints<H, S>
where Vec<H>: UnsafeUnpin,

§

impl<H, const S: usize> UnwindSafe for Hints<H, S>
where Vec<H>: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.