mirror of
https://github.com/arnaucube/Nova.git
synced 2026-01-12 00:51:28 +01:00
Add serde proof serialization (#123)
* Bump commit. * Bump commit. * (WIP) Add serde support * Minor fixes * Use neptune const generics * Use git patches * Impl serde for CompressedSNARK * Update dependencies, revert to typenum * Formatting * Update bellperson-nonnative patch * Cleanup * Remove bellperson-nonnative fork * Switch back to fil_pasta_curves * Update forked dependencies * Cleanup * Remove unnecessary patch * Update to lurk-pasta-msm --------- Co-authored-by: porcuquine <porcuquine@users.noreply.github.com>
This commit is contained in:
@@ -10,6 +10,7 @@ use core::{
|
||||
use ff::{PrimeField, PrimeFieldBits};
|
||||
use merlin::Transcript;
|
||||
use num_bigint::BigInt;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Represents an element of a group
|
||||
/// This is currently tailored for an elliptic curve group
|
||||
@@ -25,25 +26,35 @@ pub trait Group:
|
||||
+ ScalarMulOwned<<Self as Group>::Scalar>
|
||||
+ Send
|
||||
+ Sync
|
||||
+ Serialize
|
||||
+ for<'de> Deserialize<'de>
|
||||
{
|
||||
/// A type representing an element of the base field of the group
|
||||
type Base: PrimeField + PrimeFieldBits;
|
||||
type Base: PrimeField + PrimeFieldBits + Serialize + for<'de> Deserialize<'de>;
|
||||
|
||||
/// A type representing an element of the scalar field of the group
|
||||
type Scalar: PrimeField + PrimeFieldBits + ChallengeTrait + Send + Sync;
|
||||
type Scalar: PrimeField
|
||||
+ PrimeFieldBits
|
||||
+ ChallengeTrait
|
||||
+ Send
|
||||
+ Sync
|
||||
+ Serialize
|
||||
+ for<'de> Deserialize<'de>;
|
||||
|
||||
/// A type representing the compressed version of the group element
|
||||
type CompressedGroupElement: CompressedGroup<GroupElement = Self>;
|
||||
type CompressedGroupElement: CompressedGroup<GroupElement = Self>
|
||||
+ Serialize
|
||||
+ for<'de> Deserialize<'de>;
|
||||
|
||||
/// A type representing preprocessed group element
|
||||
type PreprocessedGroupElement: Clone + Send + Sync;
|
||||
type PreprocessedGroupElement: Clone + Send + Sync + Serialize + for<'de> Deserialize<'de>;
|
||||
|
||||
/// A type that represents a hash function that consumes elements
|
||||
/// from the base field and squeezes out elements of the scalar field
|
||||
type RO: ROTrait<Self::Base, Self::Scalar>;
|
||||
type RO: ROTrait<Self::Base, Self::Scalar> + Serialize + for<'de> Deserialize<'de>;
|
||||
|
||||
/// An alternate implementation of Self::RO in the circuit model
|
||||
type ROCircuit: ROCircuitTrait<Self::Base>;
|
||||
type ROCircuit: ROCircuitTrait<Self::Base> + Serialize + for<'de> Deserialize<'de>;
|
||||
|
||||
/// A method to compute a multiexponentation
|
||||
fn vartime_multiscalar_mul(
|
||||
@@ -74,9 +85,11 @@ pub trait Group:
|
||||
}
|
||||
|
||||
/// Represents a compressed version of a group element
|
||||
pub trait CompressedGroup: Clone + Copy + Debug + Eq + Sized + Send + Sync + 'static {
|
||||
pub trait CompressedGroup:
|
||||
Clone + Copy + Debug + Eq + Sized + Send + Sync + Serialize + for<'de> Deserialize<'de> + 'static
|
||||
{
|
||||
/// A type that holds the decompressed version of the compressed group element
|
||||
type GroupElement: Group;
|
||||
type GroupElement: Group + Serialize + for<'de> Deserialize<'de>;
|
||||
|
||||
/// Decompresses the compressed group element
|
||||
fn decompress(&self) -> Option<Self::GroupElement>;
|
||||
@@ -106,7 +119,12 @@ pub trait ChallengeTrait {
|
||||
/// A helper trait that defines the behavior of a hash function that we use as an RO
|
||||
pub trait ROTrait<Base, Scalar> {
|
||||
/// A type representing constants/parameters associated with the hash function
|
||||
type Constants: ROConstantsTrait<Base> + Clone + Send + Sync;
|
||||
type Constants: ROConstantsTrait<Base>
|
||||
+ Clone
|
||||
+ Send
|
||||
+ Sync
|
||||
+ Serialize
|
||||
+ for<'de> Deserialize<'de>;
|
||||
|
||||
/// Initializes the hash function
|
||||
fn new(constants: Self::Constants, num_absorbs: usize) -> Self;
|
||||
@@ -121,7 +139,12 @@ pub trait ROTrait<Base, Scalar> {
|
||||
/// A helper trait that defines the behavior of a hash function that we use as an RO in the circuit model
|
||||
pub trait ROCircuitTrait<Base: PrimeField> {
|
||||
/// A type representing constants/parameters associated with the hash function
|
||||
type Constants: ROConstantsTrait<Base> + Clone + Send + Sync;
|
||||
type Constants: ROConstantsTrait<Base>
|
||||
+ Clone
|
||||
+ Send
|
||||
+ Sync
|
||||
+ Serialize
|
||||
+ for<'de> Deserialize<'de>;
|
||||
|
||||
/// Initializes the hash function
|
||||
fn new(constants: Self::Constants, num_absorbs: usize) -> Self;
|
||||
|
||||
@@ -5,6 +5,8 @@ use crate::{
|
||||
traits::Group,
|
||||
};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// A trait that defines the behavior of a zkSNARK's prover key
|
||||
pub trait ProverKeyTrait<G: Group>: Send + Sync {
|
||||
/// Produces a new prover's key
|
||||
@@ -18,12 +20,14 @@ pub trait VerifierKeyTrait<G: Group>: Send + Sync {
|
||||
}
|
||||
|
||||
/// A trait that defines the behavior of a zkSNARK
|
||||
pub trait RelaxedR1CSSNARKTrait<G: Group>: Sized + Send + Sync {
|
||||
pub trait RelaxedR1CSSNARKTrait<G: Group>:
|
||||
Sized + Send + Sync + Serialize + for<'de> Deserialize<'de>
|
||||
{
|
||||
/// A type that represents the prover's key
|
||||
type ProverKey: ProverKeyTrait<G>;
|
||||
type ProverKey: ProverKeyTrait<G> + Serialize + for<'de> Deserialize<'de>;
|
||||
|
||||
/// A type that represents the verifier's key
|
||||
type VerifierKey: VerifierKeyTrait<G>;
|
||||
type VerifierKey: VerifierKeyTrait<G> + Serialize + for<'de> Deserialize<'de>;
|
||||
|
||||
/// Produces a prover key
|
||||
fn prover_key(gens: &R1CSGens<G>, S: &R1CSShape<G>) -> Self::ProverKey {
|
||||
|
||||
Reference in New Issue
Block a user