diff --git a/Cargo.lock b/Cargo.lock index 1f459ba6e8..f35728510e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1122,6 +1122,7 @@ dependencies = [ "leo-ast", "leo-gadgets", "leo-input", + "leo-state", "leo-typed", "log", "num-bigint", diff --git a/compiler/Cargo.toml b/compiler/Cargo.toml index 35bf31e318..c4d27487d9 100644 --- a/compiler/Cargo.toml +++ b/compiler/Cargo.toml @@ -9,6 +9,7 @@ leo-ast = { path = "../ast", version = "0.1.0" } leo-gadgets = { path = "../gadgets", version = "0.1.0" } leo-input = { path = "../input", version = "0.1.0" } leo-typed = { path = "../typed", version = "0.1.0" } +leo-state = { path = "../state", version = "0.1.0" } snarkos-curves = { git = "ssh://git@github.com/AleoHQ/snarkOS.git", package = "snarkos-curves", default-features = false } snarkos-dpc = { git = "ssh://git@github.com/AleoHQ/snarkOS.git", package = "snarkos-dpc", default-features = false } diff --git a/compiler/src/compiler.rs b/compiler/src/compiler.rs index bcde2061c4..949a46e5f9 100644 --- a/compiler/src/compiler.rs +++ b/compiler/src/compiler.rs @@ -10,8 +10,10 @@ use crate::{ }; use leo_ast::LeoAst; use leo_input::LeoInputParser; +use leo_state::verify_local_data_commitment; use leo_typed::{Input, LeoTypedAst, MainInput, Program}; +use snarkos_dpc::{base_dpc::instantiated::Components, SystemParameters}; use snarkos_errors::gadgets::SynthesisError; use snarkos_models::{ curves::{Field, PrimeField}, @@ -124,6 +126,16 @@ impl> Compiler { self.program_input.set_main_input(input); } + /// Verifies the input to the program + pub fn verify_local_data_commitment( + &self, + system_parameters: &SystemParameters, + ) -> Result { + let result = verify_local_data_commitment(system_parameters, &self.program_input)?; + + Ok(result) + } + pub fn checksum(&self) -> Result { // Read in the main file as string let unparsed_file = fs::read_to_string(&self.main_file_path) diff --git a/compiler/src/errors/compiler.rs b/compiler/src/errors/compiler.rs index ff76268520..42293a676c 100644 --- a/compiler/src/errors/compiler.rs +++ b/compiler/src/errors/compiler.rs @@ -1,6 +1,7 @@ use crate::errors::{FunctionError, ImportError, OutputBytesError, OutputFileError}; use leo_ast::ParserError; use leo_input::InputParserError; +use leo_state::LocalDataVerificationError; use bincode::Error as SerdeError; use std::path::PathBuf; @@ -19,6 +20,9 @@ pub enum CompilerError { #[error("Cannot read from the provided file path - {:?}", _0)] FileReadError(PathBuf), + #[error("{}", _0)] + LocalDataVerificationError(#[from] LocalDataVerificationError), + #[error("`main` function not found")] NoMain,