From 501c18a58c383a8f38abe7f4ae0648a0a68583e9 Mon Sep 17 00:00:00 2001 From: Davide Galassi Date: Tue, 4 Aug 2026 09:32:22 +0200 Subject: [PATCH] test-vectors feature replaced by runtime Domain::without_blinding --- w3f-plonk-common/Cargo.toml | 1 - w3f-plonk-common/src/domain.rs | 40 ++++++++++++++++++++++++++++++---- w3f-ring-proof/Cargo.toml | 1 - w3f-ring-vrf-snark/Cargo.toml | 1 - 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/w3f-plonk-common/Cargo.toml b/w3f-plonk-common/Cargo.toml index f3393a79..8721cb62 100644 --- a/w3f-plonk-common/Cargo.toml +++ b/w3f-plonk-common/Cargo.toml @@ -50,4 +50,3 @@ parallel = [ ] print-trace = ["ark-std/print-trace"] asm = ["w3f-pcs/asm"] -test-vectors = [] diff --git a/w3f-plonk-common/src/domain.rs b/w3f-plonk-common/src/domain.rs index ef500e30..cd3dcb05 100644 --- a/w3f-plonk-common/src/domain.rs +++ b/w3f-plonk-common/src/domain.rs @@ -64,6 +64,7 @@ pub struct Domain { pub l_first: FieldColumn, pub l_last: FieldColumn, zk_rows_prod: DensePolynomial, + blinding: bool, } impl Domain { @@ -97,9 +98,20 @@ impl Domain { l_first, l_last, zk_rows_prod, + blinding: zk_rows != 0, } } + /// Disables column blinding, preserving the domain layout (`zk_rows`, `capacity`): + /// the zk rows are padded with zeros instead of random values. + /// Proofs generated over such a domain are deterministic, thus NOT zero-knowledge, + /// but remain valid for verifiers configured with the blinding-enabled domain. + /// Intended for reproducible test vectors generation. + pub fn without_blinding(mut self) -> Self { + self.blinding = false; + self + } + #[cfg(test)] pub const ZK_ROWS_TEST: usize = 3; @@ -136,13 +148,12 @@ impl Domain { fn _column(&self, mut values: Vec, public: bool) -> FieldColumn { let payload_len = values.len(); assert!(payload_len <= self.capacity); - let no_blinding = !self.is_hiding() || public || cfg!(feature = "test-vectors"); - if no_blinding { - values.resize(self.domain_size(), F::zero()); - } else { + if self.blinding && !public { values.resize(self.capacity, F::zero()); let rng = &mut getrandom_or_panic(); values.resize_with(self.domain_size(), || F::rand(rng)); + } else { + values.resize(self.domain_size(), F::zero()); } self.domains.column_from_evals(values, payload_len) } @@ -323,4 +334,25 @@ mod tests { _test_evaluated_domain(false); _test_evaluated_domain(true); } + + // Disabling blinding must yield reproducible columns (deterministic proofs, for test + // vectors generation) without altering the domain layout, so that the resulting proofs + // still match the parameters (e.g. max ring size) of the blinding-enabled configuration. + #[test] + fn column_blinding() { + let n = 16; + let values = vec![Fq::one(); 4]; + + let domain = Domain::test_domain(n, true); + let col_1 = domain.column(values.clone()); + let col_2 = domain.column(values.clone()); + assert_ne!(col_1.poly, col_2.poly); + + let capacity = domain.capacity; + let domain = domain.without_blinding(); + assert_eq!(domain.capacity, capacity); + let col_1 = domain.column(values.clone()); + let col_2 = domain.column(values); + assert_eq!(col_1.poly, col_2.poly); + } } diff --git a/w3f-ring-proof/Cargo.toml b/w3f-ring-proof/Cargo.toml index 893c03fd..e99556c2 100644 --- a/w3f-ring-proof/Cargo.toml +++ b/w3f-ring-proof/Cargo.toml @@ -51,4 +51,3 @@ parallel = [ ] print-trace = ["ark-std/print-trace"] asm = [ "w3f-pcs/asm" ] -test-vectors = [ "w3f-plonk-common/test-vectors" ] diff --git a/w3f-ring-vrf-snark/Cargo.toml b/w3f-ring-vrf-snark/Cargo.toml index f76ebd7d..b4a3a075 100644 --- a/w3f-ring-vrf-snark/Cargo.toml +++ b/w3f-ring-vrf-snark/Cargo.toml @@ -49,6 +49,5 @@ print-trace = [ "w3f-plonk-common/print-trace" ] asm = [ "w3f-pcs/asm" ] -test-vectors = [ "w3f-plonk-common/test-vectors" ] # benchmarking by running many proofs and verifications to get more accurate timing comparison intensive-benchmarking = ["std"]