refactor to use snarkvm pow gadget

This commit is contained in:
collin 2021-03-11 16:18:00 -08:00
parent fd41c70250
commit adce376675
9 changed files with 38 additions and 38 deletions

View File

@ -18,7 +18,7 @@ use leo_gadgets::{arithmetic::*, Int128, Int16, Int32, Int64, Int8};
use snarkvm_gadgets::traits::utilities::{
alloc::AllocGadget,
arithmetic::{Add, Div, Mul, Neg},
arithmetic::{Add, Div, Mul, Neg, Pow},
};
use snarkvm_r1cs::{ConstraintSystem, Fr, TestConstraintSystem};

View File

@ -14,8 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
pub mod pow;
pub use self::pow::*;
// pub mod pow;
// pub use self::pow::*;
pub mod sub;
pub use self::sub::*;

View File

@ -1,28 +1,28 @@
// Copyright (C) 2019-2021 Aleo Systems Inc.
// This file is part of the Leo library.
// The Leo library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// The Leo library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use snarkvm_fields::Field;
use snarkvm_r1cs::ConstraintSystem;
/// Returns exponentiation of `self` ** `other` in the constraint system.
pub trait Pow<F: Field, Rhs = Self>
where
Self: std::marker::Sized,
{
type ErrorType;
fn pow<CS: ConstraintSystem<F>>(&self, cs: CS, other: &Self) -> Result<Self, Self::ErrorType>;
}
// // Copyright (C) 2019-2021 Aleo Systems Inc.
// // This file is part of the Leo library.
//
// // The Leo library is free software: you can redistribute it and/or modify
// // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// // (at your option) any later version.
//
// // The Leo library is distributed in the hope that it will be useful,
// // but WITHOUT ANY WARRANTY; without even the implied warranty of
// // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// // GNU General Public License for more details.
//
// // You should have received a copy of the GNU General Public License
// // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
//
// use snarkvm_fields::Field;
// use snarkvm_r1cs::ConstraintSystem;
//
// /// Returns exponentiation of `self` ** `other` in the constraint system.
// pub trait Pow<F: Field, Rhs = Self>
// where
// Self: std::marker::Sized,
// {
// type ErrorType;
//
// fn pow<CS: ConstraintSystem<F>>(&self, cs: CS, other: &Self) -> Result<Self, Self::ErrorType>;
// }

View File

@ -14,12 +14,12 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{arithmetic::Pow, errors::SignedIntegerError, Int, Int128, Int16, Int32, Int64, Int8};
use crate::{errors::SignedIntegerError, Int, Int128, Int16, Int32, Int64, Int8};
use snarkvm_fields::PrimeField;
use snarkvm_gadgets::traits::utilities::{
alloc::AllocGadget,
arithmetic::Mul,
arithmetic::{Mul, Pow},
boolean::Boolean,
select::CondSelectGadget,
};

View File

@ -19,7 +19,7 @@ use leo_gadgets::{arithmetic::*, Int128};
use snarkvm_fields::{One, Zero};
use snarkvm_gadgets::traits::utilities::{
alloc::AllocGadget,
arithmetic::{Add, Div, Mul, Neg},
arithmetic::{Add, Div, Mul, Neg, Pow},
boolean::Boolean,
};
use snarkvm_r1cs::{ConstraintSystem, Fr, TestConstraintSystem};

View File

@ -19,7 +19,7 @@ use leo_gadgets::{arithmetic::*, Int16};
use snarkvm_fields::{One, Zero};
use snarkvm_gadgets::traits::utilities::{
alloc::AllocGadget,
arithmetic::{Add, Div, Mul, Neg},
arithmetic::{Add, Div, Mul, Neg, Pow},
boolean::Boolean,
};
use snarkvm_r1cs::{ConstraintSystem, Fr, TestConstraintSystem};

View File

@ -19,7 +19,7 @@ use leo_gadgets::{arithmetic::*, Int32};
use snarkvm_fields::{One, Zero};
use snarkvm_gadgets::traits::utilities::{
alloc::AllocGadget,
arithmetic::{Add, Div, Mul, Neg},
arithmetic::{Add, Div, Mul, Neg, Pow},
boolean::Boolean,
};
use snarkvm_r1cs::{ConstraintSystem, Fr, TestConstraintSystem};

View File

@ -19,7 +19,7 @@ use leo_gadgets::{arithmetic::*, Int64};
use snarkvm_fields::{One, Zero};
use snarkvm_gadgets::traits::utilities::{
alloc::AllocGadget,
arithmetic::{Add, Div, Mul, Neg},
arithmetic::{Add, Div, Mul, Neg, Pow},
boolean::Boolean,
};
use snarkvm_r1cs::{ConstraintSystem, Fr, TestConstraintSystem};

View File

@ -19,7 +19,7 @@ use leo_gadgets::{arithmetic::*, Int8};
use snarkvm_fields::{One, Zero};
use snarkvm_gadgets::traits::utilities::{
alloc::AllocGadget,
arithmetic::{Add, Div, Mul, Neg},
arithmetic::{Add, Div, Mul, Neg, Pow},
boolean::Boolean,
};
use snarkvm_r1cs::{ConstraintSystem, Fr, TestConstraintSystem};