mirror of
https://github.com/personaelabs/spartan-ecdsa.git
synced 2026-01-09 14:07:54 -05:00
Expose proof values so we can read them in Hoplite
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
[package]
|
||||
name = "spartan"
|
||||
version = "0.7.1"
|
||||
authors = ["Srinath Setty <srinath@microsoft.com>"]
|
||||
authors = ["Srinath Setty <srinath@microsoft.com>, Dan Tehrani"]
|
||||
edition = "2021"
|
||||
description = "High-speed zkSNARKs without trusted setup"
|
||||
documentation = "https://docs.rs/spartan/"
|
||||
readme = "README.md"
|
||||
repository = "https://github.com/microsoft/Spartan"
|
||||
license-file = "LICENSE"
|
||||
keywords = ["zkSNARKs", "cryptography", "proofs"]
|
||||
|
||||
@@ -39,19 +37,3 @@ criterion = "0.3.1"
|
||||
name = "libspartan"
|
||||
path = "src/lib.rs"
|
||||
crate-type = ["cdylib", "rlib"]
|
||||
|
||||
[[bin]]
|
||||
name = "snark"
|
||||
path = "profiler/snark.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "nizk"
|
||||
path = "profiler/nizk.rs"
|
||||
|
||||
[[bench]]
|
||||
name = "snark"
|
||||
harness = false
|
||||
|
||||
[[bench]]
|
||||
name = "nizk"
|
||||
harness = false
|
||||
|
||||
@@ -41,7 +41,7 @@ pub struct PolyCommitmentBlinds {
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct PolyCommitment {
|
||||
C: Vec<CompressedGroup>,
|
||||
pub C: Vec<CompressedGroup>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
@@ -299,7 +299,7 @@ impl AppendToTranscript for PolyCommitment {
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct PolyEvalProof {
|
||||
proof: DotProductProofLog,
|
||||
pub proof: DotProductProofLog,
|
||||
}
|
||||
|
||||
impl PolyEvalProof {
|
||||
|
||||
@@ -3,30 +3,30 @@ use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum ProofVerifyError {
|
||||
#[error("Proof verification failed")]
|
||||
InternalError,
|
||||
#[error("Compressed group element failed to decompress: {0:?}")]
|
||||
DecompressionError([u8; 32]),
|
||||
#[error("Proof verification failed")]
|
||||
InternalError,
|
||||
#[error("Compressed group element failed to decompress: {0:?}")]
|
||||
DecompressionError([u8; 32]),
|
||||
}
|
||||
|
||||
impl Default for ProofVerifyError {
|
||||
fn default() -> Self {
|
||||
ProofVerifyError::InternalError
|
||||
}
|
||||
fn default() -> Self {
|
||||
ProofVerifyError::InternalError
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub enum R1CSError {
|
||||
/// returned if the number of constraints is not a power of 2
|
||||
NonPowerOfTwoCons,
|
||||
/// returned if the number of variables is not a power of 2
|
||||
NonPowerOfTwoVars,
|
||||
/// returned if a wrong number of inputs in an assignment are supplied
|
||||
InvalidNumberOfInputs,
|
||||
/// returned if a wrong number of variables in an assignment are supplied
|
||||
InvalidNumberOfVars,
|
||||
/// returned if a [u8;32] does not parse into a valid Scalar in the field of secq256k1
|
||||
InvalidScalar,
|
||||
/// returned if the supplied row or col in (row,col,val) tuple is out of range
|
||||
InvalidIndex,
|
||||
/// returned if the number of constraints is not a power of 2
|
||||
NonPowerOfTwoCons,
|
||||
/// returned if the number of variables is not a power of 2
|
||||
NonPowerOfTwoVars,
|
||||
/// returned if a wrong number of inputs in an assignment are supplied
|
||||
InvalidNumberOfInputs,
|
||||
/// returned if a wrong number of variables in an assignment are supplied
|
||||
InvalidNumberOfVars,
|
||||
/// returned if a [u8;32] does not parse into a valid Scalar in the field of secq256k1
|
||||
InvalidScalar,
|
||||
/// returned if the supplied row or col in (row,col,val) tuple is out of range
|
||||
InvalidIndex,
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -15,8 +15,8 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct BulletReductionProof {
|
||||
L_vec: Vec<CompressedGroup>,
|
||||
R_vec: Vec<CompressedGroup>,
|
||||
pub L_vec: Vec<CompressedGroup>,
|
||||
pub R_vec: Vec<CompressedGroup>,
|
||||
}
|
||||
|
||||
impl BulletReductionProof {
|
||||
|
||||
@@ -11,13 +11,13 @@ use merlin::Transcript;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
mod bullet;
|
||||
use bullet::BulletReductionProof;
|
||||
pub use bullet::BulletReductionProof;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct KnowledgeProof {
|
||||
alpha: CompressedGroup,
|
||||
z1: Scalar,
|
||||
z2: Scalar,
|
||||
pub alpha: CompressedGroup,
|
||||
pub z1: Scalar,
|
||||
pub z2: Scalar,
|
||||
}
|
||||
|
||||
impl KnowledgeProof {
|
||||
@@ -77,8 +77,8 @@ impl KnowledgeProof {
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct EqualityProof {
|
||||
alpha: CompressedGroup,
|
||||
z: Scalar,
|
||||
pub alpha: CompressedGroup,
|
||||
pub z: Scalar,
|
||||
}
|
||||
|
||||
impl EqualityProof {
|
||||
@@ -146,10 +146,10 @@ impl EqualityProof {
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct ProductProof {
|
||||
alpha: CompressedGroup,
|
||||
beta: CompressedGroup,
|
||||
delta: CompressedGroup,
|
||||
z: [Scalar; 5],
|
||||
pub alpha: CompressedGroup,
|
||||
pub beta: CompressedGroup,
|
||||
pub delta: CompressedGroup,
|
||||
pub z: [Scalar; 5],
|
||||
}
|
||||
|
||||
impl ProductProof {
|
||||
@@ -292,11 +292,11 @@ impl ProductProof {
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct DotProductProof {
|
||||
delta: CompressedGroup,
|
||||
beta: CompressedGroup,
|
||||
z: Vec<Scalar>,
|
||||
z_delta: Scalar,
|
||||
z_beta: Scalar,
|
||||
pub delta: CompressedGroup,
|
||||
pub beta: CompressedGroup,
|
||||
pub z: Vec<Scalar>,
|
||||
pub z_delta: Scalar,
|
||||
pub z_beta: Scalar,
|
||||
}
|
||||
|
||||
impl DotProductProof {
|
||||
@@ -420,11 +420,11 @@ impl DotProductProofGens {
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct DotProductProofLog {
|
||||
bullet_reduction_proof: BulletReductionProof,
|
||||
delta: CompressedGroup,
|
||||
beta: CompressedGroup,
|
||||
z1: Scalar,
|
||||
z2: Scalar,
|
||||
pub bullet_reduction_proof: BulletReductionProof,
|
||||
pub delta: CompressedGroup,
|
||||
pub beta: CompressedGroup,
|
||||
pub z1: Scalar,
|
||||
pub z2: Scalar,
|
||||
}
|
||||
|
||||
impl DotProductProofLog {
|
||||
|
||||
@@ -21,26 +21,26 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct R1CSProof {
|
||||
comm_vars: PolyCommitment,
|
||||
sc_proof_phase1: ZKSumcheckInstanceProof,
|
||||
claims_phase2: (
|
||||
pub comm_vars: PolyCommitment,
|
||||
pub sc_proof_phase1: ZKSumcheckInstanceProof,
|
||||
pub claims_phase2: (
|
||||
CompressedGroup,
|
||||
CompressedGroup,
|
||||
CompressedGroup,
|
||||
CompressedGroup,
|
||||
),
|
||||
pok_claims_phase2: (KnowledgeProof, ProductProof),
|
||||
proof_eq_sc_phase1: EqualityProof,
|
||||
sc_proof_phase2: ZKSumcheckInstanceProof,
|
||||
comm_vars_at_ry: CompressedGroup,
|
||||
proof_eval_vars_at_ry: PolyEvalProof,
|
||||
proof_eq_sc_phase2: EqualityProof,
|
||||
pub pok_claims_phase2: (KnowledgeProof, ProductProof),
|
||||
pub proof_eq_sc_phase1: EqualityProof,
|
||||
pub sc_proof_phase2: ZKSumcheckInstanceProof,
|
||||
pub comm_vars_at_ry: CompressedGroup,
|
||||
pub proof_eval_vars_at_ry: PolyEvalProof,
|
||||
pub proof_eq_sc_phase2: EqualityProof,
|
||||
}
|
||||
|
||||
pub struct R1CSSumcheckGens {
|
||||
gens_1: MultiCommitGens,
|
||||
gens_3: MultiCommitGens,
|
||||
gens_4: MultiCommitGens,
|
||||
pub gens_1: MultiCommitGens,
|
||||
pub gens_3: MultiCommitGens,
|
||||
pub gens_4: MultiCommitGens,
|
||||
}
|
||||
|
||||
// TODO: fix passing gens_1_ref
|
||||
@@ -59,8 +59,8 @@ impl R1CSSumcheckGens {
|
||||
}
|
||||
|
||||
pub struct R1CSGens {
|
||||
gens_sc: R1CSSumcheckGens,
|
||||
gens_pc: PolyCommitmentGens,
|
||||
pub gens_sc: R1CSSumcheckGens,
|
||||
pub gens_pc: PolyCommitmentGens,
|
||||
}
|
||||
|
||||
impl R1CSGens {
|
||||
|
||||
@@ -1559,6 +1559,7 @@ impl SparseMatPolyEvalProof {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct SparsePolyEntry {
|
||||
idx: usize,
|
||||
val: Scalar,
|
||||
@@ -1609,7 +1610,7 @@ impl SparsePolynomial {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use rand_core::{RngCore, OsRng};
|
||||
use rand_core::{OsRng, RngCore};
|
||||
#[test]
|
||||
fn check_sparse_polyeval_proof() {
|
||||
let mut csprng: OsRng = OsRng;
|
||||
|
||||
@@ -64,9 +64,9 @@ impl SumcheckInstanceProof {
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct ZKSumcheckInstanceProof {
|
||||
comm_polys: Vec<CompressedGroup>,
|
||||
comm_evals: Vec<CompressedGroup>,
|
||||
proofs: Vec<DotProductProof>,
|
||||
pub comm_polys: Vec<CompressedGroup>,
|
||||
pub comm_evals: Vec<CompressedGroup>,
|
||||
pub proofs: Vec<DotProductProof>,
|
||||
}
|
||||
|
||||
impl ZKSumcheckInstanceProof {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::group::CompressedGroup;
|
||||
use super::scalar::Scalar;
|
||||
use merlin::Transcript;
|
||||
pub use merlin::Transcript;
|
||||
|
||||
pub trait ProofTranscript {
|
||||
fn append_protocol_name(&mut self, protocol_name: &'static [u8]);
|
||||
|
||||
Reference in New Issue
Block a user