[][src]Enum fancy_garbling::Wire

pub enum Wire {
    Mod2 {
        val: Block,
    },
    Mod3 {
        lsb: u64,
        msb: u64,
    },
    ModN {
        q: u16,
        ds: Vec<u16>,
    },
}

The core wire-label type.

Variants

Mod2

Representation of a mod-2 wire.

Fields of Mod2

val: Block

A 128-bit value.

Mod3

Representation of a mod-3 wire.

We represent a mod-3 wire by 64 mod-3 elements. These elements are stored as follows: the least-significant bits of each element are stored in lsb and the most-significant bits of each element are stored in msb. This representation allows for efficient addition and multiplication as described here by the paper "Hardware Implementation of Finite Fields of Characteristic Three." D. Page, N.P. Smart. CHES 2002. Link: https://link.springer.com/content/pdf/10.1007/3-540-36400-5_38.pdf.

Fields of Mod3

lsb: u64

The least-significant bits of each mod-3 element.

msb: u64

The most-significant bits of each mod-3 element.

ModN

Representation of a mod-q wire.

We represent a mod-q wire for q > 3 by the modulus q alongside a list of mod-q digits.

Fields of ModN

q: u16

The modulus of this wire-label.

ds: Vec<u16>

A list of mod-q digits.

Methods

impl Wire[src]

pub fn digits(&self) -> Vec<u16>[src]

Get the digits of the wire.

pub fn from_block(inp: Block, q: u16) -> Self[src]

Unpack the wire represented by a Block with modulus q. Assumes that the block was constructed through the Wire API.

pub fn as_block(&self) -> Block[src]

Pack the wire into a Block.

pub fn zero(q: u16) -> Self[src]

The zero wire with modulus q.

pub fn rand_delta<R: CryptoRng + RngCore>(rng: &mut R, q: u16) -> Self[src]

Get a random wire label mod q, with the first digit set to 1.

pub fn color(&self) -> u16[src]

Get the color digit of the wire.

pub fn plus(&self, other: &Self) -> Self[src]

Add two wires digit-wise, returning a new wire.

pub fn plus_eq<'a>(&'a mut self, other: &Wire) -> &'a mut Wire[src]

Add another wire digit-wise into this one. Assumes that both wires have the same modulus.

pub fn plus_mov(self, other: &Wire) -> Wire[src]

Add another wire into this one, consuming it for chained computations.

pub fn cmul(&self, c: u16) -> Self[src]

Multiply each digit by a constant c mod q, returning a new wire.

pub fn cmul_eq(&mut self, c: u16) -> &mut Wire[src]

Multiply each digit by a constant c mod q.

pub fn cmul_mov(self, c: u16) -> Wire[src]

Multiply each digit by a constant c mod q, consuming it for chained computations.

pub fn negate(&self) -> Self[src]

Negate all the digits mod q, returning a new wire.

pub fn negate_eq(&mut self) -> &mut Wire[src]

Negate all the digits mod q.

pub fn negate_mov(self) -> Wire[src]

Negate all the digits mod q, consuming it for chained computations.

pub fn minus(&self, other: &Wire) -> Wire[src]

Subtract two wires, returning the result.

pub fn minus_eq<'a>(&'a mut self, other: &Wire) -> &'a mut Wire[src]

Subtract a wire from this one.

pub fn minus_mov(self, other: &Wire) -> Wire[src]

Subtract a wire from this one, consuming it for chained computations.

pub fn rand<R: CryptoRng + RngCore>(rng: &mut R, q: u16) -> Wire[src]

Get a random wire mod q.

pub fn hash(&self, tweak: Block) -> Block[src]

Compute the hash of this wire.

Uses fixed-key AES.

pub fn hashback(&self, tweak: Block, q: u16) -> Wire[src]

Compute the hash of this wire, converting the result back to a wire.

Uses fixed-key AES.

Trait Implementations

impl HasModulus for Wire[src]

impl PartialEq<Wire> for Wire[src]

impl Default for Wire[src]

impl Clone for Wire[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Wire[src]

Auto Trait Implementations

impl Send for Wire

impl Sync for Wire

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T, U> IntoBits<U> for T where
    U: FromBits<T>, 

impl<T> Clear for T where
    T: InitializableFromZeroed + ?Sized

impl<T> InitializableFromZeroed for T where
    T: Default

impl<T> FromCast<T> for T

impl<T, U> Cast<U> for T where
    U: FromCast<T>, 

impl<T> FromBits<T> for T

impl<T> Same<T> for T

type Output = T

Should always be Self