Skip to content

Commit

Permalink
Merge pull request #814 from dusk-network/mocello/813_hades_constants
Browse files Browse the repository at this point in the history
Reduce hades constants from 960 to 335
  • Loading branch information
moCello authored Feb 13, 2024
2 parents c053660 + cf2dcf3 commit 7505e9a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Reduce hades constants count in circuit compression from 960 to 335 [#813]

## [0.19.0] - 2024-01-03

### Fixed
Expand Down Expand Up @@ -563,6 +567,7 @@ is necessary since `rkyv/validation` was required as a bound.
- Proof system module.

<!-- ISSUES -->
[#813]: https://github.com/dusk-network/plonk/issues/813
[#805]: https://github.com/dusk-network/plonk/issues/805
[#804]: https://github.com/dusk-network/plonk/issues/804
[#802]: https://github.com/dusk-network/plonk/issues/802
Expand Down
4 changes: 2 additions & 2 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2023-05-24"
components = ["rustfmt", "clippy"]
channel = "nightly-2023-11-10"
components = ["rustfmt", "clippy"]
16 changes: 9 additions & 7 deletions src/composer/compress/hades.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
//
// Copyright (c) DUSK NETWORK. All rights reserved.

use sha2::{Digest, Sha512};
// Extracted from
// https://github.com/dusk-network/Poseidon252/blob/master/assets/HOWTO.md

use super::BlsScalar;
use sha2::{Digest, Sha512};

const CONSTANTS: usize = 960;

// Extracted from
// https://github.com/dusk-network/Hades252/blob/a4d55e06ee9ff7f549043582e8d194eb0a01bf24/assets/HOWTO.md
// the width of the hades permutation container
const WIDTH: usize = 5;
// the total amount of rounds (partial + full) within one hades permutation
const ROUNDS: usize = 59 + 8;
// the amount of constants needed for one hades permutation
const CONSTANTS: usize = ROUNDS * WIDTH;

pub fn constants() -> [BlsScalar; CONSTANTS] {
let mut cnst = [BlsScalar::zero(); CONSTANTS];
Expand All @@ -31,8 +35,6 @@ pub fn constants() -> [BlsScalar; CONSTANTS] {
cnst
}

const WIDTH: usize = 5;

pub fn mds() -> [[BlsScalar; WIDTH]; WIDTH] {
let mut matrix = [[BlsScalar::zero(); WIDTH]; WIDTH];
let mut xs = [BlsScalar::zero(); WIDTH];
Expand Down

0 comments on commit 7505e9a

Please sign in to comment.