Checkpoint for further wasm compatibility

This commit is contained in:
howardwu 2021-02-27 08:57:44 -08:00
parent ec056a2877
commit a0b6dba14d
2 changed files with 45 additions and 0 deletions

View File

@ -20,6 +20,10 @@ edition = "2018"
[lib]
crate-type = [ "cdylib", "rlib" ]
#[dependencies.snarkvm-curves]
#version = "0.0.5"
#default-features = false
[dependencies.leo-asg]
path = "../asg"
version = "1.2.3"
@ -36,6 +40,11 @@ version = "1.2.3"
path = "../imports"
version = "1.2.3"
#[dependencies.leo-synthesizer]
#path = "../synthesizer"
#version = "1.2.3"
#default-features = false
[dependencies.serde]
version = "1.0"
features = [ "derive" ]

View File

@ -16,6 +16,9 @@
use crate::{asg::Asg, ast::Ast};
use leo_compiler::generate_constraints;
// use leo_synthesizer::CircuitSynthesizer;
// use snarkvm_curves::Bls12_377;
use std::path::Path;
use wasm_bindgen::prelude::*;
@ -30,6 +33,39 @@ impl Compiler {
let ast = Ast::new(filepath, program_name, program_string).unwrap();
let asg = Asg::from(&ast);
// Generate the program on the constraint system and verify correctness
{
// let mut cs = CircuitSynthesizer::<Bls12_377> {
// at: vec![],
// bt: vec![],
// ct: vec![],
// input_assignment: vec![],
// aux_assignment: vec![],
// };
// let temporary_program = program.clone();
// let output = temporary_program.compile_constraints(&mut cs)?;
//
// tracing::debug!("Compiled output - {:#?}", output);
// tracing::info!("Number of constraints - {:#?}", cs.num_constraints());
//
// // Serialize the circuit
// let circuit_object = SerializedCircuit::from(cs);
// let json = circuit_object.to_json_string().unwrap();
// // println!("json: {}", json);
//
// // Write serialized circuit to circuit `.json` file.
// let circuit_file = CircuitFile::new(&package_name);
// circuit_file.write_to(&path, json)?;
// Check that we can read the serialized circuit file
// let serialized = circuit_file.read_from(&package_path)?;
// Deserialize the circuit
// let deserialized = SerializedCircuit::from_json_string(&serialized).unwrap();
// let _circuit_synthesizer = CircuitSynthesizer::<Bls12_377>::try_from(deserialized).unwrap();
// println!("deserialized {:?}", circuit_synthesizer.num_constraints());
}
// TODO (howardwu): Support program inputs.
generate_constraints(cs, &asg.as_ref().unwrap(), &Input::new()).unwrap();
Self(ast.to_string())