mirror of
https://github.com/AleoHQ/leo.git
synced 2024-11-29 03:35:10 +03:00
refactor Field + PrimeField -> PrimeField, all tests still pass
This commit is contained in:
parent
a7c9caf4b3
commit
ba3ca6069a
@ -33,7 +33,7 @@ use leo_state::verify_local_data_commitment;
|
||||
use snarkvm_dpc::{base_dpc::instantiated::Components, SystemParameters};
|
||||
use snarkvm_errors::gadgets::SynthesisError;
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
curves::PrimeField,
|
||||
gadgets::r1cs::{ConstraintSynthesizer, ConstraintSystem},
|
||||
};
|
||||
|
||||
@ -46,7 +46,7 @@ use std::{
|
||||
|
||||
/// Stores information to compile a Leo program.
|
||||
#[derive(Clone)]
|
||||
pub struct Compiler<F: Field + PrimeField, G: GroupType<F>> {
|
||||
pub struct Compiler<F: PrimeField, G: GroupType<F>> {
|
||||
program_name: String,
|
||||
main_file_path: PathBuf,
|
||||
output_directory: PathBuf,
|
||||
@ -57,7 +57,7 @@ pub struct Compiler<F: Field + PrimeField, G: GroupType<F>> {
|
||||
_group: PhantomData<G>,
|
||||
}
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> Compiler<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> Compiler<F, G> {
|
||||
///
|
||||
/// Returns a new Leo program compiler.
|
||||
///
|
||||
@ -261,7 +261,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> Compiler<F, G> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstraintSynthesizer<F> for Compiler<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstraintSynthesizer<F> for Compiler<F, G> {
|
||||
///
|
||||
/// Synthesizes the circuit with program input.
|
||||
///
|
||||
|
@ -27,11 +27,11 @@ use leo_asg::{Expression, Span};
|
||||
use std::sync::Arc;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
curves::PrimeField,
|
||||
gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean},
|
||||
};
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
pub fn evaluate_console_assert<CS: ConstraintSystem<F>>(
|
||||
&mut self,
|
||||
cs: &mut CS,
|
||||
|
@ -20,11 +20,11 @@ use crate::{errors::ConsoleError, program::ConstrainedProgram, statement::get_in
|
||||
use leo_asg::{ConsoleFunction, ConsoleStatement};
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
curves::PrimeField,
|
||||
gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean},
|
||||
};
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
pub fn evaluate_console_function_call<CS: ConstraintSystem<F>>(
|
||||
&mut self,
|
||||
cs: &mut CS,
|
||||
|
@ -19,12 +19,9 @@
|
||||
use crate::{errors::ConsoleError, program::ConstrainedProgram, GroupType};
|
||||
use leo_asg::FormattedString;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
gadgets::r1cs::ConstraintSystem,
|
||||
};
|
||||
use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem};
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
pub fn format<CS: ConstraintSystem<F>>(
|
||||
&mut self,
|
||||
cs: &mut CS,
|
||||
|
@ -23,12 +23,12 @@ use leo_input::LeoInputParser;
|
||||
use leo_package::inputs::InputPairs;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
curves::PrimeField,
|
||||
gadgets::r1cs::{ConstraintSystem, TestConstraintSystem},
|
||||
};
|
||||
use std::path::Path;
|
||||
|
||||
pub fn generate_constraints<F: Field + PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
pub fn generate_constraints<F: PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
cs: &mut CS,
|
||||
asg: &Asg,
|
||||
input: &Input,
|
||||
@ -50,7 +50,7 @@ pub fn generate_constraints<F: Field + PrimeField, G: GroupType<F>, CS: Constrai
|
||||
}
|
||||
}
|
||||
|
||||
pub fn generate_test_constraints<F: Field + PrimeField, G: GroupType<F>>(
|
||||
pub fn generate_test_constraints<F: PrimeField, G: GroupType<F>>(
|
||||
asg: &Asg,
|
||||
input: InputPairs,
|
||||
main_file_path: &Path,
|
||||
|
@ -19,9 +19,9 @@
|
||||
use crate::{program::ConstrainedProgram, value::ConstrainedValue, GroupType};
|
||||
use leo_asg::Variable;
|
||||
|
||||
use snarkvm_models::curves::{Field, PrimeField};
|
||||
use snarkvm_models::curves::PrimeField;
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
pub fn store_definition(&mut self, variable: &Variable, value: ConstrainedValue<F, G>) {
|
||||
let variable = variable.borrow();
|
||||
|
||||
|
@ -19,12 +19,9 @@
|
||||
use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType};
|
||||
use leo_ast::Span;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
gadgets::r1cs::ConstraintSystem,
|
||||
};
|
||||
use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem};
|
||||
|
||||
pub fn enforce_add<F: Field + PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
pub fn enforce_add<F: PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
cs: &mut CS,
|
||||
left: ConstrainedValue<F, G>,
|
||||
right: ConstrainedValue<F, G>,
|
||||
|
@ -19,12 +19,9 @@
|
||||
use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType};
|
||||
use leo_ast::Span;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
gadgets::r1cs::ConstraintSystem,
|
||||
};
|
||||
use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem};
|
||||
|
||||
pub fn enforce_div<F: Field + PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
pub fn enforce_div<F: PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
cs: &mut CS,
|
||||
left: ConstrainedValue<F, G>,
|
||||
right: ConstrainedValue<F, G>,
|
||||
|
@ -19,12 +19,9 @@
|
||||
use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType};
|
||||
use leo_ast::Span;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
gadgets::r1cs::ConstraintSystem,
|
||||
};
|
||||
use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem};
|
||||
|
||||
pub fn enforce_mul<F: Field + PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
pub fn enforce_mul<F: PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
cs: &mut CS,
|
||||
left: ConstrainedValue<F, G>,
|
||||
right: ConstrainedValue<F, G>,
|
||||
|
@ -19,12 +19,9 @@
|
||||
use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType};
|
||||
use leo_ast::Span;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
gadgets::r1cs::ConstraintSystem,
|
||||
};
|
||||
use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem};
|
||||
|
||||
pub fn enforce_negate<F: Field + PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
pub fn enforce_negate<F: PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
cs: &mut CS,
|
||||
value: ConstrainedValue<F, G>,
|
||||
span: &Span,
|
||||
|
@ -19,12 +19,9 @@
|
||||
use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType};
|
||||
use leo_ast::Span;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
gadgets::r1cs::ConstraintSystem,
|
||||
};
|
||||
use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem};
|
||||
|
||||
pub fn enforce_pow<F: Field + PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
pub fn enforce_pow<F: PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
cs: &mut CS,
|
||||
left: ConstrainedValue<F, G>,
|
||||
right: ConstrainedValue<F, G>,
|
||||
|
@ -19,12 +19,9 @@
|
||||
use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType};
|
||||
use leo_ast::Span;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
gadgets::r1cs::ConstraintSystem,
|
||||
};
|
||||
use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem};
|
||||
|
||||
pub fn enforce_sub<F: Field + PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
pub fn enforce_sub<F: PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
cs: &mut CS,
|
||||
left: ConstrainedValue<F, G>,
|
||||
right: ConstrainedValue<F, G>,
|
||||
|
@ -20,12 +20,9 @@ use crate::{errors::ExpressionError, program::ConstrainedProgram, value::Constra
|
||||
use leo_asg::{Expression, Span};
|
||||
use std::sync::Arc;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
gadgets::r1cs::ConstraintSystem,
|
||||
};
|
||||
use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem};
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn enforce_array_access<CS: ConstraintSystem<F>>(
|
||||
&mut self,
|
||||
|
@ -20,12 +20,9 @@ use crate::{errors::ExpressionError, program::ConstrainedProgram, value::Constra
|
||||
use leo_asg::{Expression, Span};
|
||||
use std::sync::Arc;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
gadgets::r1cs::ConstraintSystem,
|
||||
};
|
||||
use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem};
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
/// Enforce array expressions
|
||||
pub fn enforce_array<CS: ConstraintSystem<F>>(
|
||||
&mut self,
|
||||
|
@ -20,12 +20,9 @@ use crate::{errors::ExpressionError, program::ConstrainedProgram, value::Constra
|
||||
use leo_asg::{Expression, Span};
|
||||
use std::sync::Arc;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
gadgets::r1cs::ConstraintSystem,
|
||||
};
|
||||
use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem};
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
pub(crate) fn enforce_index<CS: ConstraintSystem<F>>(
|
||||
&mut self,
|
||||
cs: &mut CS,
|
||||
|
@ -20,14 +20,11 @@ use crate::{errors::ExpressionError, program::ConstrainedProgram, value::Constra
|
||||
use leo_asg::Expression;
|
||||
use std::sync::Arc;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
gadgets::r1cs::ConstraintSystem,
|
||||
};
|
||||
use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem};
|
||||
|
||||
type ConstrainedValuePair<T, U> = (ConstrainedValue<T, U>, ConstrainedValue<T, U>);
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn enforce_binary_expression<CS: ConstraintSystem<F>>(
|
||||
&mut self,
|
||||
|
@ -19,12 +19,9 @@
|
||||
use crate::{errors::ExpressionError, program::ConstrainedProgram, value::ConstrainedValue, GroupType};
|
||||
use leo_asg::{CircuitAccessExpression, Node};
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
gadgets::r1cs::ConstraintSystem,
|
||||
};
|
||||
use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem};
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn enforce_circuit_access<CS: ConstraintSystem<F>>(
|
||||
&mut self,
|
||||
|
@ -24,12 +24,9 @@ use crate::{
|
||||
};
|
||||
use leo_asg::{CircuitInitExpression, CircuitMemberBody, Span};
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
gadgets::r1cs::ConstraintSystem,
|
||||
};
|
||||
use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem};
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
pub fn enforce_circuit<CS: ConstraintSystem<F>>(
|
||||
&mut self,
|
||||
cs: &mut CS,
|
||||
|
@ -21,11 +21,11 @@ use leo_asg::{Expression, Span};
|
||||
use std::sync::Arc;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
curves::PrimeField,
|
||||
gadgets::{r1cs::ConstraintSystem, utilities::select::CondSelectGadget},
|
||||
};
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
/// Enforce ternary conditional expression
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn enforce_conditional_expression<CS: ConstraintSystem<F>>(
|
||||
|
@ -31,11 +31,11 @@ use leo_asg::{expression::*, ConstValue, Expression, Node};
|
||||
use std::sync::Arc;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
curves::PrimeField,
|
||||
gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean},
|
||||
};
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
pub(crate) fn enforce_expression<CS: ConstraintSystem<F>>(
|
||||
&mut self,
|
||||
cs: &mut CS,
|
||||
|
@ -17,13 +17,10 @@ use crate::{program::ConstrainedProgram, value::ConstrainedValue, CoreCircuit, G
|
||||
|
||||
use crate::errors::ExpressionError;
|
||||
use leo_asg::{Expression, Function, Span};
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
gadgets::r1cs::ConstraintSystem,
|
||||
};
|
||||
use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem};
|
||||
use std::sync::Arc;
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
/// Call a default core circuit function with arguments
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn enforce_core_circuit_call_expression<CS: ConstraintSystem<F>, C: CoreCircuit<F, G>>(
|
||||
|
@ -20,12 +20,9 @@ use crate::{errors::ExpressionError, program::ConstrainedProgram, value::Constra
|
||||
use leo_asg::{Expression, Function, Span};
|
||||
use std::sync::Arc;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
gadgets::r1cs::ConstraintSystem,
|
||||
};
|
||||
use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem};
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn enforce_function_call_expression<CS: ConstraintSystem<F>>(
|
||||
&mut self,
|
||||
|
@ -20,11 +20,11 @@ use crate::{errors::BooleanError, value::ConstrainedValue, GroupType};
|
||||
use leo_asg::Span;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
curves::PrimeField,
|
||||
gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean},
|
||||
};
|
||||
|
||||
pub fn enforce_and<F: Field + PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
pub fn enforce_and<F: PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
cs: &mut CS,
|
||||
left: ConstrainedValue<F, G>,
|
||||
right: ConstrainedValue<F, G>,
|
||||
|
@ -19,9 +19,9 @@
|
||||
use crate::{errors::BooleanError, value::ConstrainedValue, GroupType};
|
||||
use leo_asg::Span;
|
||||
|
||||
use snarkvm_models::curves::{Field, PrimeField};
|
||||
use snarkvm_models::curves::PrimeField;
|
||||
|
||||
pub fn evaluate_not<F: Field + PrimeField, G: GroupType<F>>(
|
||||
pub fn evaluate_not<F: PrimeField, G: GroupType<F>>(
|
||||
value: ConstrainedValue<F, G>,
|
||||
span: &Span,
|
||||
) -> Result<ConstrainedValue<F, G>, BooleanError> {
|
||||
|
@ -20,11 +20,11 @@ use crate::{errors::BooleanError, value::ConstrainedValue, GroupType};
|
||||
use leo_asg::Span;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
curves::PrimeField,
|
||||
gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean},
|
||||
};
|
||||
|
||||
pub fn enforce_or<F: Field + PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
pub fn enforce_or<F: PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
cs: &mut CS,
|
||||
left: ConstrainedValue<F, G>,
|
||||
right: ConstrainedValue<F, G>,
|
||||
|
@ -20,14 +20,14 @@ use crate::{enforce_and, errors::ExpressionError, value::ConstrainedValue, Group
|
||||
use leo_asg::Span;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
curves::PrimeField,
|
||||
gadgets::{
|
||||
r1cs::ConstraintSystem,
|
||||
utilities::{boolean::Boolean, eq::EvaluateEqGadget},
|
||||
},
|
||||
};
|
||||
|
||||
pub fn evaluate_eq<F: Field + PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
pub fn evaluate_eq<F: PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
cs: &mut CS,
|
||||
left: ConstrainedValue<F, G>,
|
||||
right: ConstrainedValue<F, G>,
|
||||
|
@ -20,12 +20,9 @@ use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType};
|
||||
use leo_asg::Span;
|
||||
use leo_gadgets::bits::ComparatorGadget;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
gadgets::r1cs::ConstraintSystem,
|
||||
};
|
||||
use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem};
|
||||
|
||||
pub fn evaluate_ge<F: Field + PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
pub fn evaluate_ge<F: PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
cs: &mut CS,
|
||||
left: ConstrainedValue<F, G>,
|
||||
right: ConstrainedValue<F, G>,
|
||||
|
@ -20,12 +20,9 @@ use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType};
|
||||
use leo_asg::Span;
|
||||
use leo_gadgets::bits::ComparatorGadget;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
gadgets::r1cs::ConstraintSystem,
|
||||
};
|
||||
use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem};
|
||||
|
||||
pub fn evaluate_gt<F: Field + PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
pub fn evaluate_gt<F: PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
cs: &mut CS,
|
||||
left: ConstrainedValue<F, G>,
|
||||
right: ConstrainedValue<F, G>,
|
||||
|
@ -20,12 +20,9 @@ use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType};
|
||||
use leo_asg::Span;
|
||||
use leo_gadgets::bits::ComparatorGadget;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
gadgets::r1cs::ConstraintSystem,
|
||||
};
|
||||
use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem};
|
||||
|
||||
pub fn evaluate_le<F: Field + PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
pub fn evaluate_le<F: PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
cs: &mut CS,
|
||||
left: ConstrainedValue<F, G>,
|
||||
right: ConstrainedValue<F, G>,
|
||||
|
@ -20,12 +20,9 @@ use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType};
|
||||
use leo_asg::Span;
|
||||
use leo_gadgets::bits::comparator::EvaluateLtGadget;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
gadgets::r1cs::ConstraintSystem,
|
||||
};
|
||||
use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem};
|
||||
|
||||
pub fn evaluate_lt<F: Field + PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
pub fn evaluate_lt<F: PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
cs: &mut CS,
|
||||
left: ConstrainedValue<F, G>,
|
||||
right: ConstrainedValue<F, G>,
|
||||
|
@ -20,12 +20,9 @@ use crate::{errors::ExpressionError, program::ConstrainedProgram, value::Constra
|
||||
use leo_asg::{Expression, Span};
|
||||
use std::sync::Arc;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
gadgets::r1cs::ConstraintSystem,
|
||||
};
|
||||
use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem};
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn enforce_tuple_access<CS: ConstraintSystem<F>>(
|
||||
&mut self,
|
||||
|
@ -20,12 +20,9 @@ use crate::{errors::ExpressionError, program::ConstrainedProgram, value::Constra
|
||||
use leo_asg::Expression;
|
||||
use std::sync::Arc;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
gadgets::r1cs::ConstraintSystem,
|
||||
};
|
||||
use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem};
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
/// Enforce tuple expressions
|
||||
pub fn enforce_tuple<CS: ConstraintSystem<F>>(
|
||||
&mut self,
|
||||
|
@ -19,9 +19,9 @@
|
||||
use crate::{errors::ExpressionError, program::ConstrainedProgram, value::ConstrainedValue, GroupType};
|
||||
use leo_asg::VariableRef;
|
||||
|
||||
use snarkvm_models::curves::{Field, PrimeField};
|
||||
use snarkvm_models::curves::PrimeField;
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
/// Enforce a variable expression by getting the resolved value
|
||||
pub fn evaluate_ref(&mut self, variable_ref: &VariableRef) -> Result<ConstrainedValue<F, G>, ExpressionError> {
|
||||
// Evaluate the identifier name in the current function scope
|
||||
|
@ -22,11 +22,11 @@ use leo_asg::{Expression, FunctionBody, FunctionQualifier};
|
||||
use std::sync::Arc;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
curves::PrimeField,
|
||||
gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean},
|
||||
};
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
pub(crate) fn enforce_function<CS: ConstraintSystem<F>>(
|
||||
&mut self,
|
||||
cs: &mut CS,
|
||||
|
@ -21,12 +21,9 @@ use crate::{errors::FunctionError, program::ConstrainedProgram, value::Constrain
|
||||
use leo_asg::Type;
|
||||
use leo_ast::{InputValue, Span};
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
gadgets::r1cs::ConstraintSystem,
|
||||
};
|
||||
use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem};
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
pub fn allocate_array<CS: ConstraintSystem<F>>(
|
||||
&mut self,
|
||||
cs: &mut CS,
|
||||
|
@ -19,17 +19,14 @@ use leo_asg::{CircuitBody, CircuitMemberBody, Type};
|
||||
use leo_ast::{Identifier, Input, Span};
|
||||
use std::sync::Arc;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
gadgets::r1cs::ConstraintSystem,
|
||||
};
|
||||
use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem};
|
||||
|
||||
pub const RECORD_VARIABLE_NAME: &str = "record";
|
||||
pub const REGISTERS_VARIABLE_NAME: &str = "registers";
|
||||
pub const STATE_VARIABLE_NAME: &str = "state";
|
||||
pub const STATE_LEAF_VARIABLE_NAME: &str = "state_leaf";
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
pub fn allocate_input_keyword<CS: ConstraintSystem<F>>(
|
||||
&mut self,
|
||||
cs: &mut CS,
|
||||
|
@ -19,14 +19,11 @@ use leo_asg::{AsgConvertError, CircuitBody, CircuitMemberBody};
|
||||
use leo_ast::{Identifier, InputValue, Parameter};
|
||||
use std::sync::Arc;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
gadgets::r1cs::ConstraintSystem,
|
||||
};
|
||||
use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem};
|
||||
|
||||
use indexmap::IndexMap;
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
pub fn allocate_input_section<CS: ConstraintSystem<F>>(
|
||||
&mut self,
|
||||
cs: &mut CS,
|
||||
|
@ -32,12 +32,9 @@ use crate::{
|
||||
|
||||
use leo_asg::Type;
|
||||
use leo_ast::{InputValue, Span};
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
gadgets::r1cs::ConstraintSystem,
|
||||
};
|
||||
use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem};
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
pub fn allocate_main_function_input<CS: ConstraintSystem<F>>(
|
||||
&mut self,
|
||||
cs: &mut CS,
|
||||
|
@ -21,12 +21,9 @@ use crate::{errors::FunctionError, program::ConstrainedProgram, value::Constrain
|
||||
use leo_asg::Type;
|
||||
use leo_ast::{InputValue, Span};
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
gadgets::r1cs::ConstraintSystem,
|
||||
};
|
||||
use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem};
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
pub fn allocate_tuple<CS: ConstraintSystem<F>>(
|
||||
&mut self,
|
||||
cs: &mut CS,
|
||||
|
@ -22,12 +22,9 @@ use leo_asg::{Expression, FunctionBody, FunctionQualifier};
|
||||
use leo_ast::Input;
|
||||
use std::sync::Arc;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
gadgets::r1cs::ConstraintSystem,
|
||||
};
|
||||
use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem};
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
pub fn enforce_main_function<CS: ConstraintSystem<F>>(
|
||||
&mut self,
|
||||
cs: &mut CS,
|
||||
|
@ -35,12 +35,9 @@ use leo_asg::{
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
gadgets::r1cs::ConstraintSystem,
|
||||
};
|
||||
use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem};
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
fn prepare_mut_access<CS: ConstraintSystem<F>>(
|
||||
&mut self,
|
||||
cs: &mut CS,
|
||||
|
@ -27,14 +27,14 @@ use crate::{
|
||||
use leo_asg::{Span, Type};
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
curves::PrimeField,
|
||||
gadgets::{
|
||||
r1cs::ConstraintSystem,
|
||||
utilities::{boolean::Boolean, select::CondSelectGadget},
|
||||
},
|
||||
};
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
///
|
||||
/// Returns a conditionally selected result from the given possible function returns and
|
||||
/// given function return type.
|
||||
|
@ -18,7 +18,7 @@ use crate::{errors::OutputBytesError, ConstrainedValue, GroupType, REGISTERS_VAR
|
||||
use leo_asg::Program;
|
||||
use leo_ast::{Parameter, Registers, Span};
|
||||
|
||||
use snarkvm_models::curves::{Field, PrimeField};
|
||||
use snarkvm_models::curves::PrimeField;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@ -31,7 +31,7 @@ impl OutputBytes {
|
||||
&self.0
|
||||
}
|
||||
|
||||
pub fn new_from_constrained_value<F: Field + PrimeField, G: GroupType<F>>(
|
||||
pub fn new_from_constrained_value<F: PrimeField, G: GroupType<F>>(
|
||||
program: &Program,
|
||||
registers: &Registers,
|
||||
value: ConstrainedValue<F, G>,
|
||||
|
@ -21,7 +21,7 @@ use crate::{errors::ExpressionError, ConstrainedValue, GroupType, Integer};
|
||||
use leo_asg::{FunctionBody, Span};
|
||||
use snarkvm_gadgets::algorithms::prf::Blake2sGadget;
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
curves::PrimeField,
|
||||
gadgets::{
|
||||
algorithms::PRFGadget,
|
||||
r1cs::ConstraintSystem,
|
||||
@ -31,7 +31,7 @@ use snarkvm_models::{
|
||||
|
||||
pub struct Blake2s;
|
||||
|
||||
fn unwrap_argument<F: Field + PrimeField, G: GroupType<F>>(arg: ConstrainedValue<F, G>) -> Vec<UInt8> {
|
||||
fn unwrap_argument<F: PrimeField, G: GroupType<F>>(arg: ConstrainedValue<F, G>) -> Vec<UInt8> {
|
||||
if let ConstrainedValue::Array(args) = arg {
|
||||
assert_eq!(args.len(), 32); // asg enforced
|
||||
args.into_iter()
|
||||
@ -48,7 +48,7 @@ fn unwrap_argument<F: Field + PrimeField, G: GroupType<F>>(arg: ConstrainedValue
|
||||
}
|
||||
}
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> CoreCircuit<F, G> for Blake2s {
|
||||
impl<F: PrimeField, G: GroupType<F>> CoreCircuit<F, G> for Blake2s {
|
||||
fn call_function<CS: ConstraintSystem<F>>(
|
||||
&self,
|
||||
cs: &mut CS,
|
||||
|
@ -21,12 +21,9 @@ pub use blake2s::*;
|
||||
|
||||
use crate::{errors::ExpressionError, ConstrainedValue, GroupType};
|
||||
use leo_asg::{FunctionBody, Span};
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
gadgets::r1cs::ConstraintSystem,
|
||||
};
|
||||
use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem};
|
||||
|
||||
pub trait CoreCircuit<F: Field + PrimeField, G: GroupType<F>>: Send + Sync {
|
||||
pub trait CoreCircuit<F: PrimeField, G: GroupType<F>>: Send + Sync {
|
||||
fn call_function<CS: ConstraintSystem<F>>(
|
||||
&self,
|
||||
cs: &mut CS,
|
||||
@ -37,7 +34,7 @@ pub trait CoreCircuit<F: Field + PrimeField, G: GroupType<F>>: Send + Sync {
|
||||
) -> Result<ConstrainedValue<F, G>, ExpressionError>;
|
||||
}
|
||||
|
||||
pub fn resolve_core_circuit<F: Field + PrimeField, G: GroupType<F>>(name: &str) -> impl CoreCircuit<F, G> {
|
||||
pub fn resolve_core_circuit<F: PrimeField, G: GroupType<F>>(name: &str) -> impl CoreCircuit<F, G> {
|
||||
match name {
|
||||
"blake2s" => Blake2s,
|
||||
_ => unimplemented!("invalid core circuit: {}", name),
|
||||
|
@ -19,17 +19,17 @@
|
||||
use crate::{value::ConstrainedValue, GroupType};
|
||||
|
||||
use leo_asg::Program;
|
||||
use snarkvm_models::curves::{Field, PrimeField};
|
||||
use snarkvm_models::curves::PrimeField;
|
||||
|
||||
use indexmap::IndexMap;
|
||||
use uuid::Uuid;
|
||||
|
||||
pub struct ConstrainedProgram<F: Field + PrimeField, G: GroupType<F>> {
|
||||
pub struct ConstrainedProgram<F: PrimeField, G: GroupType<F>> {
|
||||
pub asg: Program,
|
||||
identifiers: IndexMap<Uuid, ConstrainedValue<F, G>>,
|
||||
}
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
pub fn new(asg: Program) -> Self {
|
||||
Self {
|
||||
asg,
|
||||
|
@ -20,14 +20,14 @@ use crate::{arithmetic::*, errors::StatementError, program::ConstrainedProgram,
|
||||
use leo_asg::{AssignOperation, AssignStatement, Span};
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
curves::PrimeField,
|
||||
gadgets::{
|
||||
r1cs::ConstraintSystem,
|
||||
utilities::{boolean::Boolean, select::CondSelectGadget},
|
||||
},
|
||||
};
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn enforce_assign_statement<CS: ConstraintSystem<F>>(
|
||||
&mut self,
|
||||
|
@ -19,10 +19,7 @@
|
||||
use crate::{errors::StatementError, program::ConstrainedProgram, value::ConstrainedValue, GroupType};
|
||||
use leo_asg::{AssignAccess, AssignStatement, Identifier, Span};
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
gadgets::r1cs::ConstraintSystem,
|
||||
};
|
||||
use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem};
|
||||
|
||||
pub(crate) enum ResolvedAssigneeAccess {
|
||||
ArrayRange(Option<usize>, Option<usize>),
|
||||
@ -31,7 +28,7 @@ pub(crate) enum ResolvedAssigneeAccess {
|
||||
Member(Identifier),
|
||||
}
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
pub fn resolve_assign<CS: ConstraintSystem<F>>(
|
||||
&mut self,
|
||||
cs: &mut CS,
|
||||
|
@ -20,11 +20,11 @@ use crate::{program::ConstrainedProgram, GroupType, IndicatorAndConstrainedValue
|
||||
use leo_asg::BlockStatement;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
curves::PrimeField,
|
||||
gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean},
|
||||
};
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
/// Evaluates a branch of one or more statements and returns a result in
|
||||
/// the given scope.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
|
@ -27,7 +27,7 @@ use crate::{
|
||||
use leo_asg::ConditionalStatement;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
curves::PrimeField,
|
||||
gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean},
|
||||
};
|
||||
|
||||
@ -38,7 +38,7 @@ fn indicator_to_string(indicator: &Boolean) -> String {
|
||||
.unwrap_or_else(|| "[input]".to_string())
|
||||
}
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
/// Enforces a conditional statement with one or more branches.
|
||||
/// Due to R1CS constraints, we must evaluate every branch to properly construct the circuit.
|
||||
/// At program execution, we will pass an `indicator` bit down to all child statements within each branch.
|
||||
|
@ -19,12 +19,9 @@
|
||||
use crate::{errors::StatementError, program::ConstrainedProgram, ConstrainedValue, GroupType};
|
||||
use leo_asg::{DefinitionStatement, Span, Variable};
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
gadgets::r1cs::ConstraintSystem,
|
||||
};
|
||||
use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem};
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
fn enforce_multiple_definition(
|
||||
&mut self,
|
||||
variable_names: &[Variable],
|
||||
|
@ -27,14 +27,14 @@ use crate::{
|
||||
use leo_asg::IterationStatement;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
curves::PrimeField,
|
||||
gadgets::{
|
||||
r1cs::ConstraintSystem,
|
||||
utilities::{boolean::Boolean, uint::UInt32},
|
||||
},
|
||||
};
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn enforce_iteration_statement<CS: ConstraintSystem<F>>(
|
||||
&mut self,
|
||||
|
@ -19,12 +19,9 @@
|
||||
use crate::{errors::StatementError, program::ConstrainedProgram, value::ConstrainedValue, GroupType};
|
||||
use leo_asg::ReturnStatement;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
gadgets::r1cs::ConstraintSystem,
|
||||
};
|
||||
use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem};
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
pub fn enforce_return_statement<CS: ConstraintSystem<F>>(
|
||||
&mut self,
|
||||
cs: &mut CS,
|
||||
|
@ -21,14 +21,14 @@ use leo_asg::Statement;
|
||||
use std::sync::Arc;
|
||||
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
curves::PrimeField,
|
||||
gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean},
|
||||
};
|
||||
|
||||
pub type StatementResult<T> = Result<T, StatementError>;
|
||||
pub type IndicatorAndConstrainedValue<T, U> = (Boolean, ConstrainedValue<T, U>);
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
///
|
||||
/// Enforce a program statement.
|
||||
/// Returns a Vector of (indicator, value) tuples.
|
||||
|
@ -20,7 +20,7 @@ use leo_ast::{InputValue, Span};
|
||||
use snarkvm_dpc::base_dpc::instantiated::Components;
|
||||
use snarkvm_errors::gadgets::SynthesisError;
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
curves::PrimeField,
|
||||
gadgets::{
|
||||
r1cs::{Assignment, ConstraintSystem},
|
||||
utilities::{
|
||||
@ -63,7 +63,7 @@ impl Address {
|
||||
self.bytes.iter().all(|byte| byte.is_constant())
|
||||
}
|
||||
|
||||
pub(crate) fn from_input<F: Field + PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
pub(crate) fn from_input<F: PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
cs: &mut CS,
|
||||
name: &str,
|
||||
input_value: Option<InputValue>,
|
||||
@ -105,7 +105,7 @@ impl Address {
|
||||
}
|
||||
}
|
||||
|
||||
impl<F: Field + PrimeField> AllocGadget<String, F> for Address {
|
||||
impl<F: PrimeField> AllocGadget<String, F> for Address {
|
||||
fn alloc<Fn: FnOnce() -> Result<T, SynthesisError>, T: Borrow<String>, CS: ConstraintSystem<F>>(
|
||||
cs: CS,
|
||||
value_gen: Fn,
|
||||
@ -143,7 +143,7 @@ impl<F: Field + PrimeField> AllocGadget<String, F> for Address {
|
||||
}
|
||||
}
|
||||
|
||||
impl<F: Field + PrimeField> EvaluateEqGadget<F> for Address {
|
||||
impl<F: PrimeField> EvaluateEqGadget<F> for Address {
|
||||
fn evaluate_equal<CS: ConstraintSystem<F>>(&self, mut cs: CS, other: &Self) -> Result<Boolean, SynthesisError> {
|
||||
if self.is_constant() && other.is_constant() {
|
||||
Ok(Boolean::Constant(self.eq(other)))
|
||||
@ -178,7 +178,7 @@ fn cond_equal_helper(first: &Address, second: &Address, cond: bool) -> Result<()
|
||||
}
|
||||
}
|
||||
|
||||
impl<F: Field + PrimeField> ConditionalEqGadget<F> for Address {
|
||||
impl<F: PrimeField> ConditionalEqGadget<F> for Address {
|
||||
fn conditional_enforce_equal<CS: ConstraintSystem<F>>(
|
||||
&self,
|
||||
mut cs: CS,
|
||||
@ -208,7 +208,7 @@ fn cond_select_helper(first: &Address, second: &Address, cond: bool) -> Address
|
||||
if cond { first.clone() } else { second.clone() }
|
||||
}
|
||||
|
||||
impl<F: Field + PrimeField> CondSelectGadget<F> for Address {
|
||||
impl<F: PrimeField> CondSelectGadget<F> for Address {
|
||||
fn conditionally_select<CS: ConstraintSystem<F>>(
|
||||
mut cs: CS,
|
||||
cond: &Boolean,
|
||||
|
@ -21,14 +21,14 @@ use leo_ast::{InputValue, Span};
|
||||
|
||||
use snarkvm_errors::gadgets::SynthesisError;
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
curves::PrimeField,
|
||||
gadgets::{
|
||||
r1cs::ConstraintSystem,
|
||||
utilities::{alloc::AllocGadget, boolean::Boolean},
|
||||
},
|
||||
};
|
||||
|
||||
pub(crate) fn allocate_bool<F: Field + PrimeField, CS: ConstraintSystem<F>>(
|
||||
pub(crate) fn allocate_bool<F: PrimeField, CS: ConstraintSystem<F>>(
|
||||
cs: &mut CS,
|
||||
name: &str,
|
||||
option: Option<bool>,
|
||||
@ -41,7 +41,7 @@ pub(crate) fn allocate_bool<F: Field + PrimeField, CS: ConstraintSystem<F>>(
|
||||
.map_err(|_| BooleanError::missing_boolean(format!("{}: bool", name), span.to_owned()))
|
||||
}
|
||||
|
||||
pub(crate) fn bool_from_input<F: Field + PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
pub(crate) fn bool_from_input<F: PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
cs: &mut CS,
|
||||
name: &str,
|
||||
input_value: Option<InputValue>,
|
||||
|
@ -21,7 +21,7 @@ use leo_ast::Span;
|
||||
|
||||
use snarkvm_errors::gadgets::SynthesisError;
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
curves::PrimeField,
|
||||
gadgets::{
|
||||
curves::{FieldGadget, FpGadget},
|
||||
r1cs::ConstraintSystem,
|
||||
@ -40,12 +40,12 @@ use snarkvm_models::{
|
||||
use std::{borrow::Borrow, cmp::Ordering};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum FieldType<F: Field + PrimeField> {
|
||||
pub enum FieldType<F: PrimeField> {
|
||||
Constant(F),
|
||||
Allocated(FpGadget<F>),
|
||||
}
|
||||
|
||||
impl<F: Field + PrimeField> FieldType<F> {
|
||||
impl<F: PrimeField> FieldType<F> {
|
||||
pub fn get_value(&self) -> Option<F> {
|
||||
match self {
|
||||
FieldType::Constant(field) => Some(*field),
|
||||
@ -186,7 +186,7 @@ impl<F: Field + PrimeField> FieldType<F> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<F: Field + PrimeField> AllocGadget<String, F> for FieldType<F> {
|
||||
impl<F: PrimeField> AllocGadget<String, F> for FieldType<F> {
|
||||
fn alloc<Fn: FnOnce() -> Result<T, SynthesisError>, T: Borrow<String>, CS: ConstraintSystem<F>>(
|
||||
cs: CS,
|
||||
value_gen: Fn,
|
||||
@ -206,7 +206,7 @@ impl<F: Field + PrimeField> AllocGadget<String, F> for FieldType<F> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<F: Field + PrimeField> PartialEq for FieldType<F> {
|
||||
impl<F: PrimeField> PartialEq for FieldType<F> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
let self_value = self.get_value();
|
||||
let other_value = other.get_value();
|
||||
@ -215,9 +215,9 @@ impl<F: Field + PrimeField> PartialEq for FieldType<F> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<F: Field + PrimeField> Eq for FieldType<F> {}
|
||||
impl<F: PrimeField> Eq for FieldType<F> {}
|
||||
|
||||
impl<F: Field + PrimeField> PartialOrd for FieldType<F> {
|
||||
impl<F: PrimeField> PartialOrd for FieldType<F> {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
let self_value = self.get_value();
|
||||
let other_value = other.get_value();
|
||||
@ -226,7 +226,7 @@ impl<F: Field + PrimeField> PartialOrd for FieldType<F> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<F: Field + PrimeField> EvaluateEqGadget<F> for FieldType<F> {
|
||||
impl<F: PrimeField> EvaluateEqGadget<F> for FieldType<F> {
|
||||
fn evaluate_equal<CS: ConstraintSystem<F>>(&self, mut _cs: CS, other: &Self) -> Result<Boolean, SynthesisError> {
|
||||
match (self, other) {
|
||||
(FieldType::Constant(first), FieldType::Constant(second)) => Ok(Boolean::constant(first.eq(second))),
|
||||
@ -242,9 +242,9 @@ impl<F: Field + PrimeField> EvaluateEqGadget<F> for FieldType<F> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<F: Field + PrimeField> EqGadget<F> for FieldType<F> {}
|
||||
impl<F: PrimeField> EqGadget<F> for FieldType<F> {}
|
||||
|
||||
impl<F: Field + PrimeField> ConditionalEqGadget<F> for FieldType<F> {
|
||||
impl<F: PrimeField> ConditionalEqGadget<F> for FieldType<F> {
|
||||
fn conditional_enforce_equal<CS: ConstraintSystem<F>>(
|
||||
&self,
|
||||
mut cs: CS,
|
||||
@ -278,7 +278,7 @@ impl<F: Field + PrimeField> ConditionalEqGadget<F> for FieldType<F> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<F: Field + PrimeField> CondSelectGadget<F> for FieldType<F> {
|
||||
impl<F: PrimeField> CondSelectGadget<F> for FieldType<F> {
|
||||
fn conditionally_select<CS: ConstraintSystem<F>>(
|
||||
mut cs: CS,
|
||||
cond: &Boolean,
|
||||
@ -301,7 +301,7 @@ impl<F: Field + PrimeField> CondSelectGadget<F> for FieldType<F> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<F: Field + PrimeField> ToBitsGadget<F> for FieldType<F> {
|
||||
impl<F: PrimeField> ToBitsGadget<F> for FieldType<F> {
|
||||
fn to_bits<CS: ConstraintSystem<F>>(&self, mut cs: CS) -> Result<Vec<Boolean>, SynthesisError> {
|
||||
let self_gadget = self.allocated(&mut cs)?;
|
||||
self_gadget.to_bits(cs)
|
||||
@ -313,7 +313,7 @@ impl<F: Field + PrimeField> ToBitsGadget<F> for FieldType<F> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<F: Field + PrimeField> ToBytesGadget<F> for FieldType<F> {
|
||||
impl<F: PrimeField> ToBytesGadget<F> for FieldType<F> {
|
||||
fn to_bytes<CS: ConstraintSystem<F>>(&self, mut cs: CS) -> Result<Vec<UInt8>, SynthesisError> {
|
||||
let self_gadget = self.allocated(&mut cs)?;
|
||||
self_gadget.to_bytes(cs)
|
||||
@ -325,7 +325,7 @@ impl<F: Field + PrimeField> ToBytesGadget<F> for FieldType<F> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<F: Field + PrimeField> std::fmt::Display for FieldType<F> {
|
||||
impl<F: PrimeField> std::fmt::Display for FieldType<F> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(f, "{:?}", self.get_value().ok_or(std::fmt::Error))
|
||||
}
|
||||
|
@ -21,11 +21,11 @@ use leo_ast::{InputValue, Span};
|
||||
|
||||
use snarkvm_errors::gadgets::SynthesisError;
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
curves::PrimeField,
|
||||
gadgets::{r1cs::ConstraintSystem, utilities::alloc::AllocGadget},
|
||||
};
|
||||
|
||||
pub(crate) fn allocate_field<F: Field + PrimeField, CS: ConstraintSystem<F>>(
|
||||
pub(crate) fn allocate_field<F: PrimeField, CS: ConstraintSystem<F>>(
|
||||
cs: &mut CS,
|
||||
name: &str,
|
||||
option: Option<String>,
|
||||
@ -38,7 +38,7 @@ pub(crate) fn allocate_field<F: Field + PrimeField, CS: ConstraintSystem<F>>(
|
||||
.map_err(|_| FieldError::missing_field(format!("{}: field", name), span.to_owned()))
|
||||
}
|
||||
|
||||
pub(crate) fn field_from_input<F: Field + PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
pub(crate) fn field_from_input<F: PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
cs: &mut CS,
|
||||
name: &str,
|
||||
input_value: Option<InputValue>,
|
||||
|
@ -21,12 +21,9 @@ use leo_asg::{GroupValue, Span};
|
||||
use leo_ast::InputValue;
|
||||
|
||||
use snarkvm_errors::gadgets::SynthesisError;
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
gadgets::r1cs::ConstraintSystem,
|
||||
};
|
||||
use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem};
|
||||
|
||||
pub(crate) fn allocate_group<F: Field + PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
pub(crate) fn allocate_group<F: PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
cs: &mut CS,
|
||||
name: &str,
|
||||
option: Option<GroupValue>,
|
||||
@ -39,7 +36,7 @@ pub(crate) fn allocate_group<F: Field + PrimeField, G: GroupType<F>, CS: Constra
|
||||
.map_err(|_| GroupError::missing_group(format!("{}: group", name), span.to_owned()))
|
||||
}
|
||||
|
||||
pub(crate) fn group_from_input<F: Field + PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
pub(crate) fn group_from_input<F: PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
|
||||
cs: &mut CS,
|
||||
name: &str,
|
||||
input_value: Option<InputValue>,
|
||||
|
@ -298,7 +298,7 @@ impl Integer {
|
||||
Self::allocate_type(cs, integer_type, name, option, span)
|
||||
}
|
||||
|
||||
pub fn negate<F: Field + PrimeField, CS: ConstraintSystem<F>>(
|
||||
pub fn negate<F: PrimeField, CS: ConstraintSystem<F>>(
|
||||
self,
|
||||
cs: &mut CS,
|
||||
span: &Span,
|
||||
@ -312,7 +312,7 @@ impl Integer {
|
||||
result.ok_or_else(|| IntegerError::negate_operation(span.to_owned()))
|
||||
}
|
||||
|
||||
pub fn add<F: Field + PrimeField, CS: ConstraintSystem<F>>(
|
||||
pub fn add<F: PrimeField, CS: ConstraintSystem<F>>(
|
||||
self,
|
||||
cs: &mut CS,
|
||||
other: Self,
|
||||
@ -328,7 +328,7 @@ impl Integer {
|
||||
result.ok_or_else(|| IntegerError::binary_operation("+".to_string(), span.to_owned()))
|
||||
}
|
||||
|
||||
pub fn sub<F: Field + PrimeField, CS: ConstraintSystem<F>>(
|
||||
pub fn sub<F: PrimeField, CS: ConstraintSystem<F>>(
|
||||
self,
|
||||
cs: &mut CS,
|
||||
other: Self,
|
||||
@ -344,7 +344,7 @@ impl Integer {
|
||||
result.ok_or_else(|| IntegerError::binary_operation("-".to_string(), span.to_owned()))
|
||||
}
|
||||
|
||||
pub fn mul<F: Field + PrimeField, CS: ConstraintSystem<F>>(
|
||||
pub fn mul<F: PrimeField, CS: ConstraintSystem<F>>(
|
||||
self,
|
||||
cs: &mut CS,
|
||||
other: Self,
|
||||
@ -360,7 +360,7 @@ impl Integer {
|
||||
result.ok_or_else(|| IntegerError::binary_operation("*".to_string(), span.to_owned()))
|
||||
}
|
||||
|
||||
pub fn div<F: Field + PrimeField, CS: ConstraintSystem<F>>(
|
||||
pub fn div<F: PrimeField, CS: ConstraintSystem<F>>(
|
||||
self,
|
||||
cs: &mut CS,
|
||||
other: Self,
|
||||
@ -376,7 +376,7 @@ impl Integer {
|
||||
result.ok_or_else(|| IntegerError::binary_operation("÷".to_string(), span.to_owned()))
|
||||
}
|
||||
|
||||
pub fn pow<F: Field + PrimeField, CS: ConstraintSystem<F>>(
|
||||
pub fn pow<F: PrimeField, CS: ConstraintSystem<F>>(
|
||||
self,
|
||||
cs: &mut CS,
|
||||
other: Self,
|
||||
@ -393,7 +393,7 @@ impl Integer {
|
||||
}
|
||||
}
|
||||
|
||||
impl<F: Field + PrimeField> EvaluateEqGadget<F> for Integer {
|
||||
impl<F: PrimeField> EvaluateEqGadget<F> for Integer {
|
||||
fn evaluate_equal<CS: ConstraintSystem<F>>(&self, cs: CS, other: &Self) -> Result<Boolean, SynthesisError> {
|
||||
let a = self;
|
||||
let b = other;
|
||||
@ -404,7 +404,7 @@ impl<F: Field + PrimeField> EvaluateEqGadget<F> for Integer {
|
||||
}
|
||||
}
|
||||
|
||||
impl<F: Field + PrimeField> EvaluateLtGadget<F> for Integer {
|
||||
impl<F: PrimeField> EvaluateLtGadget<F> for Integer {
|
||||
fn less_than<CS: ConstraintSystem<F>>(&self, cs: CS, other: &Self) -> Result<Boolean, SynthesisError> {
|
||||
let a = self;
|
||||
let b = other;
|
||||
@ -414,11 +414,11 @@ impl<F: Field + PrimeField> EvaluateLtGadget<F> for Integer {
|
||||
}
|
||||
}
|
||||
|
||||
impl<F: Field + PrimeField> ComparatorGadget<F> for Integer {}
|
||||
impl<F: PrimeField> ComparatorGadget<F> for Integer {}
|
||||
|
||||
impl<F: Field + PrimeField> EqGadget<F> for Integer {}
|
||||
impl<F: PrimeField> EqGadget<F> for Integer {}
|
||||
|
||||
impl<F: Field + PrimeField> ConditionalEqGadget<F> for Integer {
|
||||
impl<F: PrimeField> ConditionalEqGadget<F> for Integer {
|
||||
fn conditional_enforce_equal<CS: ConstraintSystem<F>>(
|
||||
&self,
|
||||
cs: CS,
|
||||
@ -438,7 +438,7 @@ impl<F: Field + PrimeField> ConditionalEqGadget<F> for Integer {
|
||||
}
|
||||
}
|
||||
|
||||
impl<F: Field + PrimeField> CondSelectGadget<F> for Integer {
|
||||
impl<F: PrimeField> CondSelectGadget<F> for Integer {
|
||||
fn conditionally_select<CS: ConstraintSystem<F>>(
|
||||
cs: CS,
|
||||
cond: &Boolean,
|
||||
|
@ -21,7 +21,7 @@ use leo_asg::{CircuitBody, Identifier, Span, Type};
|
||||
|
||||
use snarkvm_errors::gadgets::SynthesisError;
|
||||
use snarkvm_models::{
|
||||
curves::{Field, PrimeField},
|
||||
curves::PrimeField,
|
||||
gadgets::{
|
||||
r1cs::ConstraintSystem,
|
||||
utilities::{boolean::Boolean, eq::ConditionalEqGadget, select::CondSelectGadget},
|
||||
@ -30,10 +30,10 @@ use snarkvm_models::{
|
||||
use std::{fmt, sync::Arc};
|
||||
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
pub struct ConstrainedCircuitMember<F: Field + PrimeField, G: GroupType<F>>(pub Identifier, pub ConstrainedValue<F, G>);
|
||||
pub struct ConstrainedCircuitMember<F: PrimeField, G: GroupType<F>>(pub Identifier, pub ConstrainedValue<F, G>);
|
||||
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
pub enum ConstrainedValue<F: Field + PrimeField, G: GroupType<F>> {
|
||||
pub enum ConstrainedValue<F: PrimeField, G: GroupType<F>> {
|
||||
// Data types
|
||||
Address(Address),
|
||||
Boolean(Boolean),
|
||||
@ -51,7 +51,7 @@ pub enum ConstrainedValue<F: Field + PrimeField, G: GroupType<F>> {
|
||||
CircuitExpression(Arc<CircuitBody>, Vec<ConstrainedCircuitMember<F, G>>),
|
||||
}
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedValue<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConstrainedValue<F, G> {
|
||||
pub(crate) fn to_type(&self, span: &Span) -> Result<Type, ValueError> {
|
||||
Ok(match self {
|
||||
// Data types
|
||||
@ -82,7 +82,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedValue<F, G> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> fmt::Display for ConstrainedValue<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> fmt::Display for ConstrainedValue<F, G> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
// Data types
|
||||
@ -129,13 +129,13 @@ impl<F: Field + PrimeField, G: GroupType<F>> fmt::Display for ConstrainedValue<F
|
||||
}
|
||||
}
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> fmt::Debug for ConstrainedValue<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> fmt::Debug for ConstrainedValue<F, G> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}", self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConditionalEqGadget<F> for ConstrainedValue<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> ConditionalEqGadget<F> for ConstrainedValue<F, G> {
|
||||
fn conditional_enforce_equal<CS: ConstraintSystem<F>>(
|
||||
&self,
|
||||
mut cs: CS,
|
||||
@ -179,7 +179,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConditionalEqGadget<F> for Constrai
|
||||
}
|
||||
}
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> CondSelectGadget<F> for ConstrainedValue<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> CondSelectGadget<F> for ConstrainedValue<F, G> {
|
||||
fn conditionally_select<CS: ConstraintSystem<F>>(
|
||||
mut cs: CS,
|
||||
cond: &Boolean,
|
||||
@ -256,7 +256,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> CondSelectGadget<F> for Constrained
|
||||
}
|
||||
}
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> CondSelectGadget<F> for ConstrainedCircuitMember<F, G> {
|
||||
impl<F: PrimeField, G: GroupType<F>> CondSelectGadget<F> for ConstrainedCircuitMember<F, G> {
|
||||
fn conditionally_select<CS: ConstraintSystem<F>>(
|
||||
cs: CS,
|
||||
cond: &Boolean,
|
||||
|
@ -36,7 +36,7 @@ where
|
||||
// Implement unsigned integers
|
||||
macro_rules! add_uint_impl {
|
||||
($($gadget: ident),*) => ($(
|
||||
impl<F: Field + PrimeField> Add<F> for $gadget {
|
||||
impl<F: PrimeField> Add<F> for $gadget {
|
||||
type ErrorType = SynthesisError;
|
||||
|
||||
fn add<CS: ConstraintSystem<F>>(
|
||||
|
@ -53,7 +53,7 @@ where
|
||||
macro_rules! uint_cmp_impl {
|
||||
($($gadget: ident),*) => ($(
|
||||
/* Bitwise less than comparison of two unsigned integers */
|
||||
impl<F: Field + PrimeField> EvaluateLtGadget<F> for $gadget {
|
||||
impl<F: PrimeField> EvaluateLtGadget<F> for $gadget {
|
||||
fn less_than<CS: ConstraintSystem<F>>(&self, mut cs: CS, other: &Self) -> Result<Boolean, SynthesisError> {
|
||||
|
||||
let mut result = Boolean::constant(true);
|
||||
@ -91,7 +91,7 @@ macro_rules! uint_cmp_impl {
|
||||
}
|
||||
|
||||
/* Bitwise comparison of two unsigned integers */
|
||||
impl<F: Field + PrimeField> ComparatorGadget<F> for $gadget {}
|
||||
impl<F: PrimeField> ComparatorGadget<F> for $gadget {}
|
||||
)*)
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ impl<F: Field> RippleCarryAdder<F> for Vec<Boolean> {
|
||||
|
||||
macro_rules! rpc_impl {
|
||||
($($gadget: ident)*) => ($(
|
||||
impl<F: Field + PrimeField> RippleCarryAdder<F> for $gadget {
|
||||
impl<F: PrimeField> RippleCarryAdder<F> for $gadget {
|
||||
fn add_bits<CS: ConstraintSystem<F>>(&self, cs: CS, other: &Self) -> Result<Vec<Boolean>, SynthesisError> {
|
||||
self.bits.add_bits(cs, &other.bits)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user