darkfi/zk/mod.rs
1/* This file is part of DarkFi (https://dark.fi)
2 *
3 * Copyright (C) 2020-2025 Dyne.org foundation
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as
7 * published by the Free Software Foundation, either version 3 of the
8 * License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
19/// Halo2 zkas virtual machine
20pub mod vm;
21pub use vm::ZkCircuit;
22
23/// VM heap variable definitions and utility functions
24pub mod vm_heap;
25pub use vm_heap::{empty_witnesses, Witness};
26
27/// ZK gadget implementations
28pub mod gadget;
29
30/// Proof creation API
31pub mod proof;
32pub use proof::{Proof, ProvingKey, VerifyingKey};
33
34/// Trace computation of intermediate values in circuit
35mod tracer;
36pub use tracer::DebugOpValue;
37
38mod debug;
39pub use debug::zkas_type_checks;
40#[cfg(feature = "tinyjson")]
41pub use debug::{export_witness_json, import_witness_json};
42
43pub mod halo2 {
44 pub use halo2_proofs::{
45 arithmetic::Field,
46 circuit::{AssignedCell, Layouter, Value},
47 dev, plonk,
48 plonk::{Advice, Assigned, Column},
49 };
50}
51
52//pub(in crate::zk) fn assign_free_advice<F: Field, V: Copy>(
53pub fn assign_free_advice<F: halo2::Field, V: Copy>(
54 mut layouter: impl halo2::Layouter<F>,
55 column: halo2::Column<halo2::Advice>,
56 value: halo2::Value<V>,
57) -> Result<halo2::AssignedCell<V, F>, halo2::plonk::Error>
58where
59 for<'v> halo2::Assigned<F>: From<&'v V>,
60{
61 layouter.assign_region(
62 || "load private",
63 |mut region| region.assign_advice(|| "load private", column, 0, || value),
64 )
65}