mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-27 12:17:35 +03:00
add verify local data commitment method to compiler
This commit is contained in:
parent
e1f4fe1846
commit
25468c4ed8
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -1122,6 +1122,7 @@ dependencies = [
|
||||
"leo-ast",
|
||||
"leo-gadgets",
|
||||
"leo-input",
|
||||
"leo-state",
|
||||
"leo-typed",
|
||||
"log",
|
||||
"num-bigint",
|
||||
|
@ -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 }
|
||||
|
@ -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<F: Field + PrimeField, G: GroupType<F>> Compiler<F, G> {
|
||||
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> {
|
||||
// Read in the main file as string
|
||||
let unparsed_file = fs::read_to_string(&self.main_file_path)
|
||||
|
@ -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,
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user