mirror of
https://github.com/AleoHQ/leo.git
synced 2024-12-21 08:31:33 +03:00
use fp256 struct
This commit is contained in:
parent
2d71a6f3b8
commit
218a6e0864
@ -164,10 +164,9 @@ impl CLI for BuildCommand {
|
|||||||
|
|
||||||
use num_bigint::BigUint;
|
use num_bigint::BigUint;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use snarkos_curves::bls12_377::Fr;
|
|
||||||
use snarkos_errors::curves::FieldError;
|
use snarkos_errors::curves::FieldError;
|
||||||
use snarkos_models::curves::{Field, Fp256, Fp256Parameters, PrimeField};
|
use snarkos_models::curves::{Field, Fp256, Fp256Parameters};
|
||||||
use std::{convert::TryInto, str::FromStr};
|
use std::str::FromStr;
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
pub struct SerializedKeypairAssembly {
|
pub struct SerializedKeypairAssembly {
|
||||||
@ -242,11 +241,11 @@ impl TryFrom<SerializedKeypairAssembly> for KeypairAssembly<Bls12_377> {
|
|||||||
fn try_from(serialized: SerializedKeypairAssembly) -> Result<KeypairAssembly<Bls12_377>, Self::Error> {
|
fn try_from(serialized: SerializedKeypairAssembly) -> Result<KeypairAssembly<Bls12_377>, Self::Error> {
|
||||||
fn get_deserialized_constraints(
|
fn get_deserialized_constraints(
|
||||||
constraints: &Vec<(SerializedField, SerializedIndex)>,
|
constraints: &Vec<(SerializedField, SerializedIndex)>,
|
||||||
) -> Result<Vec<(Fr, Index)>, FieldError> {
|
) -> Result<Vec<(<Bls12_377 as PairingEngine>::Fr, Index)>, FieldError> {
|
||||||
let mut deserialized = vec![];
|
let mut deserialized = vec![];
|
||||||
|
|
||||||
for &(ref serialized_coeff, ref serialized_index) in constraints.iter() {
|
for &(ref serialized_coeff, ref serialized_index) in constraints.iter() {
|
||||||
let field = Fr::try_from(serialized_coeff)?;
|
let field = <Bls12_377 as PairingEngine>::Fr::try_from(serialized_coeff)?;
|
||||||
let index = Index::from(serialized_index);
|
let index = Index::from(serialized_index);
|
||||||
|
|
||||||
deserialized.push((field, index));
|
deserialized.push((field, index));
|
||||||
@ -306,11 +305,11 @@ impl<F: Field> From<&F> for SerializedField {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<&SerializedField> for Fr {
|
impl<P: Fp256Parameters> TryFrom<&SerializedField> for Fp256<P> {
|
||||||
type Error = FieldError;
|
type Error = FieldError;
|
||||||
|
|
||||||
fn try_from(serialized: &SerializedField) -> Result<Self, Self::Error> {
|
fn try_from(serialized: &SerializedField) -> Result<Self, Self::Error> {
|
||||||
Ok(Fr::from_str(&serialized.0).unwrap())
|
Fp256::<P>::from_str(&serialized.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user