From d14bda794506b25a7c4e58a0ad60b2fe89dc352e Mon Sep 17 00:00:00 2001 From: moana Date: Tue, 13 Feb 2024 11:17:44 +0100 Subject: [PATCH 1/2] Reduce hades constants from 960 to 335 Resolves #813 --- CHANGELOG.md | 5 +++++ src/composer/compress/hades.rs | 16 +++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85f244b8..41f30257 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -563,6 +567,7 @@ is necessary since `rkyv/validation` was required as a bound. - Proof system module. +[#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 diff --git a/src/composer/compress/hades.rs b/src/composer/compress/hades.rs index 8b1000cd..c1047caa 100644 --- a/src/composer/compress/hades.rs +++ b/src/composer/compress/hades.rs @@ -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]; @@ -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]; From cf2dcf363b27c9377bde2a691927cc65750b731f Mon Sep 17 00:00:00 2001 From: moana Date: Tue, 13 Feb 2024 11:24:28 +0100 Subject: [PATCH 2/2] Update toolchain to nightly-2023-11-10 --- rust-toolchain.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index de54b29a..e4ada996 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-05-24" -components = ["rustfmt", "clippy"] \ No newline at end of file +channel = "nightly-2023-11-10" +components = ["rustfmt", "clippy"]