mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-25 19:22:01 +03:00
Merge pull request #322 from AleoHQ/feature/n-group-notation
Feature/n group notation
This commit is contained in:
commit
754725f5b7
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -1398,9 +1398,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libz-sys"
|
||||
version = "1.1.0"
|
||||
version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af67924b8dd885cccea261866c8ce5b74d239d272e154053ff927dae839f5ae9"
|
||||
checksum = "23b34178653005c1181711c333f0e5604a14a1b5115c814fd42304bdd16245e0"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
|
@ -98,4 +98,10 @@ impl GroupError {
|
||||
|
||||
Self::new_from_span(message, span)
|
||||
}
|
||||
|
||||
pub fn n_group(number: String, span: Span) -> Self {
|
||||
let message = format!("cannot multiply group generator by \"{}\"", number);
|
||||
|
||||
Self::new_from_span(message, span)
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ use snarkos_curves::{
|
||||
use snarkos_errors::gadgets::SynthesisError;
|
||||
use snarkos_gadgets::curves::edwards_bls12::EdwardsBlsGadget;
|
||||
use snarkos_models::{
|
||||
curves::{AffineCurve, One, TEModelParameters, Zero},
|
||||
curves::{AffineCurve, Fp256, One, TEModelParameters, Zero},
|
||||
gadgets::{
|
||||
curves::{FieldGadget, FpGadget, GroupGadget},
|
||||
r1cs::ConstraintSystem,
|
||||
@ -41,7 +41,7 @@ use snarkos_models::{
|
||||
};
|
||||
use std::{
|
||||
borrow::Borrow,
|
||||
ops::{Neg, Sub},
|
||||
ops::{Mul, Neg, Sub},
|
||||
str::FromStr,
|
||||
};
|
||||
|
||||
@ -142,12 +142,14 @@ impl EdwardsGroupType {
|
||||
}
|
||||
|
||||
pub fn edwards_affine_from_single(number: String, span: Span) -> Result<EdwardsAffine, GroupError> {
|
||||
if number.eq("1") {
|
||||
return Ok(edwards_affine_one());
|
||||
} else if number.eq("0") {
|
||||
if number.eq("0") {
|
||||
return Ok(EdwardsAffine::zero());
|
||||
} else {
|
||||
Self::edwards_affine_from_x_str(number, span.clone(), None, span)
|
||||
let one = edwards_affine_one();
|
||||
let number_value = Fp256::from_str(&number).map_err(|_| GroupError::n_group(number, span))?;
|
||||
let result: EdwardsAffine = one.mul(&number_value);
|
||||
|
||||
return Ok(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user