Преглед изворни кода

rename supervisor to simply contract

narodnik пре 5 година
родитељ
комит
b46dfcd322
4 измењених фајлова са 22 додато и 22 уклоњено
  1. 14 14
      src/bin/jubjub.rs
  2. 3 3
      src/bin/mint.rs
  3. 2 2
      src/lib.rs
  4. 3 3
      src/vm_serial.rs

+ 14 - 14
src/bin/jubjub.rs

@@ -1,4 +1,4 @@
-use sapvi::{BlsStringConversion, Decodable, ZKSupervisor};
+use sapvi::{BlsStringConversion, Decodable, ZKContract};
 use std::fs::File;
 use std::fs::File;
 use std::time::Instant;
 use std::time::Instant;
 
 
@@ -14,44 +14,44 @@ 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 visor = ZKSupervisor::decode(file)?;
-    println!("Loaded contract '{}': [{:?}]", visor.name, start.elapsed());
+    let mut contract = ZKContract::decode(file)?;
+    println!("Loaded contract '{}': [{:?}]", contract.name, start.elapsed());
 
 
     println!("Stats:");
     println!("Stats:");
-    println!("    Constants: {}", visor.vm.constants.len());
-    println!("    Alloc: {}", visor.vm.alloc.len());
-    println!("    Operations: {}", visor.vm.ops.len());
+    println!("    Constants: {}", contract.vm.constants.len());
+    println!("    Alloc: {}", contract.vm.alloc.len());
+    println!("    Operations: {}", contract.vm.ops.len());
     println!(
     println!(
         "    Constraint Instructions: {}",
         "    Constraint Instructions: {}",
-        visor.vm.constraints.len()
+        contract.vm.constraints.len()
     );
     );
 
 
     // Do the trusted setup
     // Do the trusted setup
 
 
-    visor.setup();
+    contract.setup();
 
 
     // Put in our input parameters
     // Put in our input parameters
 
 
-    visor.set_param(
+    contract.set_param(
         "x1",
         "x1",
         Scalar::from_string("15a36d1f0f390d8852a35a8c1908dd87a361ee3fd48fdf77b9819dc82d90607e"),
         Scalar::from_string("15a36d1f0f390d8852a35a8c1908dd87a361ee3fd48fdf77b9819dc82d90607e"),
     )?;
     )?;
-    visor.set_param(
+    contract.set_param(
         "y1",
         "y1",
         Scalar::from_string("015d8c7f5b43fe33f7891142c001d9251f3abeeb98fad3e87b0dc53c4ebf1891"),
         Scalar::from_string("015d8c7f5b43fe33f7891142c001d9251f3abeeb98fad3e87b0dc53c4ebf1891"),
     )?;
     )?;
-    visor.set_param(
+    contract.set_param(
         "x2",
         "x2",
         Scalar::from_string("15a36d1f0f390d8852a35a8c1908dd87a361ee3fd48fdf77b9819dc82d90607e"),
         Scalar::from_string("15a36d1f0f390d8852a35a8c1908dd87a361ee3fd48fdf77b9819dc82d90607e"),
     )?;
     )?;
-    visor.set_param(
+    contract.set_param(
         "y2",
         "y2",
         Scalar::from_string("015d8c7f5b43fe33f7891142c001d9251f3abeeb98fad3e87b0dc53c4ebf1891"),
         Scalar::from_string("015d8c7f5b43fe33f7891142c001d9251f3abeeb98fad3e87b0dc53c4ebf1891"),
     )?;
     )?;
 
 
     // Generate the ZK proof
     // Generate the ZK proof
 
 
-    let proof = visor.prove()?;
+    let proof = contract.prove()?;
 
 
     // Test and show our output values
     // Test and show our output values
 
 
@@ -71,7 +71,7 @@ fn main() -> Result<()> {
 
 
     // Verify the proof
     // Verify the proof
 
 
-    assert!(visor.verify(&proof));
+    assert!(contract.verify(&proof));
 
 
     Ok(())
     Ok(())
 }
 }

+ 3 - 3
src/bin/mint.rs

@@ -1,4 +1,4 @@
-use sapvi::{BlsStringConversion, Decodable, ZKSupervisor};
+use sapvi::{BlsStringConversion, 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 = ZKSupervisor::decode(file)?;
+    let mut visor = ZKContract::decode(file)?;
     println!("{}", visor.name);
     println!("{}", visor.name);
-    //ZKSupervisor::load_contract(bytes);
+    //ZKContract::load_contract(bytes);
     println!("Loaded contract: [{:?}]", start.elapsed());
     println!("Loaded contract: [{:?}]", start.elapsed());
 
 
     println!("Stats:");
     println!("Stats:");

+ 2 - 2
src/lib.rs

@@ -19,7 +19,7 @@ pub use crate::vm::{
 
 
 pub type Bytes = Vec<u8>;
 pub type Bytes = Vec<u8>;
 
 
-pub struct ZKSupervisor {
+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>,
@@ -32,7 +32,7 @@ pub struct ZKProof {
     pub proof: groth16::Proof<Bls12>
     pub proof: groth16::Proof<Bls12>
 }
 }
 
 
-impl ZKSupervisor {
+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...
 
 

+ 3 - 3
src/vm_serial.rs

@@ -4,20 +4,20 @@ use crate::vm::{
     AllocType, ConstraintInstruction, CryptoOperation, VariableIndex, VariableRef, ZKVMCircuit,
     AllocType, ConstraintInstruction, CryptoOperation, VariableIndex, VariableRef, ZKVMCircuit,
     ZKVirtualMachine,
     ZKVirtualMachine,
 };
 };
-use crate::{impl_vec, ZKSupervisor};
+use crate::{impl_vec, ZKContract};
 use std::collections::HashMap;
 use std::collections::HashMap;
 use std::io;
 use std::io;
 
 
 impl_vec!((String, VariableIndex));
 impl_vec!((String, VariableIndex));
 
 
-impl Encodable for ZKSupervisor {
+impl Encodable for ZKContract {
     fn encode<S: io::Write>(&self, mut s: S) -> Result<usize> {
     fn encode<S: io::Write>(&self, mut s: S) -> Result<usize> {
         unimplemented!();
         unimplemented!();
         Ok(0)
         Ok(0)
     }
     }
 }
 }
 
 
-impl Decodable for ZKSupervisor {
+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)?,