Pārlūkot izejas kodu

Code linting.

For best and standard practices in Rust, acronyms should be CamelCase,
and capitalization should be avoided; i.e. ZKCircuit -> ZkCircuit

This commit replaces all such occurencies in the codebase.
parazyd 5 gadi atpakaļ
vecāks
revīzija
340631df2d

+ 2 - 3
.gitignore

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

+ 1 - 1
lisp/README.md

@@ -1,6 +1,6 @@
 ## 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.
 

+ 2 - 2
lisp/TODO.md

@@ -2,6 +2,6 @@
 
 - Document the language
 - 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
-- 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):
     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;
 
 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("}\n")
 
-    print(r"""pub fn load_zkvm() -> ZKVirtualMachine {
-    ZKVirtualMachine {
+    print(r"""pub fn load_zkvm() -> ZkVirtualMachine {
+    ZkVirtualMachine {
         constants: vec![""")
 
     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::util;
 use drk::util::join_config_path;
-use drk::wallet::{WalletDB, WalletPtr};
+use drk::wallet::{WalletDb, WalletPtr};
 use drk::{tx, Result};
 use log::*;
 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 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();
 

+ 4 - 4
src/bin/jubjub.rs

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

+ 2 - 2
src/bin/mimc.rs

@@ -1,6 +1,6 @@
 use bls12_381::Scalar;
 use ff::Field;
-use drk::{Decodable, ZKContract};
+use drk::{Decodable, ZkContract};
 use std::fs::File;
 use std::ops::{Add, AddAssign, MulAssign, Neg, SubAssign};
 use std::time::Instant;
@@ -59,7 +59,7 @@ fn main() -> Result<()> {
 
     let start = Instant::now();
     let file = File::open("mimc.zcd")?;
-    let mut contract = ZKContract::decode(file)?;
+    let mut contract = ZkContract::decode(file)?;
     println!(
         "Loaded contract '{}': [{:?}]",
         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::time::Instant;
 
@@ -42,9 +42,9 @@ fn _unpack_u64(value: u64) -> Vec<Scalar> {
 fn main() -> Result<()> {
     let start = Instant::now();
     let file = File::open("mint.zcd")?;
-    let mut visor = ZKContract::decode(file)?;
+    let mut visor = ZkContract::decode(file)?;
     println!("{}", visor.name);
-    //ZKContract::load_contract(bytes);
+    //ZkContract::load_contract(bytes);
     println!("Loaded contract: [{:?}]", start.elapsed());
 
     println!("Stats:");

+ 4 - 4
src/bin/tutorial.rs

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

+ 6 - 6
src/bin/zkvm.rs

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

+ 10 - 10
src/error.rs

@@ -1,10 +1,10 @@
 // TODO: Add support for rusqlite error
 use jsonrpc_core::*;
-use rusqlite;
+//use rusqlite;
 use std::fmt;
 
 use crate::state;
-use crate::vm::ZKVMError;
+use crate::vm::ZkVmError;
 
 pub type Result<T> = std::result::Result<T, Error>;
 
@@ -25,7 +25,7 @@ pub enum Error {
     BadConstraintType,
     InvalidParamName,
     MissingParams,
-    VMError,
+    VmError,
     BadContract,
     Groth16Error,
     RusqliteError(String),
@@ -39,7 +39,7 @@ pub enum Error {
     StrUtf8Error(String),
     NoteDecryptionFailed,
     ServicesError(&'static str),
-    ZMQError(String),
+    ZmqError(String),
     VerifyFailed,
     TryIntoError,
     TryFromError,
@@ -71,7 +71,7 @@ impl fmt::Display for Error {
             Error::BadConstraintType => f.write_str("Bad constraint type byte"),
             Error::InvalidParamName => f.write_str("Invalid param name"),
             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::Groth16Error => f.write_str("Groth16 error"),
             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::NoteDecryptionFailed => f.write_str("Unable to decrypt mint note"),
             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::TryIntoError => f.write_str("TryInto 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.
 impl From<zeromq::ZmqError> for 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::serial::{Decodable, Encodable};
 pub use crate::vm::{
-    AllocType, ConstraintInstruction, CryptoOperation, VariableIndex, VariableRef, ZKVMCircuit,
-    ZKVirtualMachine,
+    AllocType, ConstraintInstruction, CryptoOperation, VariableIndex, VariableRef, ZkVmCircuit,
+    ZkVirtualMachine,
 };
 
 pub type Bytes = Vec<u8>;
 
-pub struct ZKContract {
+pub struct ZkContract {
     pub name: String,
-    pub vm: ZKVirtualMachine,
+    pub vm: ZkVirtualMachine,
     params_map: HashMap<String, VariableIndex>,
     pub params: HashMap<VariableIndex, Scalar>,
     public_map: bimap::BiMap<String, VariableIndex>,
 }
 
-pub struct ZKProof {
+pub struct ZkProof {
     pub public: HashMap<String, Scalar>,
     pub proof: groth16::Proof<Bls12>,
 }
 
-impl ZKContract {
+impl ZkContract {
     // Just have a load() and save()
     // 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
         let user_params: HashSet<_> = self.params.keys().collect();
         let req_params: HashSet<_> = self.params_map.values().collect();
@@ -108,9 +108,9 @@ impl ZKContract {
         }
 
         // 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![];
         for (name, value) in &proof.public {
             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};
 
 /// 64bit identifier for message subscription.
-pub type MessageSubscriptionID = u64;
+pub type MessageSubscriptionId = u64;
 type MessageResult<M> = Result<Arc<M>>;
 
 /// Handles message subscriptions through a subscription ID and a receiver
 /// channel.
 pub struct MessageSubscription<M: Message> {
-    id: MessageSubscriptionID,
+    id: MessageSubscriptionId,
     recv_queue: async_channel::Receiver<MessageResult<M>>,
     parent: Arc<MessageDispatcher<M>>,
 }
@@ -54,7 +54,7 @@ trait MessageDispatcherInterface: Send + Sync {
 /// Maintains a list of active subscribers and handles sending messages across
 /// subscriptions.
 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> {
@@ -66,7 +66,7 @@ impl<M: Message> MessageDispatcher<M> {
     }
 
     /// Create a random ID.
-    fn random_id() -> MessageSubscriptionID {
+    fn random_id() -> MessageSubscriptionId {
         let mut rng = rand::thread_rng();
         rng.gen()
     }
@@ -87,7 +87,7 @@ impl<M: Message> MessageDispatcher<M> {
 
     /// Unsubcribe from a channel. Removes the associated ID from the subscriber
     /// list.
-    async fn unsubscribe(&self, sub_id: MessageSubscriptionID) {
+    async fn unsubscribe(&self, sub_id: MessageSubscriptionId) {
         self.subs.lock().await.remove(&sub_id);
     }
 
@@ -125,7 +125,7 @@ impl<M: Message> MessageDispatcher<M> {
     }
 
     /// 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;
         for id in &ids {
             subs.remove(id);

+ 1 - 1
src/old/bits.rs

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

+ 1 - 1
src/old/mint2.rs

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

+ 7 - 7
src/rpc/adapter.rs

@@ -1,4 +1,4 @@
-use crate::wallet::WalletDB;
+use crate::wallet::WalletDb;
 use crate::Result;
 use async_std::sync::Arc;
 use log::*;
@@ -7,11 +7,11 @@ use log::*;
 pub type AdapterPtr = Arc<RpcAdapter>;
 // Dummy adapter for now
 pub struct RpcAdapter {
-    pub wallet: Arc<WalletDB>,
+    pub wallet: Arc<WalletDb>,
 }
 
 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]");
         Ok(Self { wallet })
     }
@@ -71,15 +71,15 @@ impl RpcAdapter {
     //pub async fn create_
     //pub async fn save_key(&self, pubkey: Vec<u8>) -> Result<()> {
     //    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(())
     //}
 
     //pub async fn save_cash_key(&self, pubkey: Vec<u8>) -> Result<()> {
     //    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(())
     //}
 

+ 2 - 2
src/service/reqrep.rs

@@ -184,7 +184,7 @@ impl ReqProtocol {
 
             Ok(Some(reply.get_payload()))
         } else {
-            Err(crate::Error::ZMQError(
+            Err(crate::Error::ZmqError(
                 "Couldn't parse ZmqMessage".to_string(),
             ))
         }
@@ -263,7 +263,7 @@ impl Subscriber {
                 let data: T = deserialize(&data)?;
                 Ok(data)
             }
-            None => Err(crate::Error::ZMQError(
+            None => Err(crate::Error::ZmqError(
                 "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 SubscriptionID = u64;
+pub type SubscriptionId = u64;
 
 pub struct Subscription<T> {
-    id: SubscriptionID,
+    id: SubscriptionId,
     recv_queue: async_channel::Receiver<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();
         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);
     }
 

+ 15 - 15
src/vm.rs

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

+ 7 - 7
src/vm_serial.rs

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

+ 1 - 1
src/wallet/mod.rs

@@ -1,3 +1,3 @@
 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;
 
-pub type WalletPtr = Arc<WalletDB>;
+pub type WalletPtr = Arc<WalletDb>;
 
-pub struct WalletDB {
+pub struct WalletDb {
     pub path: PathBuf,
     pub secrets: Vec<jubjub::Fr>,
     pub cashier_secrets: Vec<jubjub::Fr>,
@@ -26,7 +26,7 @@ pub struct WalletDB {
     pub password: String,
 }
 
-impl WalletDB {
+impl WalletDb {
     pub fn new(wallet: &str, password: String) -> Result<Self> {
         debug!(target: "walletdb", "new() Constructor called");
         let path = join_config_path(&PathBuf::from(wallet))?;