Ver código fonte

zk: Move zk gadgets to separate gadget module.

parazyd 4 anos atrás
pai
commit
12bb3a0cde

+ 1 - 1
example/gt.rs

@@ -1,4 +1,4 @@
-use darkfi::zk::{
+use darkfi::zk::gadget::{
     arith_chip::{ArithChip, ArithConfig, ArithInstruction},
     arith_chip::{ArithChip, ArithConfig, ArithInstruction},
     even_bits::{EvenBitsChip, EvenBitsConfig, EvenBitsLookup},
     even_bits::{EvenBitsChip, EvenBitsConfig, EvenBitsLookup},
     greater_than::{GreaterThanChip, GreaterThanConfig, GreaterThanInstruction},
     greater_than::{GreaterThanChip, GreaterThanConfig, GreaterThanInstruction},

+ 2 - 2
src/zk/circuit/lead_contract.rs

@@ -30,8 +30,8 @@ use crate::crypto::{
     merkle_node::MerkleNode,
     merkle_node::MerkleNode,
 };
 };
 
 
-use crate::zk::{
-    arith_chip::{ArithChip, ArithConfig, ArithInstruction},
+use crate::zk::gadget::{
+    arithmetic::{ArithChip, ArithConfig, ArithInstruction},
     even_bits::{EvenBitsChip, EvenBitsConfig, EvenBitsLookup},
     even_bits::{EvenBitsChip, EvenBitsConfig, EvenBitsLookup},
     greater_than::{GreaterThanChip, GreaterThanConfig, GreaterThanInstruction},
     greater_than::{GreaterThanChip, GreaterThanConfig, GreaterThanInstruction},
 };
 };

+ 0 - 0
src/zk/arith_chip.rs → src/zk/gadget/arithmetic.rs


+ 0 - 0
src/zk/even_bits.rs → src/zk/gadget/even_bits.rs


+ 0 - 0
src/zk/greater_than.rs → src/zk/gadget/greater_than.rs


+ 8 - 0
src/zk/gadget/mod.rs

@@ -0,0 +1,8 @@
+/// Scalar arithmetic
+pub mod arithmetic;
+
+/// Even-bits lookup table
+pub mod even_bits;
+
+/// Greater than comparison gadget;
+pub mod greater_than;

+ 3 - 6
src/zk/mod.rs

@@ -1,14 +1,11 @@
-/// Halo2 arithmetic chip
-pub mod arith_chip;
-/// Even bits lookup table
-pub mod even_bits;
-/// Greather than gadget
-pub mod greater_than;
+/// ZK gadget implementations
+pub mod gadget;
 
 
 /// Halo2 zkas virtual machine
 /// Halo2 zkas virtual machine
 pub mod vm;
 pub mod vm;
 pub mod vm_stack;
 pub mod vm_stack;
 
 
+/// ZK circuits
 pub mod circuit;
 pub mod circuit;
 
 
 use halo2_proofs::{
 use halo2_proofs::{

+ 2 - 2
src/zk/vm.rs

@@ -24,8 +24,8 @@ use halo2_proofs::{
 use log::debug;
 use log::debug;
 use pasta_curves::{group::Curve, pallas, Fp};
 use pasta_curves::{group::Curve, pallas, Fp};
 
 
-use super::{
-    arith_chip::{ArithChip, ArithConfig, ArithInstruction},
+use super::gadget::{
+    arithmetic::{ArithChip, ArithConfig, ArithInstruction},
     even_bits::{EvenBitsChip, EvenBitsConfig, EvenBitsLookup},
     even_bits::{EvenBitsChip, EvenBitsConfig, EvenBitsLookup},
     greater_than::{GreaterThanChip, GreaterThanConfig, GreaterThanInstruction},
     greater_than::{GreaterThanChip, GreaterThanConfig, GreaterThanInstruction},
 };
 };