Przeglądaj źródła

Merge pull request #1 from parazyd/master

Code linting
∞ − 0 − a + a + 0 = ∞ 5 lat temu
rodzic
commit
93458c7d93

+ 2 - 3
.gitignore

@@ -1,5 +1,4 @@
-.gitignore
-/target
-scripts/__pycache__/
+target
+*.pyc
 mint.params
 mint.params
 spend.params
 spend.params

+ 1 - 1
lisp/README.md

@@ -1,6 +1,6 @@
 ## zklisp
 ## zklisp
 
 
-This is a DSL for ZKVMCircuit from drk language.
+This is a DSL for ZkVmCircuit from drk language.
 
 
 It uses the mal (lisp) version of rust with some modifications to interact with bellman backend and also drk vm.
 It uses the mal (lisp) version of rust with some modifications to interact with bellman backend and also drk vm.
 
 

+ 2 - 2
lisp/TODO.md

@@ -2,6 +2,6 @@
 
 
 - Document the language
 - Document the language
 - Integrate with zkvm command line
 - Integrate with zkvm command line
-- Integrate with ZKVMCircuit: allocs and constraints
+- Integrate with ZkVmCircuit: allocs and constraints
 - Added CryptoOperation such double and square to core.rs
 - Added CryptoOperation such double and square to core.rs
-- Adapt ZKContract to use lisp to read contract and execute
+- Adapt ZkContract to use lisp to read contract and execute

+ 3 - 3
scripts/compile_export_rust.py

@@ -7,7 +7,7 @@ def to_initial_caps(snake_str):
 def display(contract):
 def display(contract):
     indent = " " * 4
     indent = " " * 4
 
 
-    print(r"""use super::vm::{ZKVirtualMachine, CryptoOperation, AllocType, ConstraintInstruction, VariableIndex, VariableRef};
+    print(r"""use super::vm::{ZkVirtualMachine, CryptoOperation, AllocType, ConstraintInstruction, VariableIndex, VariableRef};
 use bls12_381::Scalar;
 use bls12_381::Scalar;
 
 
 pub fn load_params(params: Vec<Scalar>) -> Vec<(VariableIndex, Scalar)> {""")
 pub fn load_params(params: Vec<Scalar>) -> Vec<(VariableIndex, Scalar)> {""")
@@ -23,8 +23,8 @@ pub fn load_params(params: Vec<Scalar>) -> Vec<(VariableIndex, Scalar)> {""")
     print("%sresult" % indent)
     print("%sresult" % indent)
     print("}\n")
     print("}\n")
 
 
-    print(r"""pub fn load_zkvm() -> ZKVirtualMachine {
-    ZKVirtualMachine {
+    print(r"""pub fn load_zkvm() -> ZkVirtualMachine {
+    ZkVirtualMachine {
         constants: vec![""")
         constants: vec![""")
 
 
     constants = list(contract.constants.items())
     constants = list(contract.constants.items())

+ 2 - 2
src/bin/darkfid.rs

@@ -13,7 +13,7 @@ use drk::service::{GatewayClient, GatewaySlabsSubscriber};
 use drk::state::{state_transition, ProgramState, StateUpdate};
 use drk::state::{state_transition, ProgramState, StateUpdate};
 use drk::util;
 use drk::util;
 use drk::util::join_config_path;
 use drk::util::join_config_path;
-use drk::wallet::{WalletDB, WalletPtr};
+use drk::wallet::{WalletDb, WalletPtr};
 use drk::{tx, Result};
 use drk::{tx, Result};
 use log::*;
 use log::*;
 use std::fs;
 use std::fs;
@@ -193,7 +193,7 @@ async fn start(executor: Arc<Executor<'_>>, config: Arc<&DarkfidConfig>) -> Resu
     let merkle_roots = RocksColumn::<columns::MerkleRoots>::new(rocks.clone());
     let merkle_roots = RocksColumn::<columns::MerkleRoots>::new(rocks.clone());
     let nullifiers = RocksColumn::<columns::Nullifiers>::new(rocks);
     let nullifiers = RocksColumn::<columns::Nullifiers>::new(rocks);
 
 
-    let wallet = Arc::new(WalletDB::new("wallet.db", config.password.clone())?);
+    let wallet = Arc::new(WalletDb::new("wallet.db", config.password.clone())?);
 
 
     let ex = executor.clone();
     let ex = executor.clone();
 
 

+ 4 - 4
src/bin/jubjub.rs

@@ -1,5 +1,5 @@
 use bls12_381::Scalar;
 use bls12_381::Scalar;
-use drk::{BlsStringConversion, Decodable, Encodable, ZKContract, ZKProof};
+use drk::{BlsStringConversion, Decodable, Encodable, ZkContract, ZkProof};
 use std::fs::File;
 use std::fs::File;
 use std::time::Instant;
 use std::time::Instant;
 
 
@@ -11,7 +11,7 @@ fn main() -> Result<()> {
 
 
         let start = Instant::now();
         let start = Instant::now();
         let file = File::open("jubjub.zcd")?;
         let file = File::open("jubjub.zcd")?;
-        let mut contract = ZKContract::decode(file)?;
+        let mut contract = ZkContract::decode(file)?;
         println!(
         println!(
             "Loaded contract '{}': [{:?}]",
             "Loaded contract '{}': [{:?}]",
             contract.name,
             contract.name,
@@ -36,7 +36,7 @@ fn main() -> Result<()> {
 
 
     let start = Instant::now();
     let start = Instant::now();
     let file = File::open("jubjub.zcd")?;
     let file = File::open("jubjub.zcd")?;
-    let mut contract = ZKContract::decode(file)?;
+    let mut contract = ZkContract::decode(file)?;
     println!(
     println!(
         "Loaded contract '{}': [{:?}]",
         "Loaded contract '{}': [{:?}]",
         contract.name,
         contract.name,
@@ -92,7 +92,7 @@ fn main() -> Result<()> {
     // Verify the proof
     // Verify the proof
 
 
     let file = File::open("jubjub.prf")?;
     let file = File::open("jubjub.prf")?;
-    let proof = ZKProof::decode(file)?;
+    let proof = ZkProof::decode(file)?;
     assert!(contract.verify(&proof));
     assert!(contract.verify(&proof));
 
 
     Ok(())
     Ok(())

+ 2 - 2
src/bin/mimc.rs

@@ -1,6 +1,6 @@
 use bls12_381::Scalar;
 use bls12_381::Scalar;
 use ff::Field;
 use ff::Field;
-use drk::{Decodable, ZKContract};
+use drk::{Decodable, ZkContract};
 use std::fs::File;
 use std::fs::File;
 use std::ops::{Add, AddAssign, MulAssign, Neg, SubAssign};
 use std::ops::{Add, AddAssign, MulAssign, Neg, SubAssign};
 use std::time::Instant;
 use std::time::Instant;
@@ -59,7 +59,7 @@ fn main() -> Result<()> {
 
 
     let start = Instant::now();
     let start = Instant::now();
     let file = File::open("mimc.zcd")?;
     let file = File::open("mimc.zcd")?;
-    let mut contract = ZKContract::decode(file)?;
+    let mut contract = ZkContract::decode(file)?;
     println!(
     println!(
         "Loaded contract '{}': [{:?}]",
         "Loaded contract '{}': [{:?}]",
         contract.name,
         contract.name,

+ 3 - 3
src/bin/mint.rs

@@ -1,4 +1,4 @@
-use drk::{Decodable, ZKContract};
+use drk::{Decodable, ZkContract};
 use std::fs::File;
 use std::fs::File;
 use std::time::Instant;
 use std::time::Instant;
 
 
@@ -42,9 +42,9 @@ fn _unpack_u64(value: u64) -> Vec<Scalar> {
 fn main() -> Result<()> {
 fn main() -> Result<()> {
     let start = Instant::now();
     let start = Instant::now();
     let file = File::open("mint.zcd")?;
     let file = File::open("mint.zcd")?;
-    let mut visor = ZKContract::decode(file)?;
+    let mut visor = ZkContract::decode(file)?;
     println!("{}", visor.name);
     println!("{}", visor.name);
-    //ZKContract::load_contract(bytes);
+    //ZkContract::load_contract(bytes);
     println!("Loaded contract: [{:?}]", start.elapsed());
     println!("Loaded contract: [{:?}]", start.elapsed());
 
 
     println!("Stats:");
     println!("Stats:");

+ 4 - 4
src/bin/tutorial.rs

@@ -1,7 +1,7 @@
 // This tutorial example corresponds to the VM proof in proofs/tutorial.psm
 // This tutorial example corresponds to the VM proof in proofs/tutorial.psm
 // It encodes the same function as the one in zk-explainer document.
 // It encodes the same function as the one in zk-explainer document.
 use bls12_381::Scalar;
 use bls12_381::Scalar;
-use drk::{BlsStringConversion, Decodable, Encodable, ZKContract, ZKProof};
+use drk::{BlsStringConversion, Decodable, Encodable, ZkContract, ZkProof};
 use std::fs::File;
 use std::fs::File;
 use std::time::Instant;
 use std::time::Instant;
 
 
@@ -13,7 +13,7 @@ fn main() -> Result<()> {
 
 
         let start = Instant::now();
         let start = Instant::now();
         let file = File::open("tutorial.zcd")?;
         let file = File::open("tutorial.zcd")?;
-        let mut contract = ZKContract::decode(file)?;
+        let mut contract = ZkContract::decode(file)?;
         println!(
         println!(
             "Loaded contract '{}': [{:?}]",
             "Loaded contract '{}': [{:?}]",
             contract.name,
             contract.name,
@@ -38,7 +38,7 @@ fn main() -> Result<()> {
 
 
     let start = Instant::now();
     let start = Instant::now();
     let file = File::open("tutorial.zcd")?;
     let file = File::open("tutorial.zcd")?;
-    let mut contract = ZKContract::decode(file)?;
+    let mut contract = ZkContract::decode(file)?;
     println!(
     println!(
         "Loaded contract '{}': [{:?}]",
         "Loaded contract '{}': [{:?}]",
         contract.name,
         contract.name,
@@ -79,7 +79,7 @@ fn main() -> Result<()> {
     // Verify the proof
     // Verify the proof
 
 
     let file = File::open("tutorial.prf")?;
     let file = File::open("tutorial.prf")?;
-    let proof = ZKProof::decode(file)?;
+    let proof = ZkProof::decode(file)?;
     assert!(contract.verify(&proof));
     assert!(contract.verify(&proof));
 
 
     Ok(())
     Ok(())

+ 6 - 6
src/bin/zkvm.rs

@@ -1,7 +1,7 @@
 #[macro_use]
 #[macro_use]
 extern crate clap;
 extern crate clap;
 use bls12_381::Scalar;
 use bls12_381::Scalar;
-use drk::{BlsStringConversion, Decodable, Encodable, ZKContract, ZKProof};
+use drk::{BlsStringConversion, Decodable, Encodable, ZkContract, ZkProof};
 use simplelog::*;
 use simplelog::*;
 use std::fs;
 use std::fs;
 use std::fs::File;
 use std::fs::File;
@@ -14,7 +14,7 @@ type Result<T> = std::result::Result<T, failure::Error>;
 fn trusted_setup(contract_data: String, setup_file: String) -> Result<()> {
 fn trusted_setup(contract_data: String, setup_file: String) -> Result<()> {
     let start = Instant::now();
     let start = Instant::now();
     let file = File::open(contract_data)?;
     let file = File::open(contract_data)?;
-    let mut contract = ZKContract::decode(file)?;
+    let mut contract = ZkContract::decode(file)?;
     println!(
     println!(
         "loaded contract '{}': [{:?}]",
         "loaded contract '{}': [{:?}]",
         contract.name,
         contract.name,
@@ -41,7 +41,7 @@ fn create_proof(
 ) -> Result<()> {
 ) -> Result<()> {
     let start = Instant::now();
     let start = Instant::now();
     let file = File::open(contract_data)?;
     let file = File::open(contract_data)?;
-    let mut contract = ZKContract::decode(file)?;
+    let mut contract = ZkContract::decode(file)?;
     contract.load_setup(&setup_file)?;
     contract.load_setup(&setup_file)?;
     println!(
     println!(
         "Loaded contract '{}': [{:?}]",
         "Loaded contract '{}': [{:?}]",
@@ -66,10 +66,10 @@ fn create_proof(
 //verify the proof
 //verify the proof
 fn verify_proof(contract_data: String, setup_file: String, zk_proof: String) -> Result<()> {
 fn verify_proof(contract_data: String, setup_file: String, zk_proof: String) -> Result<()> {
     let contract_file = File::open(contract_data)?;
     let contract_file = File::open(contract_data)?;
-    let mut contract = ZKContract::decode(contract_file)?;
+    let mut contract = ZkContract::decode(contract_file)?;
     contract.load_setup(&setup_file)?;
     contract.load_setup(&setup_file)?;
     let proof_file = File::open(zk_proof)?;
     let proof_file = File::open(zk_proof)?;
-    let proof = ZKProof::decode(proof_file)?;
+    let proof = ZkProof::decode(proof_file)?;
     if contract.verify(&proof) {
     if contract.verify(&proof) {
         println!("Zero-knowledge proof verified correctly.")
         println!("Zero-knowledge proof verified correctly.")
     } else {
     } else {
@@ -81,7 +81,7 @@ fn verify_proof(contract_data: String, setup_file: String, zk_proof: String) ->
 // show public values in proof
 // show public values in proof
 fn show_public(zk_proof: String) -> Result<()> {
 fn show_public(zk_proof: String) -> Result<()> {
     let file = File::open(zk_proof)?;
     let file = File::open(zk_proof)?;
-    let proof = ZKProof::decode(file)?;
+    let proof = ZkProof::decode(file)?;
     //assert_eq!(proof.public.len(), 2);
     //assert_eq!(proof.public.len(), 2);
     println!("Public values: {:?}", proof.public);
     println!("Public values: {:?}", proof.public);
     Ok(())
     Ok(())

+ 10 - 10
src/error.rs

@@ -1,10 +1,10 @@
 // TODO: Add support for rusqlite error
 // TODO: Add support for rusqlite error
 use jsonrpc_core::*;
 use jsonrpc_core::*;
-use rusqlite;
+//use rusqlite;
 use std::fmt;
 use std::fmt;
 
 
 use crate::state;
 use crate::state;
-use crate::vm::ZKVMError;
+use crate::vm::ZkVmError;
 
 
 pub type Result<T> = std::result::Result<T, Error>;
 pub type Result<T> = std::result::Result<T, Error>;
 
 
@@ -25,7 +25,7 @@ pub enum Error {
     BadConstraintType,
     BadConstraintType,
     InvalidParamName,
     InvalidParamName,
     MissingParams,
     MissingParams,
-    VMError,
+    VmError,
     BadContract,
     BadContract,
     Groth16Error,
     Groth16Error,
     RusqliteError(String),
     RusqliteError(String),
@@ -39,7 +39,7 @@ pub enum Error {
     StrUtf8Error(String),
     StrUtf8Error(String),
     NoteDecryptionFailed,
     NoteDecryptionFailed,
     ServicesError(&'static str),
     ServicesError(&'static str),
-    ZMQError(String),
+    ZmqError(String),
     VerifyFailed,
     VerifyFailed,
     TryIntoError,
     TryIntoError,
     TryFromError,
     TryFromError,
@@ -71,7 +71,7 @@ impl fmt::Display for Error {
             Error::BadConstraintType => f.write_str("Bad constraint type byte"),
             Error::BadConstraintType => f.write_str("Bad constraint type byte"),
             Error::InvalidParamName => f.write_str("Invalid param name"),
             Error::InvalidParamName => f.write_str("Invalid param name"),
             Error::MissingParams => f.write_str("Missing params"),
             Error::MissingParams => f.write_str("Missing params"),
-            Error::VMError => f.write_str("VM error"),
+            Error::VmError => f.write_str("VM error"),
             Error::BadContract => f.write_str("Contract is poorly defined"),
             Error::BadContract => f.write_str("Contract is poorly defined"),
             Error::Groth16Error => f.write_str("Groth16 error"),
             Error::Groth16Error => f.write_str("Groth16 error"),
             Error::RusqliteError(ref err) => write!(f, "Rusqlite error {}", err),
             Error::RusqliteError(ref err) => write!(f, "Rusqlite error {}", err),
@@ -86,7 +86,7 @@ impl fmt::Display for Error {
             Error::StrUtf8Error(ref err) => write!(f, "Malformed UTF8: {}", err),
             Error::StrUtf8Error(ref err) => write!(f, "Malformed UTF8: {}", err),
             Error::NoteDecryptionFailed => f.write_str("Unable to decrypt mint note"),
             Error::NoteDecryptionFailed => f.write_str("Unable to decrypt mint note"),
             Error::ServicesError(ref err) => write!(f, "Services error: {}", err),
             Error::ServicesError(ref err) => write!(f, "Services error: {}", err),
-            Error::ZMQError(ref err) => write!(f, "ZMQError: {}", err),
+            Error::ZmqError(ref err) => write!(f, "ZmqError: {}", err),
             Error::VerifyFailed => f.write_str("Verify failed"),
             Error::VerifyFailed => f.write_str("Verify failed"),
             Error::TryIntoError => f.write_str("TryInto error"),
             Error::TryIntoError => f.write_str("TryInto error"),
             Error::TryFromError => f.write_str("TryFrom error"),
             Error::TryFromError => f.write_str("TryFrom error"),
@@ -105,7 +105,7 @@ impl fmt::Display for Error {
 // TODO: Match statement to parse external errors into strings.
 // TODO: Match statement to parse external errors into strings.
 impl From<zeromq::ZmqError> for Error {
 impl From<zeromq::ZmqError> for Error {
     fn from(err: zeromq::ZmqError) -> Error {
     fn from(err: zeromq::ZmqError) -> Error {
-        Error::ZMQError(err.to_string())
+        Error::ZmqError(err.to_string())
     }
     }
 }
 }
 
 
@@ -146,9 +146,9 @@ impl From<rusqlite::Error> for Error {
     }
     }
 }
 }
 
 
-impl From<ZKVMError> for Error {
-    fn from(_err: ZKVMError) -> Error {
-        Error::VMError
+impl From<ZkVmError> for Error {
+    fn from(_err: ZkVmError) -> Error {
+        Error::VmError
     }
     }
 }
 }
 
 

+ 9 - 9
src/lib.rs

@@ -29,26 +29,26 @@ pub use crate::error::{Error, Result};
 pub use crate::net::p2p::P2p;
 pub use crate::net::p2p::P2p;
 pub use crate::serial::{Decodable, Encodable};
 pub use crate::serial::{Decodable, Encodable};
 pub use crate::vm::{
 pub use crate::vm::{
-    AllocType, ConstraintInstruction, CryptoOperation, VariableIndex, VariableRef, ZKVMCircuit,
-    ZKVirtualMachine,
+    AllocType, ConstraintInstruction, CryptoOperation, VariableIndex, VariableRef, ZkVmCircuit,
+    ZkVirtualMachine,
 };
 };
 
 
 pub type Bytes = Vec<u8>;
 pub type Bytes = Vec<u8>;
 
 
-pub struct ZKContract {
+pub struct ZkContract {
     pub name: String,
     pub name: String,
-    pub vm: ZKVirtualMachine,
+    pub vm: ZkVirtualMachine,
     params_map: HashMap<String, VariableIndex>,
     params_map: HashMap<String, VariableIndex>,
     pub params: HashMap<VariableIndex, Scalar>,
     pub params: HashMap<VariableIndex, Scalar>,
     public_map: bimap::BiMap<String, VariableIndex>,
     public_map: bimap::BiMap<String, VariableIndex>,
 }
 }
 
 
-pub struct ZKProof {
+pub struct ZkProof {
     pub public: HashMap<String, Scalar>,
     pub public: HashMap<String, Scalar>,
     pub proof: groth16::Proof<Bls12>,
     pub proof: groth16::Proof<Bls12>,
 }
 }
 
 
-impl ZKContract {
+impl ZkContract {
     // Just have a load() and save()
     // Just have a load() and save()
     // Load the contract, do the setup, save it...
     // Load the contract, do the setup, save it...
 
 
@@ -82,7 +82,7 @@ impl ZKContract {
         }
         }
     }
     }
 
 
-    pub fn prove(&mut self) -> Result<ZKProof> {
+    pub fn prove(&mut self) -> Result<ZkProof> {
         // Error if params not all set
         // Error if params not all set
         let user_params: HashSet<_> = self.params.keys().collect();
         let user_params: HashSet<_> = self.params.keys().collect();
         let req_params: HashSet<_> = self.params_map.values().collect();
         let req_params: HashSet<_> = self.params_map.values().collect();
@@ -108,9 +108,9 @@ impl ZKContract {
         }
         }
 
 
         // return proof and public values (Hashmap string -> scalars)
         // return proof and public values (Hashmap string -> scalars)
-        Ok(ZKProof { public, proof })
+        Ok(ZkProof { public, proof })
     }
     }
-    pub fn verify(&self, proof: &ZKProof) -> bool {
+    pub fn verify(&self, proof: &ZkProof) -> bool {
         let mut public = vec![];
         let mut public = vec![];
         for (name, value) in &proof.public {
         for (name, value) in &proof.public {
             match self.public_map.get_by_left(name) {
             match self.public_map.get_by_left(name) {

+ 6 - 6
src/net/message_subscriber.rs

@@ -13,13 +13,13 @@ use crate::net::messages::Message;
 use crate::serial::{Decodable, Encodable};
 use crate::serial::{Decodable, Encodable};
 
 
 /// 64bit identifier for message subscription.
 /// 64bit identifier for message subscription.
-pub type MessageSubscriptionID = u64;
+pub type MessageSubscriptionId = u64;
 type MessageResult<M> = Result<Arc<M>>;
 type MessageResult<M> = Result<Arc<M>>;
 
 
 /// Handles message subscriptions through a subscription ID and a receiver
 /// Handles message subscriptions through a subscription ID and a receiver
 /// channel.
 /// channel.
 pub struct MessageSubscription<M: Message> {
 pub struct MessageSubscription<M: Message> {
-    id: MessageSubscriptionID,
+    id: MessageSubscriptionId,
     recv_queue: async_channel::Receiver<MessageResult<M>>,
     recv_queue: async_channel::Receiver<MessageResult<M>>,
     parent: Arc<MessageDispatcher<M>>,
     parent: Arc<MessageDispatcher<M>>,
 }
 }
@@ -54,7 +54,7 @@ trait MessageDispatcherInterface: Send + Sync {
 /// Maintains a list of active subscribers and handles sending messages across
 /// Maintains a list of active subscribers and handles sending messages across
 /// subscriptions.
 /// subscriptions.
 struct MessageDispatcher<M: Message> {
 struct MessageDispatcher<M: Message> {
-    subs: Mutex<HashMap<MessageSubscriptionID, async_channel::Sender<MessageResult<M>>>>,
+    subs: Mutex<HashMap<MessageSubscriptionId, async_channel::Sender<MessageResult<M>>>>,
 }
 }
 
 
 impl<M: Message> MessageDispatcher<M> {
 impl<M: Message> MessageDispatcher<M> {
@@ -66,7 +66,7 @@ impl<M: Message> MessageDispatcher<M> {
     }
     }
 
 
     /// Create a random ID.
     /// Create a random ID.
-    fn random_id() -> MessageSubscriptionID {
+    fn random_id() -> MessageSubscriptionId {
         let mut rng = rand::thread_rng();
         let mut rng = rand::thread_rng();
         rng.gen()
         rng.gen()
     }
     }
@@ -87,7 +87,7 @@ impl<M: Message> MessageDispatcher<M> {
 
 
     /// Unsubcribe from a channel. Removes the associated ID from the subscriber
     /// Unsubcribe from a channel. Removes the associated ID from the subscriber
     /// list.
     /// list.
-    async fn unsubscribe(&self, sub_id: MessageSubscriptionID) {
+    async fn unsubscribe(&self, sub_id: MessageSubscriptionId) {
         self.subs.lock().await.remove(&sub_id);
         self.subs.lock().await.remove(&sub_id);
     }
     }
 
 
@@ -125,7 +125,7 @@ impl<M: Message> MessageDispatcher<M> {
     }
     }
 
 
     /// Remove inactive channels.
     /// Remove inactive channels.
-    async fn collect_garbage(&self, ids: Vec<MessageSubscriptionID>) {
+    async fn collect_garbage(&self, ids: Vec<MessageSubscriptionId>) {
         let mut subs = self.subs.lock().await;
         let mut subs = self.subs.lock().await;
         for id in &ids {
         for id in &ids {
             subs.remove(id);
             subs.remove(id);

+ 1 - 1
src/old/bits.rs

@@ -4,7 +4,7 @@ mod bits_contract;
 mod vm;
 mod vm;
 use bits_contract::load_zkvm;
 use bits_contract::load_zkvm;
 
 
-fn main() -> std::result::Result<(), vm::ZKVMError> {
+fn main() -> std::result::Result<(), vm::ZkVmError> {
     let mut vm = load_zkvm();
     let mut vm = load_zkvm();
 
 
     vm.setup();
     vm.setup();

+ 1 - 1
src/old/mint2.rs

@@ -57,7 +57,7 @@ fn do_vcr_test(value: &jubjub::Fr) {
     println!("cvr2: {:?}", randomness_commit);
     println!("cvr2: {:?}", randomness_commit);
 }
 }
 
 
-fn main() -> std::result::Result<(), vm::ZKVMError> {
+fn main() -> std::result::Result<(), vm::ZkVmError> {
     use rand::rngs::OsRng;
     use rand::rngs::OsRng;
     let public_point = jubjub::ExtendedPoint::from(jubjub::SubgroupPoint::random(&mut OsRng));
     let public_point = jubjub::ExtendedPoint::from(jubjub::SubgroupPoint::random(&mut OsRng));
     let public_affine = public_point.to_affine();
     let public_affine = public_point.to_affine();

+ 1 - 1
src/old/zkmimc.rs

@@ -40,7 +40,7 @@ macro_rules! from_slice {
     }};
     }};
 }
 }
 
 
-fn main() -> std::result::Result<(), vm::ZKVMError> {
+fn main() -> std::result::Result<(), vm::ZkVmError> {
     use rand::rngs::OsRng;
     use rand::rngs::OsRng;
 
 
     /////////////////////////////////
     /////////////////////////////////

+ 7 - 7
src/rpc/adapter.rs

@@ -1,4 +1,4 @@
-use crate::wallet::WalletDB;
+use crate::wallet::WalletDb;
 use crate::Result;
 use crate::Result;
 use async_std::sync::Arc;
 use async_std::sync::Arc;
 use log::*;
 use log::*;
@@ -7,11 +7,11 @@ use log::*;
 pub type AdapterPtr = Arc<RpcAdapter>;
 pub type AdapterPtr = Arc<RpcAdapter>;
 // Dummy adapter for now
 // Dummy adapter for now
 pub struct RpcAdapter {
 pub struct RpcAdapter {
-    pub wallet: Arc<WalletDB>,
+    pub wallet: Arc<WalletDb>,
 }
 }
 
 
 impl RpcAdapter {
 impl RpcAdapter {
-    pub fn new(wallet: Arc<WalletDB>) -> Result<Self> {
+    pub fn new(wallet: Arc<WalletDb>) -> Result<Self> {
         debug!(target: "ADAPTER", "new() [CREATING NEW WALLET]");
         debug!(target: "ADAPTER", "new() [CREATING NEW WALLET]");
         Ok(Self { wallet })
         Ok(Self { wallet })
     }
     }
@@ -71,15 +71,15 @@ impl RpcAdapter {
     //pub async fn create_
     //pub async fn create_
     //pub async fn save_key(&self, pubkey: Vec<u8>) -> Result<()> {
     //pub async fn save_key(&self, pubkey: Vec<u8>) -> Result<()> {
     //    debug!(target: "adapter", "save_key() [START]");
     //    debug!(target: "adapter", "save_key() [START]");
-    //    //let path = WalletDB::path("wallet.db")?;
-    //    //WalletDB::save(path, pubkey).await?;
+    //    //let path = WalletDb::path("wallet.db")?;
+    //    //WalletDb::save(path, pubkey).await?;
     //    Ok(())
     //    Ok(())
     //}
     //}
 
 
     //pub async fn save_cash_key(&self, pubkey: Vec<u8>) -> Result<()> {
     //pub async fn save_cash_key(&self, pubkey: Vec<u8>) -> Result<()> {
     //    debug!(target: "adapter", "save_cash_key() [START]");
     //    debug!(target: "adapter", "save_cash_key() [START]");
-    //    //let path = WalletDB::path("cashier.db")?;
-    //    //WalletDB::save(path, pubkey).await?;
+    //    //let path = WalletDb::path("cashier.db")?;
+    //    //WalletDb::save(path, pubkey).await?;
     //    Ok(())
     //    Ok(())
     //}
     //}
 
 

+ 2 - 2
src/service/reqrep.rs

@@ -184,7 +184,7 @@ impl ReqProtocol {
 
 
             Ok(Some(reply.get_payload()))
             Ok(Some(reply.get_payload()))
         } else {
         } else {
-            Err(crate::Error::ZMQError(
+            Err(crate::Error::ZmqError(
                 "Couldn't parse ZmqMessage".to_string(),
                 "Couldn't parse ZmqMessage".to_string(),
             ))
             ))
         }
         }
@@ -263,7 +263,7 @@ impl Subscriber {
                 let data: T = deserialize(&data)?;
                 let data: T = deserialize(&data)?;
                 Ok(data)
                 Ok(data)
             }
             }
-            None => Err(crate::Error::ZMQError(
+            None => Err(crate::Error::ZmqError(
                 "Couldn't parse ZmqMessage".to_string(),
                 "Couldn't parse ZmqMessage".to_string(),
             )),
             )),
         }
         }

+ 4 - 4
src/system/subscriber.rs

@@ -5,10 +5,10 @@ use std::sync::Arc;
 
 
 pub type SubscriberPtr<T> = Arc<Subscriber<T>>;
 pub type SubscriberPtr<T> = Arc<Subscriber<T>>;
 
 
-pub type SubscriptionID = u64;
+pub type SubscriptionId = u64;
 
 
 pub struct Subscription<T> {
 pub struct Subscription<T> {
-    id: SubscriptionID,
+    id: SubscriptionId,
     recv_queue: async_channel::Receiver<T>,
     recv_queue: async_channel::Receiver<T>,
     parent: Arc<Subscriber<T>>,
     parent: Arc<Subscriber<T>>,
 }
 }
@@ -43,7 +43,7 @@ impl<T: Clone> Subscriber<T> {
         })
         })
     }
     }
 
 
-    fn random_id() -> SubscriptionID {
+    fn random_id() -> SubscriptionId {
         let mut rng = rand::thread_rng();
         let mut rng = rand::thread_rng();
         rng.gen()
         rng.gen()
     }
     }
@@ -62,7 +62,7 @@ impl<T: Clone> Subscriber<T> {
         }
         }
     }
     }
 
 
-    async fn unsubscribe(self: Arc<Self>, sub_id: SubscriptionID) {
+    async fn unsubscribe(self: Arc<Self>, sub_id: SubscriptionId) {
         self.subs.lock().await.remove(&sub_id);
         self.subs.lock().await.remove(&sub_id);
     }
     }
 
 

+ 15 - 15
src/vm.rs

@@ -8,7 +8,7 @@ use std::time::Instant;
 
 
 use crate::error::Result;
 use crate::error::Result;
 
 
-pub struct ZKVirtualMachine {
+pub struct ZkVirtualMachine {
     pub constants: Vec<Scalar>,
     pub constants: Vec<Scalar>,
     pub alloc: Vec<(AllocType, VariableIndex)>,
     pub alloc: Vec<(AllocType, VariableIndex)>,
     pub ops: Vec<CryptoOperation>,
     pub ops: Vec<CryptoOperation>,
@@ -76,16 +76,16 @@ pub enum ConstraintInstruction {
 }
 }
 
 
 #[derive(Debug)]
 #[derive(Debug)]
-pub enum ZKVMError {
+pub enum ZkVmError {
     DivisionByZero,
     DivisionByZero,
     MalformedRange,
     MalformedRange,
 }
 }
 
 
-impl ZKVirtualMachine {
+impl ZkVirtualMachine {
     pub fn initialize(
     pub fn initialize(
         &mut self,
         &mut self,
         params: &Vec<(VariableIndex, Scalar)>,
         params: &Vec<(VariableIndex, Scalar)>,
-    ) -> std::result::Result<(), ZKVMError> {
+    ) -> std::result::Result<(), ZkVmError> {
         // Resize array
         // Resize array
         self.aux = vec![Scalar::zero(); self.alloc.len()];
         self.aux = vec![Scalar::zero(); self.alloc.len()];
 
 
@@ -163,7 +163,7 @@ impl ZKVirtualMachine {
                     if bool::from(ret.is_some()) {
                     if bool::from(ret.is_some()) {
                         *self_ = ret.unwrap();
                         *self_ = ret.unwrap();
                     } else {
                     } else {
-                        return Err(ZKVMError::DivisionByZero);
+                        return Err(ZkVmError::DivisionByZero);
                     }
                     }
                 }
                 }
                 CryptoOperation::Double(self_) => {
                 CryptoOperation::Double(self_) => {
@@ -186,7 +186,7 @@ impl ZKVirtualMachine {
                         VariableRef::Local(index) => &mut local_stack[*index],
                         VariableRef::Local(index) => &mut local_stack[*index],
                     };
                     };
                     if self_.is_zero() {
                     if self_.is_zero() {
-                        return Err(ZKVMError::DivisionByZero);
+                        return Err(ZkVmError::DivisionByZero);
                     } else {
                     } else {
                         *self_ = self_.invert().unwrap();
                         *self_ = self_.invert().unwrap();
                     }
                     }
@@ -200,12 +200,12 @@ impl ZKVirtualMachine {
                         VariableRef::Aux(start_index) => match end {
                         VariableRef::Aux(start_index) => match end {
                             VariableRef::Aux(end_index) => (&mut self.aux, start_index, end_index),
                             VariableRef::Aux(end_index) => (&mut self.aux, start_index, end_index),
                             VariableRef::Local(_) => {
                             VariableRef::Local(_) => {
-                                return Err(ZKVMError::MalformedRange);
+                                return Err(ZkVmError::MalformedRange);
                             }
                             }
                         },
                         },
                         VariableRef::Local(start_index) => match end {
                         VariableRef::Local(start_index) => match end {
                             VariableRef::Aux(_) => {
                             VariableRef::Aux(_) => {
-                                return Err(ZKVMError::MalformedRange);
+                                return Err(ZkVmError::MalformedRange);
                             }
                             }
                             VariableRef::Local(end_index) => {
                             VariableRef::Local(end_index) => {
                                 (&mut local_stack, start_index, end_index)
                                 (&mut local_stack, start_index, end_index)
@@ -213,13 +213,13 @@ impl ZKVirtualMachine {
                         },
                         },
                     };
                     };
                     if start_index > end_index {
                     if start_index > end_index {
-                        return Err(ZKVMError::MalformedRange);
+                        return Err(ZkVmError::MalformedRange);
                     }
                     }
                     if (end_index + 1) - start_index != 256 {
                     if (end_index + 1) - start_index != 256 {
-                        return Err(ZKVMError::MalformedRange);
+                        return Err(ZkVmError::MalformedRange);
                     }
                     }
                     if *end_index >= self_.len() {
                     if *end_index >= self_.len() {
-                        return Err(ZKVMError::MalformedRange);
+                        return Err(ZkVmError::MalformedRange);
                     }
                     }
 
 
                     for (i, bit) in value.to_le_bits().into_iter().cloned().enumerate() {
                     for (i, bit) in value.to_le_bits().into_iter().cloned().enumerate() {
@@ -283,7 +283,7 @@ impl ZKVirtualMachine {
         // Create parameters for our circuit. In a production deployment these would
         // Create parameters for our circuit. In a production deployment these would
         // be generated securely using a multiparty computation.
         // be generated securely using a multiparty computation.
         self.params = Some({
         self.params = Some({
-            let circuit = ZKVMCircuit {
+            let circuit = ZkVmCircuit {
                 aux: vec![None; self.aux.len()],
                 aux: vec![None; self.aux.len()],
                 alloc: self.alloc.clone(),
                 alloc: self.alloc.clone(),
                 constraints: self.constraints.clone(),
                 constraints: self.constraints.clone(),
@@ -303,7 +303,7 @@ impl ZKVirtualMachine {
     pub fn prove(&self) -> groth16::Proof<Bls12> {
     pub fn prove(&self) -> groth16::Proof<Bls12> {
         let aux = self.aux.iter().map(|scalar| Some(scalar.clone())).collect();
         let aux = self.aux.iter().map(|scalar| Some(scalar.clone())).collect();
         // Create an instance of our circuit (with the preimage as a witness).
         // Create an instance of our circuit (with the preimage as a witness).
-        let circuit = ZKVMCircuit {
+        let circuit = ZkVmCircuit {
             aux,
             aux,
             alloc: self.alloc.clone(),
             alloc: self.alloc.clone(),
             constraints: self.constraints.clone(),
             constraints: self.constraints.clone(),
@@ -329,14 +329,14 @@ impl ZKVirtualMachine {
     }
     }
 }
 }
 
 
-pub struct ZKVMCircuit {
+pub struct ZkVmCircuit {
     aux: Vec<Option<bls12_381::Scalar>>,
     aux: Vec<Option<bls12_381::Scalar>>,
     alloc: Vec<(AllocType, VariableIndex)>,
     alloc: Vec<(AllocType, VariableIndex)>,
     constraints: Vec<ConstraintInstruction>,
     constraints: Vec<ConstraintInstruction>,
     constants: Vec<Scalar>,
     constants: Vec<Scalar>,
 }
 }
 
 
-impl Circuit<bls12_381::Scalar> for ZKVMCircuit {
+impl Circuit<bls12_381::Scalar> for ZkVmCircuit {
     fn synthesize<CS: ConstraintSystem<bls12_381::Scalar>>(
     fn synthesize<CS: ConstraintSystem<bls12_381::Scalar>>(
         self,
         self,
         cs: &mut CS,
         cs: &mut CS,

+ 7 - 7
src/vm_serial.rs

@@ -1,9 +1,9 @@
 use crate::error::{Error, Result};
 use crate::error::{Error, Result};
 use crate::serial::{Decodable, Encodable, ReadExt, VarInt};
 use crate::serial::{Decodable, Encodable, ReadExt, VarInt};
 use crate::vm::{
 use crate::vm::{
-    AllocType, ConstraintInstruction, CryptoOperation, VariableIndex, VariableRef, ZKVirtualMachine,
+    AllocType, ConstraintInstruction, CryptoOperation, VariableIndex, VariableRef, ZkVirtualMachine,
 };
 };
-use crate::{impl_vec, ZKContract, ZKProof};
+use crate::{impl_vec, ZkContract, ZkProof};
 use bellman::groth16;
 use bellman::groth16;
 use bls12_381 as bls;
 use bls12_381 as bls;
 use std::collections::HashMap;
 use std::collections::HashMap;
@@ -12,18 +12,18 @@ use std::io;
 impl_vec!((String, VariableIndex));
 impl_vec!((String, VariableIndex));
 impl_vec!((String, bls::Scalar));
 impl_vec!((String, bls::Scalar));
 
 
-impl Encodable for ZKContract {
+impl Encodable for ZkContract {
     fn encode<S: io::Write>(&self, _s: S) -> Result<usize> {
     fn encode<S: io::Write>(&self, _s: S) -> Result<usize> {
         unimplemented!();
         unimplemented!();
         //Ok(0)
         //Ok(0)
     }
     }
 }
 }
 
 
-impl Decodable for ZKContract {
+impl Decodable for ZkContract {
     fn decode<D: io::Read>(mut d: D) -> Result<Self> {
     fn decode<D: io::Read>(mut d: D) -> Result<Self> {
         Ok(Self {
         Ok(Self {
             name: Decodable::decode(&mut d)?,
             name: Decodable::decode(&mut d)?,
-            vm: ZKVirtualMachine {
+            vm: ZkVirtualMachine {
                 constants: Decodable::decode(&mut d)?,
                 constants: Decodable::decode(&mut d)?,
                 alloc: Decodable::decode(&mut d)?,
                 alloc: Decodable::decode(&mut d)?,
                 ops: Decodable::decode(&mut d)?,
                 ops: Decodable::decode(&mut d)?,
@@ -45,7 +45,7 @@ impl Decodable for ZKContract {
     }
     }
 }
 }
 
 
-impl Encodable for ZKProof {
+impl Encodable for ZkProof {
     fn encode<S: io::Write>(&self, mut s: S) -> Result<usize> {
     fn encode<S: io::Write>(&self, mut s: S) -> Result<usize> {
         let mut len = self
         let mut len = self
             .public
             .public
@@ -58,7 +58,7 @@ impl Encodable for ZKProof {
     }
     }
 }
 }
 
 
-impl Decodable for ZKProof {
+impl Decodable for ZkProof {
     fn decode<D: io::Read>(mut d: D) -> Result<Self> {
     fn decode<D: io::Read>(mut d: D) -> Result<Self> {
         Ok(Self {
         Ok(Self {
             public: Vec::<(String, bls::Scalar)>::decode(&mut d)?
             public: Vec::<(String, bls::Scalar)>::decode(&mut d)?

+ 1 - 1
src/wallet/mod.rs

@@ -1,3 +1,3 @@
 pub mod walletdb;
 pub mod walletdb;
 
 
-pub use walletdb::{WalletDB, WalletPtr};
+pub use walletdb::{WalletDb, WalletPtr};

+ 3 - 3
src/wallet/walletdb.rs

@@ -12,9 +12,9 @@ use rusqlite::{named_params, params, Connection};
 
 
 use std::path::PathBuf;
 use std::path::PathBuf;
 
 
-pub type WalletPtr = Arc<WalletDB>;
+pub type WalletPtr = Arc<WalletDb>;
 
 
-pub struct WalletDB {
+pub struct WalletDb {
     pub path: PathBuf,
     pub path: PathBuf,
     pub secrets: Vec<jubjub::Fr>,
     pub secrets: Vec<jubjub::Fr>,
     pub cashier_secrets: Vec<jubjub::Fr>,
     pub cashier_secrets: Vec<jubjub::Fr>,
@@ -26,7 +26,7 @@ pub struct WalletDB {
     pub password: String,
     pub password: String,
 }
 }
 
 
-impl WalletDB {
+impl WalletDb {
     pub fn new(wallet: &str, password: String) -> Result<Self> {
     pub fn new(wallet: &str, password: String) -> Result<Self> {
         debug!(target: "walletdb", "new() Constructor called");
         debug!(target: "walletdb", "new() Constructor called");
         let path = join_config_path(&PathBuf::from(wallet))?;
         let path = join_config_path(&PathBuf::from(wallet))?;