Trait dusk_hades::Strategy

source ·
pub trait Strategy<T: Clone + Copy> {
    // Required methods
    fn add_round_key<'b, I>(&mut self, constants: &mut I, words: &mut [T])
       where I: Iterator<Item = &'b BlsScalar>;
    fn quintic_s_box(&mut self, value: &mut T);
    fn mul_matrix<'b, I>(&mut self, constants: &mut I, values: &mut [T])
       where I: Iterator<Item = &'b BlsScalar>;

    // Provided methods
    fn next_c<'b, I>(constants: &mut I) -> BlsScalar
       where I: Iterator<Item = &'b BlsScalar> { ... }
    fn apply_partial_round<'b, I>(&mut self, constants: &mut I, words: &mut [T])
       where I: Iterator<Item = &'b BlsScalar> { ... }
    fn apply_full_round<'a, I>(&mut self, constants: &mut I, words: &mut [T])
       where I: Iterator<Item = &'a BlsScalar> { ... }
    fn perm(&mut self, data: &mut [T]) { ... }
    fn rounds() -> usize { ... }
}
👎Deprecated: This crate is deprecated. The code was moved to dusk-poseidon.
Expand description

Defines the Hades252 strategy algorithm.

Required Methods§

source

fn add_round_key<'b, I>(&mut self, constants: &mut I, words: &mut [T])
where I: Iterator<Item = &'b BlsScalar>,

👎Deprecated: This crate is deprecated. The code was moved to dusk-poseidon.

Add round keys to a set of StrategyInput.

This round key addition also known as ARK is used to reach Confusion and Diffusion properties for the algorithm.

Basically it allows to destroy any connection between the inputs and the outputs of the function.

source

fn quintic_s_box(&mut self, value: &mut T)

👎Deprecated: This crate is deprecated. The code was moved to dusk-poseidon.

Computes input ^ 5 (mod Fp)

The modulo depends on the input you use. In our case the modulo is done in respect of the bls12_381 scalar field == 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001.

source

fn mul_matrix<'b, I>(&mut self, constants: &mut I, values: &mut [T])
where I: Iterator<Item = &'b BlsScalar>,

👎Deprecated: This crate is deprecated. The code was moved to dusk-poseidon.

Multiply the values for MDS matrix during the full rounds application.

Provided Methods§

source

fn next_c<'b, I>(constants: &mut I) -> BlsScalar
where I: Iterator<Item = &'b BlsScalar>,

👎Deprecated: This crate is deprecated. The code was moved to dusk-poseidon.

Fetch the next round constant from an iterator

source

fn apply_partial_round<'b, I>(&mut self, constants: &mut I, words: &mut [T])
where I: Iterator<Item = &'b BlsScalar>,

👎Deprecated: This crate is deprecated. The code was moved to dusk-poseidon.

Applies a Partial Round also known as a Partial S-Box layer to a set of inputs.

§A partial round has 3 steps on every iteration:
  • Add round keys to each word. Also known as ARK.
  • Apply quintic S-Box just to the last element of the words generated from the first step. This is also known as a Sub Words operation.
  • Multiplies the output words from the second step by the MDS_MATRIX. This is known as the Mix Layer.
source

fn apply_full_round<'a, I>(&mut self, constants: &mut I, words: &mut [T])
where I: Iterator<Item = &'a BlsScalar>,

👎Deprecated: This crate is deprecated. The code was moved to dusk-poseidon.

Applies a Full Round also known as a Full S-Box layer to a set of inputs.

A full round has 3 steps on every iteration:

  • Add round keys to each word. Also known as ARK.
  • Apply quintic S-Box to all of the words generated from the first step. This is also known as a Sub Words operation.
  • Multiplies the output words from the second step by the MDS_MATRIX. This is known as the Mix Layer.
source

fn perm(&mut self, data: &mut [T])

👎Deprecated: This crate is deprecated. The code was moved to dusk-poseidon.

Applies a permutation-round of the Hades252 strategy.

It returns a vec of WIDTH outputs as a result which should be a randomly permuted version of the input.

In general, the same round function is iterated enough times to make sure that any symmetries and structural properties that might exist in the round function vanish.

This permutation is a 3-step process that:

  • Applies twice the half of the FULL_ROUNDS (which can be understood as linear ops).

  • In the middle step it applies the PARTIAL_ROUDS (which can be understood as non-linear ops).

This structure allows to minimize the number of non-linear ops while mantaining the security.

source

fn rounds() -> usize

👎Deprecated: This crate is deprecated. The code was moved to dusk-poseidon.

Return the total rounds count

Object Safety§

This trait is not object safe.

Implementors§