From 323f40329cffaac3c709326ac1d38a7ce9912f58 Mon Sep 17 00:00:00 2001 From: Han Date: Thu, 23 Feb 2023 04:08:12 +0800 Subject: [PATCH] Expose mod `permutation` and re-export `permutation::keygen::Assembly` (#149) * feat: expose mod ule `permutation` and re-export `permutation::keygen::Assembly` * feat: derive `lone` for `permutation::keygen::Assembly` * feat: bump MSRV for `inferno` --- halo2_proofs/src/dev.rs | 4 ++-- halo2_proofs/src/plonk.rs | 2 +- halo2_proofs/src/plonk/permutation.rs | 5 +++++ halo2_proofs/src/plonk/permutation/keygen.rs | 20 +++++++++++++++----- rust-toolchain | 2 +- 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/halo2_proofs/src/dev.rs b/halo2_proofs/src/dev.rs index 1d9de2706e..28ca17a082 100644 --- a/halo2_proofs/src/dev.rs +++ b/halo2_proofs/src/dev.rs @@ -1443,7 +1443,7 @@ impl<'a, F: FieldExt> MockProver<'a, F> { self.permutation .as_ref() .expect("root cs permutation must be Some") - .mapping + .mapping() .iter() .enumerate() .flat_map(move |(column, values)| { @@ -1817,7 +1817,7 @@ impl<'a, F: FieldExt> MockProver<'a, F> { self.permutation .as_ref() .expect("root cs permutation must be Some") - .mapping + .mapping() .iter() .enumerate() .flat_map(move |(column, values)| { diff --git a/halo2_proofs/src/plonk.rs b/halo2_proofs/src/plonk.rs index d1aecca38e..f2e2ce7df8 100644 --- a/halo2_proofs/src/plonk.rs +++ b/halo2_proofs/src/plonk.rs @@ -28,7 +28,7 @@ mod error; mod evaluation; mod keygen; mod lookup; -pub(crate) mod permutation; +pub mod permutation; mod vanishing; mod prover; diff --git a/halo2_proofs/src/plonk/permutation.rs b/halo2_proofs/src/plonk/permutation.rs index b353493c57..8a731416ee 100644 --- a/halo2_proofs/src/plonk/permutation.rs +++ b/halo2_proofs/src/plonk/permutation.rs @@ -1,3 +1,5 @@ +//! Implementation of permutation argument. + use super::circuit::{Any, Column}; use crate::{ arithmetic::CurveAffine, @@ -14,6 +16,8 @@ pub(crate) mod keygen; pub(crate) mod prover; pub(crate) mod verifier; +pub use keygen::Assembly; + use std::io; /// A permutation argument. @@ -72,6 +76,7 @@ impl Argument { } } + /// Returns columns that participate on the permutation argument. pub fn get_columns(&self) -> Vec> { self.columns.clone() } diff --git a/halo2_proofs/src/plonk/permutation/keygen.rs b/halo2_proofs/src/plonk/permutation/keygen.rs index 58ba4878cc..cc2dc09bb0 100644 --- a/halo2_proofs/src/plonk/permutation/keygen.rs +++ b/halo2_proofs/src/plonk/permutation/keygen.rs @@ -12,16 +12,16 @@ use crate::{ }; /// Struct that accumulates all the necessary data in order to construct the permutation argument. -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct Assembly { /// Columns that participate on the copy permutation argument. - pub columns: Vec>, + columns: Vec>, /// Mapping of the actual copies done. - pub mapping: Vec>, + mapping: Vec>, /// Some aux data used to swap positions directly when sorting. - pub aux: Vec>, + aux: Vec>, /// More aux data - pub sizes: Vec>, + sizes: Vec>, } impl Assembly { @@ -238,4 +238,14 @@ impl Assembly { polys, } } + + /// Returns columns that participate on the permutation argument. + pub fn columns(&self) -> &[Column] { + &self.columns + } + + /// Returns mappings of the copies. + pub fn mapping(&self) -> &[Vec<(usize, usize)>] { + &self.mapping + } } diff --git a/rust-toolchain b/rust-toolchain index af92bdd9f5..9405730420 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.63.0 +1.64.0