Trait dusk_hades::strategies::Strategy [−][src]
Defines the Hades252 strategy algorithm.
Required methods
fn add_round_key<'b, I>(&mut self, constants: &mut I, words: &mut [T]) where
I: Iterator<Item = &'b BlsScalar>, [src]
I: Iterator<Item = &'b BlsScalar>,
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.
fn quintic_s_box(&mut self, value: &mut T)[src]
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.
fn mul_matrix<'b, I>(&mut self, constants: &mut I, values: &mut [T]) where
I: Iterator<Item = &'b BlsScalar>, [src]
I: Iterator<Item = &'b BlsScalar>,
Multiply the values for MDS matrix during the full rounds application.
Provided methods
fn next_c<'b, I>(constants: &mut I) -> BlsScalar where
I: Iterator<Item = &'b BlsScalar>, [src]
I: Iterator<Item = &'b BlsScalar>,
Fetch the next round constant from an iterator
fn apply_partial_round<'b, I>(&mut self, constants: &mut I, words: &mut [T]) where
I: Iterator<Item = &'b BlsScalar>, [src]
I: Iterator<Item = &'b BlsScalar>,
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-Boxjust to the last element of the words generated from the first step. This is also known as aSub Wordsoperation. - Multiplies the output words from the second step by
the
MDS_MATRIX. This is known as theMix Layer.
fn apply_full_round<'a, I>(&mut self, constants: &mut I, words: &mut [T]) where
I: Iterator<Item = &'a BlsScalar>, [src]
I: Iterator<Item = &'a BlsScalar>,
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-Boxto all of the words generated from the first step. This is also known as aSub Wordsoperation. - Multiplies the output words from the second step by
the
MDS_MATRIX. This is known as theMix Layer.
fn perm(&mut self, data: &mut [T])[src]
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.
fn rounds() -> usize[src]
Return the total rounds count
Implementors
impl Strategy<Scalar> for ScalarStrategy[src]
fn add_round_key<'b, I>(&mut self, constants: &mut I, words: &mut [BlsScalar]) where
I: Iterator<Item = &'b BlsScalar>, [src]
I: Iterator<Item = &'b BlsScalar>,
fn quintic_s_box(&mut self, value: &mut BlsScalar)[src]
fn mul_matrix<'b, I>(&mut self, _constants: &mut I, values: &mut [BlsScalar]) where
I: Iterator<Item = &'b BlsScalar>, [src]
I: Iterator<Item = &'b BlsScalar>,
impl<'a> Strategy<Variable> for GadgetStrategy<'a>[src]
fn add_round_key<'b, I>(&mut self, constants: &mut I, words: &mut [Variable]) where
I: Iterator<Item = &'b BlsScalar>, [src]
I: Iterator<Item = &'b BlsScalar>,
fn quintic_s_box(&mut self, value: &mut Variable)[src]
fn mul_matrix<'b, I>(&mut self, constants: &mut I, values: &mut [Variable]) where
I: Iterator<Item = &'b BlsScalar>, [src]
I: Iterator<Item = &'b BlsScalar>,
Adds a constraint for each matrix coefficient multiplication