mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-26 11:45:00 +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]]
|
[[package]]
|
||||||
name = "libz-sys"
|
name = "libz-sys"
|
||||||
version = "1.1.0"
|
version = "1.1.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "af67924b8dd885cccea261866c8ce5b74d239d272e154053ff927dae839f5ae9"
|
checksum = "23b34178653005c1181711c333f0e5604a14a1b5115c814fd42304bdd16245e0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"libc",
|
"libc",
|
||||||
|
@ -98,4 +98,10 @@ impl GroupError {
|
|||||||
|
|
||||||
Self::new_from_span(message, span)
|
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_errors::gadgets::SynthesisError;
|
||||||
use snarkos_gadgets::curves::edwards_bls12::EdwardsBlsGadget;
|
use snarkos_gadgets::curves::edwards_bls12::EdwardsBlsGadget;
|
||||||
use snarkos_models::{
|
use snarkos_models::{
|
||||||
curves::{AffineCurve, One, TEModelParameters, Zero},
|
curves::{AffineCurve, Fp256, One, TEModelParameters, Zero},
|
||||||
gadgets::{
|
gadgets::{
|
||||||
curves::{FieldGadget, FpGadget, GroupGadget},
|
curves::{FieldGadget, FpGadget, GroupGadget},
|
||||||
r1cs::ConstraintSystem,
|
r1cs::ConstraintSystem,
|
||||||
@ -41,7 +41,7 @@ use snarkos_models::{
|
|||||||
};
|
};
|
||||||
use std::{
|
use std::{
|
||||||
borrow::Borrow,
|
borrow::Borrow,
|
||||||
ops::{Neg, Sub},
|
ops::{Mul, Neg, Sub},
|
||||||
str::FromStr,
|
str::FromStr,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -142,12 +142,14 @@ impl EdwardsGroupType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn edwards_affine_from_single(number: String, span: Span) -> Result<EdwardsAffine, GroupError> {
|
pub fn edwards_affine_from_single(number: String, span: Span) -> Result<EdwardsAffine, GroupError> {
|
||||||
if number.eq("1") {
|
if number.eq("0") {
|
||||||
return Ok(edwards_affine_one());
|
|
||||||
} else if number.eq("0") {
|
|
||||||
return Ok(EdwardsAffine::zero());
|
return Ok(EdwardsAffine::zero());
|
||||||
} else {
|
} 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