add verify local data commitment method to compiler

This commit is contained in:
collin 2020-08-16 00:28:39 -07:00
parent e1f4fe1846
commit 25468c4ed8
4 changed files with 18 additions and 0 deletions

1
Cargo.lock generated
View File

@ -1122,6 +1122,7 @@ dependencies = [
"leo-ast", "leo-ast",
"leo-gadgets", "leo-gadgets",
"leo-input", "leo-input",
"leo-state",
"leo-typed", "leo-typed",
"log", "log",
"num-bigint", "num-bigint",

View File

@ -9,6 +9,7 @@ leo-ast = { path = "../ast", version = "0.1.0" }
leo-gadgets = { path = "../gadgets", version = "0.1.0" } leo-gadgets = { path = "../gadgets", version = "0.1.0" }
leo-input = { path = "../input", version = "0.1.0" } leo-input = { path = "../input", version = "0.1.0" }
leo-typed = { path = "../typed", 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-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 } snarkos-dpc = { git = "ssh://git@github.com/AleoHQ/snarkOS.git", package = "snarkos-dpc", default-features = false }

View File

@ -10,8 +10,10 @@ use crate::{
}; };
use leo_ast::LeoAst; use leo_ast::LeoAst;
use leo_input::LeoInputParser; use leo_input::LeoInputParser;
use leo_state::verify_local_data_commitment;
use leo_typed::{Input, LeoTypedAst, MainInput, Program}; use leo_typed::{Input, LeoTypedAst, MainInput, Program};
use snarkos_dpc::{base_dpc::instantiated::Components, SystemParameters};
use snarkos_errors::gadgets::SynthesisError; use snarkos_errors::gadgets::SynthesisError;
use snarkos_models::{ use snarkos_models::{
curves::{Field, PrimeField}, curves::{Field, PrimeField},
@ -124,6 +126,16 @@ impl<F: Field + PrimeField, G: GroupType<F>> Compiler<F, G> {
self.program_input.set_main_input(input); self.program_input.set_main_input(input);
} }
/// Verifies the input to the program
pub fn verify_local_data_commitment(
&self,
system_parameters: &SystemParameters<Components>,
) -> Result<bool, CompilerError> {
let result = verify_local_data_commitment(system_parameters, &self.program_input)?;
Ok(result)
}
pub fn checksum(&self) -> Result<String, CompilerError> { pub fn checksum(&self) -> Result<String, CompilerError> {
// Read in the main file as string // Read in the main file as string
let unparsed_file = fs::read_to_string(&self.main_file_path) let unparsed_file = fs::read_to_string(&self.main_file_path)

View File

@ -1,6 +1,7 @@
use crate::errors::{FunctionError, ImportError, OutputBytesError, OutputFileError}; use crate::errors::{FunctionError, ImportError, OutputBytesError, OutputFileError};
use leo_ast::ParserError; use leo_ast::ParserError;
use leo_input::InputParserError; use leo_input::InputParserError;
use leo_state::LocalDataVerificationError;
use bincode::Error as SerdeError; use bincode::Error as SerdeError;
use std::path::PathBuf; use std::path::PathBuf;
@ -19,6 +20,9 @@ pub enum CompilerError {
#[error("Cannot read from the provided file path - {:?}", _0)] #[error("Cannot read from the provided file path - {:?}", _0)]
FileReadError(PathBuf), FileReadError(PathBuf),
#[error("{}", _0)]
LocalDataVerificationError(#[from] LocalDataVerificationError),
#[error("`main` function not found")] #[error("`main` function not found")]
NoMain, NoMain,