Răsfoiți Sursa

Add plotters crate as a dev-dependency to visualise zk circuits.

parazyd 4 ani în urmă
părinte
comite
ce52d8b07b
3 a modificat fișierele cu 30 adăugiri și 0 ștergeri
  1. 1 0
      Cargo.lock
  2. 1 0
      Cargo.toml
  3. 28 0
      src/zk/mod.rs

+ 1 - 0
Cargo.lock

@@ -1223,6 +1223,7 @@ dependencies = [
  "ntp",
  "num-bigint",
  "pasta_curves",
+ "plotters",
  "rand",
  "rcgen",
  "regex",

+ 1 - 0
Cargo.toml

@@ -134,6 +134,7 @@ sled = {version = "0.34.7", optional = true}
 clap = {version = "3.1.18", features = ["derive"]}
 halo2_proofs = {version = "0.1.0", features = ["dev-graph", "gadget-traces", "sanity-checks"]}
 halo2_gadgets = {version = "0.1.0", features = ["dev-graph", "test-dependencies"]}
+plotters = "0.3.1"
 
 [features]
 async-runtime = [

+ 28 - 0
src/zk/mod.rs

@@ -10,3 +10,31 @@ pub mod vm;
 pub mod vm_stack;
 
 pub mod circuit;
+
+use halo2_proofs::{
+    arithmetic::Field,
+    circuit::{AssignedCell, Layouter},
+    plonk,
+    plonk::{Advice, Assigned, Column},
+};
+
+pub(in crate::zk) fn assign_free_advice<F: Field, V: Copy>(
+    mut layouter: impl Layouter<F>,
+    column: Column<Advice>,
+    value: Option<V>,
+) -> Result<AssignedCell<V, F>, plonk::Error>
+where
+    for<'v> Assigned<F>: From<&'v V>,
+{
+    layouter.assign_region(
+        || "load private",
+        |mut region| {
+            region.assign_advice(
+                || "load private",
+                column,
+                0,
+                || value.ok_or(plonk::Error::Synthesis),
+            )
+        },
+    )
+}