Build Status Repository Documentation

Hades252

Implementation of Hades252 permutation algorithm over the Bls12-381 Scalar field.

Documentation

To generate the Hades252 documentation:

sh make doc make doc-internal

Use

To import Hades252, add the following to the dependencies section of your project's Cargo.toml:

toml dusk-hades = "0.16.0"

Hades252 has a width equals to 5; it's possible to use a different value, see How to generate the assets.

Parameters

Example for ScalarStrategy

```rust use duskbls12381::BlsScalar; use dusk_hades::{ScalarStrategy, Strategy, WIDTH};

// Generate the inputs that will permute. // The number of values we can input is equivalent to WIDTH

let input = vec![BlsScalar::from(1u64); dusk_hades::WIDTH]; let mut output = input.clone();

let mut strategy = ScalarStrategy::new(); strategy.perm(output.asmutslice());

assertne!(&input, &output); asserteq!(input.len(), output.len()); ```

Example for GadgetStrategy

```rust,ignore // Proving that we know the pre-image of a hades-252 hash. use duskhades::{GadgetStrategy, Strategy, WIDTH}; use duskplonk::prelude::*;

// Setup OG params. const CAPACITY: usize = 1 << 10;

let publicparameters = PublicParameters::setup(CAPACITY, &mut rand::threadrng()).unwrap(); let (ck, vk) = public_parameters.trim(CAPACITY).unwrap();;

// Gen inputs let mut inputs = [BlsScalar::one(); WIDTH];

let mut prover = Prover::new(b"Hades_Testing");

// Generate the witness data let mut composer = prover.composermut(); let zero = TurboComposer::constantzero();

let mut witness = [zero; WIDTH]; witness.itermut() .zip(inputs.iter()) .foreach(|(w, i)| w = composer.append_witness(i));

// Perform the permutation in the circuit GadgetStrategy::gadget(prover.composer_mut(), &mut witness);

// Now your composer has been filled with a hades permutation // inside. // Now you can build your proof or keep extending your circuit. ```

Deviations

Reference

https://eprint.iacr.org/2019/458.pdf