mod.rs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* This file is part of DarkFi (https://dark.fi)
  2. *
  3. * Copyright (C) 2020-2024 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. /// Halo2 zkas virtual machine
  19. pub mod vm;
  20. pub use vm::ZkCircuit;
  21. /// VM heap variable definitions and utility functions
  22. pub mod vm_heap;
  23. pub use vm_heap::{empty_witnesses, Witness};
  24. /// ZK gadget implementations
  25. pub mod gadget;
  26. /// Proof creation API
  27. pub mod proof;
  28. pub use proof::{Proof, ProvingKey, VerifyingKey};
  29. /// Trace computation of intermediate values in circuit
  30. mod tracer;
  31. pub use tracer::DebugOpValue;
  32. mod debug;
  33. pub use debug::zkas_type_checks;
  34. #[cfg(feature = "tinyjson")]
  35. pub use debug::{export_witness_json, import_witness_json};
  36. pub mod halo2 {
  37. pub use halo2_proofs::{
  38. arithmetic::Field,
  39. circuit::{AssignedCell, Layouter, Value},
  40. dev, plonk,
  41. plonk::{Advice, Assigned, Column},
  42. };
  43. }
  44. //pub(in crate::zk) fn assign_free_advice<F: Field, V: Copy>(
  45. pub fn assign_free_advice<F: halo2::Field, V: Copy>(
  46. mut layouter: impl halo2::Layouter<F>,
  47. column: halo2::Column<halo2::Advice>,
  48. value: halo2::Value<V>,
  49. ) -> Result<halo2::AssignedCell<V, F>, halo2::plonk::Error>
  50. where
  51. for<'v> halo2::Assigned<F>: From<&'v V>,
  52. {
  53. layouter.assign_region(
  54. || "load private",
  55. |mut region| region.assign_advice(|| "load private", column, 0, || value),
  56. )
  57. }