WireLabel

Trait WireLabel 

Source
pub trait WireLabel:
    Clone
    + HasModulus
    + Add<Output = Self>
    + AddAssign
    + Sub<Output = Self>
    + SubAssign
    + Neg<Output = Self>
    + Mul<u16, Output = Self>
    + MulAssign<u16> {
    // Required methods
    fn digits(&self) -> Vec<u16>;
    fn to_repr(&self) -> U8x16;
    fn color(&self) -> u16;
    fn from_repr(inp: U8x16, q: u16) -> Self;
    fn zero(q: u16) -> Self;
    fn rand_delta<R: CryptoRng + Rng>(rng: &mut R, q: u16) -> Self;
    fn rand<R: CryptoRng + RngCore>(rng: &mut R, q: u16) -> Self;
    fn hash_to_mod(hash: U8x16, q: u16) -> Self;

    // Provided methods
    fn hashback(&self, tweak: u128, q: u16) -> Self { ... }
    fn hash(&self, tweak: u128) -> U8x16 { ... }
}
Expand description

A trait that defines a wirelabel as used in garbled circuits.

At its core, a WireLabel is a way of encoding values, and operating on those encoded values.

Required Methods§

Source

fn digits(&self) -> Vec<u16>

The underlying digits encoded by the WireLabel.

Source

fn to_repr(&self) -> U8x16

Converts a WireLabel into its [U8x16] representation.

Source

fn color(&self) -> u16

The color digit of the wire.

Source

fn from_repr(inp: U8x16, q: u16) -> Self

Converts a [U8x16] into its WireLabel representation, based on the modulus q.

§Panics

This panics if q does not align with the modulus supported by the WireLabel.

Source

fn zero(q: u16) -> Self

The zero WireLabel, based on the modulus q.

§Panics

This panics if q does not align with the modulus supported by the WireLabel.

Source

fn rand_delta<R: CryptoRng + Rng>(rng: &mut R, q: u16) -> Self

A random WireLabel mod q, with the first digit set to 1.

§Panics

This panics if q does not align with the modulus supported by the WireLabel.

Source

fn rand<R: CryptoRng + RngCore>(rng: &mut R, q: u16) -> Self

A random WireLabel mod q.

§Panics

This panics if q does not align with the modulus supported by the WireLabel.

Source

fn hash_to_mod(hash: U8x16, q: u16) -> Self

Converts a hashed block into a valid wire of the given modulus q.

This is useful when separately using hash_wires to hash a set of wires in one shot for efficiency reasons.

§Panics

This panics if q does not align with the modulus supported by the WireLabel.

Provided Methods§

Source

fn hashback(&self, tweak: u128, q: u16) -> Self

Computes the hash of this WireLabel, converting the result back into a WireLabel based on the modulus q.

This is equivalent to WireLabel::hash_to_mod(self.hash(tweak), q), and is useful when stringing together a sequence of operations on a WireLabel.

§Panics

This panics if q does not align with the modulus supported by the WireLabel.

Source

fn hash(&self, tweak: u128) -> U8x16

Computes the hash of the WireLabel.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§