mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-23 23:23:50 +03:00
update field and group modules
This commit is contained in:
parent
a6092e9a2f
commit
b0acd5ea5a
@ -111,7 +111,7 @@ type_u64 = { "u64" }
|
||||
type_u128 = { "u128" }
|
||||
|
||||
// Declared in types/field_type.rs
|
||||
type_field = { "value.field" }
|
||||
type_field = { "field" }
|
||||
|
||||
// Declared in types/group_type.rs
|
||||
type_group = { "group" }
|
||||
|
@ -3,9 +3,14 @@
|
||||
|
||||
use crate::{
|
||||
address::Address,
|
||||
constraints::{group::group_from_input, new_scope, ConstrainedProgram},
|
||||
constraints::{new_scope, ConstrainedProgram},
|
||||
errors::{FunctionError, StatementError},
|
||||
value::{boolean::input::bool_from_input, field::input::field_from_input, ConstrainedValue},
|
||||
value::{
|
||||
boolean::input::bool_from_input,
|
||||
field::input::field_from_input,
|
||||
group::input::group_from_input,
|
||||
ConstrainedValue,
|
||||
},
|
||||
GroupType,
|
||||
Integer,
|
||||
};
|
||||
|
@ -9,8 +9,6 @@ pub use self::expression::*;
|
||||
pub mod generate_constraints;
|
||||
pub use self::generate_constraints::*;
|
||||
|
||||
pub mod group;
|
||||
|
||||
pub mod program;
|
||||
pub use self::program::*;
|
||||
|
||||
|
@ -15,9 +15,6 @@ pub mod definitions;
|
||||
|
||||
pub mod errors;
|
||||
|
||||
pub mod group;
|
||||
pub use self::group::*;
|
||||
|
||||
pub mod imports;
|
||||
pub use self::imports::*;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
//! Methods to enforce constraints on an input boolean value in a resolved Leo program.
|
||||
//! Methods to enforce constraints on input boolean values in a resolved Leo program.
|
||||
|
||||
use crate::{errors::BooleanError, value::ConstrainedValue, GroupType};
|
||||
use leo_types::{InputValue, Span};
|
||||
|
@ -1,4 +1,4 @@
|
||||
//! A data type that represents a value.field value
|
||||
//! A data type that represents a field value
|
||||
|
||||
use crate::{
|
||||
comparator::{ComparatorGadget, EvaluateLtGadget},
|
||||
|
@ -1,4 +1,4 @@
|
||||
//! Methods to enforce constraints on value.field elements in a resolved Leo program.
|
||||
//! Methods to enforce constraints on input field values in a resolved Leo program.
|
||||
|
||||
use crate::{errors::FieldError, value::ConstrainedValue, FieldType, GroupType};
|
||||
use leo_types::{InputValue, Span};
|
||||
|
@ -1,3 +1,5 @@
|
||||
//! Methods to enforce constraints on fields in a resolved Leo program.
|
||||
|
||||
pub mod input;
|
||||
|
||||
pub mod field_type;
|
||||
|
@ -18,8 +18,6 @@ use snarkos_models::{
|
||||
};
|
||||
use std::fmt::{Debug, Display};
|
||||
|
||||
pub mod edwards_bls12;
|
||||
|
||||
pub trait GroupType<F: Field>:
|
||||
Sized
|
||||
+ Clone
|
8
compiler/src/value/group/mod.rs
Normal file
8
compiler/src/value/group/mod.rs
Normal file
@ -0,0 +1,8 @@
|
||||
//! Methods to enforce constraints on points in the affine group in a resolved Leo program.
|
||||
|
||||
pub mod input;
|
||||
|
||||
pub mod group_type;
|
||||
pub use self::group_type::*;
|
||||
|
||||
pub mod targets;
|
1
compiler/src/value/group/targets/mod.rs
Normal file
1
compiler/src/value/group/targets/mod.rs
Normal file
@ -0,0 +1 @@
|
||||
pub mod edwards_bls12;
|
@ -1,12 +1,17 @@
|
||||
//! Methods to enforce constraints on values in a resolved Leo program.
|
||||
|
||||
pub mod boolean;
|
||||
|
||||
pub(crate) mod comparator;
|
||||
|
||||
pub mod integer;
|
||||
pub use self::integer::*;
|
||||
|
||||
pub mod field;
|
||||
pub use self::field::*;
|
||||
|
||||
pub mod group;
|
||||
pub use self::group::*;
|
||||
|
||||
pub mod integer;
|
||||
pub use self::integer::*;
|
||||
|
||||
pub mod value;
|
||||
pub use self::value::*;
|
||||
|
@ -1,3 +1,3 @@
|
||||
function main(a: value.field, b: value.field) -> value.field {
|
||||
function main(a: field, b: field) -> field {
|
||||
return a + b
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: value.field, b: value.field) {
|
||||
function main(a: field, b: field) {
|
||||
assert_eq!(a, b);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: value.field, b: value.field) -> value.field {
|
||||
function main(a: field, b: field) -> field {
|
||||
return a / b
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: value.field, b: value.field) -> bool {
|
||||
function main(a: field, b: field) -> bool {
|
||||
return a == b
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: value.field, b: value.field) -> bool {
|
||||
function main(a: field, b: field) -> bool {
|
||||
return a >= b
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: value.field, b: value.field) -> bool {
|
||||
function main(a: field, b: field) -> bool {
|
||||
return a > b
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(f: value.field) -> value.field{
|
||||
function main(f: field) -> field{
|
||||
return f
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: value.field, b: value.field) -> bool {
|
||||
function main(a: field, b: field) -> bool {
|
||||
return a <= b
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: value.field, b: value.field) -> bool {
|
||||
function main(a: field, b: field) -> bool {
|
||||
return a < b
|
||||
}
|
@ -55,7 +55,7 @@ fn output_one(program: EdwardsTestCompiler) {
|
||||
fn fail_field(program: EdwardsTestCompiler) {
|
||||
match get_error(program) {
|
||||
CompilerError::FunctionError(FunctionError::FieldError(FieldError::Error(_string))) => {}
|
||||
error => panic!("Expected invalid value.field error, got {}", error),
|
||||
error => panic!("Expected invalid field error, got {}", error),
|
||||
}
|
||||
}
|
||||
|
||||
@ -450,7 +450,7 @@ fn test_ternary() {
|
||||
let mut program_1 = parse_program(bytes).unwrap();
|
||||
let mut program_2 = program_1.clone();
|
||||
|
||||
// true -> value.field 1
|
||||
// true -> field 1
|
||||
program_1.set_inputs(vec![
|
||||
Some(InputValue::Boolean(true)),
|
||||
Some(InputValue::Field(r1.to_string())),
|
||||
@ -459,7 +459,7 @@ fn test_ternary() {
|
||||
|
||||
output_expected_allocated(program_1, g1);
|
||||
|
||||
// false -> value.field 2
|
||||
// false -> field 2
|
||||
program_2.set_inputs(vec![
|
||||
Some(InputValue::Boolean(false)),
|
||||
Some(InputValue::Field(r1.to_string())),
|
||||
|
@ -1,3 +1,3 @@
|
||||
function main(a: value.field, b: value.field) -> value.field {
|
||||
function main(a: field, b: field) -> field {
|
||||
return a * b
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main() -> value.field {
|
||||
function main() -> field {
|
||||
return 1field
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(a: value.field, b: value.field) -> value.field {
|
||||
function main(a: field, b: field) -> field {
|
||||
return a - b
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main(b: bool, f1: value.field, f2: value.field) -> value.field {
|
||||
function main(b: bool, f1: field, f2: field) -> field {
|
||||
return if b ? f1 : f2
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main() -> value.field {
|
||||
function main() -> field {
|
||||
return 0field
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
function foo() -> value.field {
|
||||
function foo() -> field {
|
||||
return myGlobal
|
||||
}
|
||||
|
||||
function main() -> value.field {
|
||||
function main() -> field {
|
||||
const myGlobal = 42field;
|
||||
return foo()
|
||||
}
|
@ -6,7 +6,7 @@ use crate::{
|
||||
EdwardsConstrainedValue,
|
||||
EdwardsTestCompiler,
|
||||
};
|
||||
use leo_compiler::{group::edwards_bls12::EdwardsGroupType, ConstrainedValue};
|
||||
use leo_compiler::{group::targets::edwards_bls12::EdwardsGroupType, ConstrainedValue};
|
||||
use leo_types::InputValue;
|
||||
|
||||
use snarkos_curves::edwards_bls12::{EdwardsAffine, EdwardsParameters, Fq};
|
||||
|
@ -15,7 +15,7 @@ pub mod syntax;
|
||||
use leo_compiler::{
|
||||
compiler::Compiler,
|
||||
errors::{CompilerError, FunctionError, StatementError},
|
||||
group::edwards_bls12::EdwardsGroupType,
|
||||
group::targets::edwards_bls12::EdwardsGroupType,
|
||||
ConstrainedValue,
|
||||
};
|
||||
|
||||
|
@ -5,7 +5,7 @@ use crate::{
|
||||
errors::CLIError,
|
||||
files::{ChecksumFile, LibFile, MainFile, Manifest, LIB_FILE_NAME, MAIN_FILE_NAME},
|
||||
};
|
||||
use leo_compiler::{compiler::Compiler, group::edwards_bls12::EdwardsGroupType};
|
||||
use leo_compiler::{compiler::Compiler, group::targets::edwards_bls12::EdwardsGroupType};
|
||||
|
||||
use snarkos_algorithms::snark::KeypairAssembly;
|
||||
use snarkos_curves::{bls12_377::Bls12_377, edwards_bls12::Fq};
|
||||
|
@ -6,7 +6,7 @@ use crate::{
|
||||
errors::{CLIError, RunError, VerificationKeyFileError},
|
||||
files::{Manifest, ProvingKeyFile, VerificationKeyFile, MAIN_FILE_NAME},
|
||||
};
|
||||
use leo_compiler::{compiler::Compiler, group::edwards_bls12::EdwardsGroupType};
|
||||
use leo_compiler::{compiler::Compiler, group::targets::edwards_bls12::EdwardsGroupType};
|
||||
|
||||
use snarkos_algorithms::snark::{generate_random_parameters, prepare_verifying_key, Parameters, PreparedVerifyingKey};
|
||||
use snarkos_curves::{bls12_377::Bls12_377, edwards_bls12::Fq};
|
||||
|
@ -5,7 +5,7 @@ use crate::{
|
||||
errors::{CLIError, TestError},
|
||||
files::{MainFile, Manifest, MAIN_FILE_NAME},
|
||||
};
|
||||
use leo_compiler::{compiler::Compiler, group::edwards_bls12::EdwardsGroupType};
|
||||
use leo_compiler::{compiler::Compiler, group::targets::edwards_bls12::EdwardsGroupType};
|
||||
|
||||
use snarkos_curves::edwards_bls12::Fq;
|
||||
use snarkos_models::gadgets::r1cs::TestConstraintSystem;
|
||||
|
Loading…
Reference in New Issue
Block a user