mirror of
https://github.com/arnaucube/testudo.git
synced 2026-01-12 16:51:28 +01:00
turn shake into poseidon
This commit is contained in:
34
src/group.rs
34
src/group.rs
@@ -1,22 +1,20 @@
|
|||||||
use ark_ec::{
|
use crate::errors::ProofVerifyError;
|
||||||
msm::VariableBaseMSM,
|
use ark_ec::msm::VariableBaseMSM;
|
||||||
};
|
use ark_ff::PrimeField;
|
||||||
use ark_ff::{PrimeField};
|
|
||||||
use digest::DynDigest;
|
use digest::DynDigest;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use num_bigint::BigInt;
|
use num_bigint::BigInt;
|
||||||
use crate::errors::ProofVerifyError;
|
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use num_bigint::BigInt;
|
use num_bigint::BigInt;
|
||||||
|
|
||||||
use super::scalar::Scalar;
|
use super::scalar::Scalar;
|
||||||
use ark_ec::{AffineCurve, ProjectiveCurve};
|
use ark_ec::{AffineCurve, ProjectiveCurve};
|
||||||
|
use ark_ec::{AffineCurve, ProjectiveCurve};
|
||||||
|
use ark_serialize::*;
|
||||||
use ark_serialize::*;
|
use ark_serialize::*;
|
||||||
use core::borrow::Borrow;
|
use core::borrow::Borrow;
|
||||||
use core::ops::{Mul, MulAssign};
|
use core::ops::{Mul, MulAssign};
|
||||||
use ark_ec::{ProjectiveCurve, AffineCurve};
|
|
||||||
use ark_serialize::*;
|
|
||||||
|
|
||||||
pub type GroupElement = ark_bls12_377::G1Projective;
|
pub type GroupElement = ark_bls12_377::G1Projective;
|
||||||
pub type GroupElementAffine = ark_bls12_377::G1Affine;
|
pub type GroupElementAffine = ark_bls12_377::G1Affine;
|
||||||
@@ -51,9 +49,7 @@ impl CompressGroupElement for GroupElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl DecompressGroupElement for GroupElement {
|
impl DecompressGroupElement for GroupElement {
|
||||||
fn decompress(encoded: &CompressedGroup) -> Option<Self>
|
fn decompress(encoded: &CompressedGroup) -> Option<Self> {
|
||||||
{
|
|
||||||
|
|
||||||
let res = GroupElement::deserialize(&*encoded.0);
|
let res = GroupElement::deserialize(&*encoded.0);
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
println!("{:?}", res);
|
println!("{:?}", res);
|
||||||
@@ -76,13 +72,15 @@ pub trait VartimeMultiscalarMul {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl VartimeMultiscalarMul for GroupElement {
|
impl VartimeMultiscalarMul for GroupElement {
|
||||||
fn vartime_multiscalar_mul(
|
fn vartime_multiscalar_mul(scalars: &[Scalar], points: &[GroupElement]) -> GroupElement {
|
||||||
scalars: &[Scalar],
|
let repr_scalars = scalars
|
||||||
points: &[GroupElement],
|
.into_iter()
|
||||||
) -> GroupElement{
|
.map(|S| S.borrow().into_repr())
|
||||||
let repr_scalars= scalars.into_iter().map(|S| S.borrow().into_repr()).collect::<Vec<<Scalar as PrimeField>::BigInt>>();
|
.collect::<Vec<<Scalar as PrimeField>::BigInt>>();
|
||||||
let aff_points = points.into_iter().map(|P| P.borrow().into_affine()).collect::<Vec<GroupElementAffine>>();
|
let aff_points = points
|
||||||
|
.into_iter()
|
||||||
|
.map(|P| P.borrow().into_affine())
|
||||||
|
.collect::<Vec<GroupElementAffine>>();
|
||||||
VariableBaseMSM::multi_scalar_mul(aff_points.as_slice(), repr_scalars.as_slice())
|
VariableBaseMSM::multi_scalar_mul(aff_points.as_slice(), repr_scalars.as_slice())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user