mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
rename supervisor to simply contract
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use sapvi::{BlsStringConversion, Decodable, ZKSupervisor};
|
||||
use sapvi::{BlsStringConversion, Decodable, ZKContract};
|
||||
use std::fs::File;
|
||||
use std::time::Instant;
|
||||
|
||||
@@ -14,44 +14,44 @@ fn main() -> Result<()> {
|
||||
|
||||
let start = Instant::now();
|
||||
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!(" 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!(
|
||||
" Constraint Instructions: {}",
|
||||
visor.vm.constraints.len()
|
||||
contract.vm.constraints.len()
|
||||
);
|
||||
|
||||
// Do the trusted setup
|
||||
|
||||
visor.setup();
|
||||
contract.setup();
|
||||
|
||||
// Put in our input parameters
|
||||
|
||||
visor.set_param(
|
||||
contract.set_param(
|
||||
"x1",
|
||||
Scalar::from_string("15a36d1f0f390d8852a35a8c1908dd87a361ee3fd48fdf77b9819dc82d90607e"),
|
||||
)?;
|
||||
visor.set_param(
|
||||
contract.set_param(
|
||||
"y1",
|
||||
Scalar::from_string("015d8c7f5b43fe33f7891142c001d9251f3abeeb98fad3e87b0dc53c4ebf1891"),
|
||||
)?;
|
||||
visor.set_param(
|
||||
contract.set_param(
|
||||
"x2",
|
||||
Scalar::from_string("15a36d1f0f390d8852a35a8c1908dd87a361ee3fd48fdf77b9819dc82d90607e"),
|
||||
)?;
|
||||
visor.set_param(
|
||||
contract.set_param(
|
||||
"y2",
|
||||
Scalar::from_string("015d8c7f5b43fe33f7891142c001d9251f3abeeb98fad3e87b0dc53c4ebf1891"),
|
||||
)?;
|
||||
|
||||
// Generate the ZK proof
|
||||
|
||||
let proof = visor.prove()?;
|
||||
let proof = contract.prove()?;
|
||||
|
||||
// Test and show our output values
|
||||
|
||||
@@ -71,7 +71,7 @@ fn main() -> Result<()> {
|
||||
|
||||
// Verify the proof
|
||||
|
||||
assert!(visor.verify(&proof));
|
||||
assert!(contract.verify(&proof));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use sapvi::{BlsStringConversion, Decodable, ZKSupervisor};
|
||||
use sapvi::{BlsStringConversion, 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 = ZKSupervisor::decode(file)?;
|
||||
let mut visor = ZKContract::decode(file)?;
|
||||
println!("{}", visor.name);
|
||||
//ZKSupervisor::load_contract(bytes);
|
||||
//ZKContract::load_contract(bytes);
|
||||
println!("Loaded contract: [{:?}]", start.elapsed());
|
||||
|
||||
println!("Stats:");
|
||||
|
||||
@@ -19,7 +19,7 @@ pub use crate::vm::{
|
||||
|
||||
pub type Bytes = Vec<u8>;
|
||||
|
||||
pub struct ZKSupervisor {
|
||||
pub struct ZKContract {
|
||||
pub name: String,
|
||||
pub vm: ZKVirtualMachine,
|
||||
params_map: HashMap<String, VariableIndex>,
|
||||
@@ -32,7 +32,7 @@ pub struct ZKProof {
|
||||
pub proof: groth16::Proof<Bls12>
|
||||
}
|
||||
|
||||
impl ZKSupervisor {
|
||||
impl ZKContract {
|
||||
// Just have a load() and save()
|
||||
// Load the contract, do the setup, save it...
|
||||
|
||||
|
||||
@@ -4,20 +4,20 @@ use crate::vm::{
|
||||
AllocType, ConstraintInstruction, CryptoOperation, VariableIndex, VariableRef, ZKVMCircuit,
|
||||
ZKVirtualMachine,
|
||||
};
|
||||
use crate::{impl_vec, ZKSupervisor};
|
||||
use crate::{impl_vec, ZKContract};
|
||||
use std::collections::HashMap;
|
||||
use std::io;
|
||||
|
||||
impl_vec!((String, VariableIndex));
|
||||
|
||||
impl Encodable for ZKSupervisor {
|
||||
impl Encodable for ZKContract {
|
||||
fn encode<S: io::Write>(&self, mut s: S) -> Result<usize> {
|
||||
unimplemented!();
|
||||
Ok(0)
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for ZKSupervisor {
|
||||
impl Decodable for ZKContract {
|
||||
fn decode<D: io::Read>(mut d: D) -> Result<Self> {
|
||||
Ok(Self {
|
||||
name: Decodable::decode(&mut d)?,
|
||||
|
||||
Reference in New Issue
Block a user