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.
- If fewer
HintSeeditems thanSare supplied during creation, decoyHintSeeds will fill the remaining slots. - A new temporary
K::SecretKeyis generated, which is used as a one-off contribution to the group secrets used to encrypt the respectiveHint’s messages. - In order to make sure passive attackers don’t know which
Hintto brute force, theHintsorder should not be deterministic, so decoy and realHints get shuffled before the result is returned. - Before a
Hintsbatch gets constructed, all the suppliedHintSeeds are checked for duplicateK::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>
impl<K: KeyPair, A: Aead + KeyInit, L: ArraySize, const S: usize> Hints<Hint<K, A, L>, S>
pub fn new(
hint_seeds: &[HintSeed<K, L>],
context: &[u8],
csprng: &mut impl CryptoRng,
) -> Result<Self, Error>
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>where
BlindedPublicKey<K>: Blinded,
pub fn from_pre_shuffled<V: Validation>(
hint_seeds: &[&HintSeed<K, L>],
context: &[u8],
csprng: &mut impl CryptoRng,
) -> Result<Self, Error>where
BlindedPublicKey<K>: Blinded,
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>where
BlindedPublicKey<K>: Blinded,
pub fn validate_hint_seeds(hint_seeds: &[&HintSeed<K, L>]) -> Result<(), Error>where
BlindedPublicKey<K>: Blinded,
Validate that the supplied slice of HintSeeds only contains BlindedPublicKeys
pub fn from_bytes(bytes: &[u8]) -> Result<Self, Error>
pub fn from_bytes(bytes: &[u8]) -> Result<Self, Error>
Deserialize from byte slice.