From 9fdf1b8ef4c30de8451b60657c7118ed49769871 Mon Sep 17 00:00:00 2001 From: Robin Salen <30937548+Nashtare@users.noreply.github.com> Date: Tue, 27 Aug 2024 16:56:19 -0400 Subject: [PATCH] Add `connect_array` convenience method in `CircuitBuilder` (#1620) * Add connect_array method * Pacify clippy * Wording --- Cargo.toml | 3 +++ field/Cargo.toml | 3 +++ plonky2/Cargo.toml | 3 +++ plonky2/src/plonk/circuit_builder.rs | 7 +++++++ starky/Cargo.toml | 3 +++ 5 files changed, 19 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 6b9de8db..81dbbde4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,3 +30,6 @@ homepage = "https://github.com/0xPolygonZero/plonky2" repository = "https://github.com/0xPolygonZero/plonky2" keywords = ["cryptography", "SNARK", "PLONK", "FRI", "plonky2"] categories = ["cryptography"] + +[workspace.lints.clippy] +too_long_first_doc_paragraph = "allow" diff --git a/field/Cargo.toml b/field/Cargo.toml index 71720318..e61f4e89 100644 --- a/field/Cargo.toml +++ b/field/Cargo.toml @@ -26,3 +26,6 @@ plonky2_util = { version = "0.2.0", path = "../util", default-features = false } # Display math equations properly in documentation [package.metadata.docs.rs] rustdoc-args = ["--html-in-header", ".cargo/katex-header.html"] + +[lints] +workspace = true diff --git a/plonky2/Cargo.toml b/plonky2/Cargo.toml index 59ae9212..e84496b0 100644 --- a/plonky2/Cargo.toml +++ b/plonky2/Cargo.toml @@ -87,3 +87,6 @@ harness = false # Display math equations properly in documentation [package.metadata.docs.rs] rustdoc-args = ["--html-in-header", ".cargo/katex-header.html"] + +[lints] +workspace = true diff --git a/plonky2/src/plonk/circuit_builder.rs b/plonky2/src/plonk/circuit_builder.rs index eaa11f2b..b36a78f0 100644 --- a/plonky2/src/plonk/circuit_builder.rs +++ b/plonky2/src/plonk/circuit_builder.rs @@ -524,6 +524,13 @@ impl, const D: usize> CircuitBuilder { .push(CopyConstraint::new((x, y), self.context_log.open_stack())); } + /// Enforces that the underlying values of two [`Target`] arrays are equal. + pub fn connect_array(&mut self, x: [Target; N], y: [Target; N]) { + for i in 0..N { + self.connect(x[i], y[i]); + } + } + /// Enforces that two [`ExtensionTarget`] underlying values are equal. pub fn connect_extension(&mut self, src: ExtensionTarget, dst: ExtensionTarget) { for i in 0..D { diff --git a/starky/Cargo.toml b/starky/Cargo.toml index 33d90d5b..8ee84d47 100644 --- a/starky/Cargo.toml +++ b/starky/Cargo.toml @@ -36,3 +36,6 @@ env_logger = { version = "0.9.0", default-features = false } # Display math equations properly in documentation [package.metadata.docs.rs] rustdoc-args = ["--html-in-header", ".cargo/katex-header.html"] + +[lints] +workspace = true