Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce hades constants from 960 to 335 #814

Merged
merged 2 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading