Trait dusk_hades::strategies::Strategy[][src]

pub trait Strategy<T: Clone + Copy> {
    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>
; 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 { ... } }
Expand description

Defines the Hades252 strategy algorithm.

Required methods

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.

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.

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

Provided methods

Fetch the next round constant from an iterator

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.

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.

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.

Return the total rounds count

Implementors

Adds a constraint for each matrix coefficient multiplication