pub struct ZkProofSystem { /* private fields */ }Expand description
Zero-Knowledge Proof System
Implementations§
Source§impl ZkProofSystem
impl ZkProofSystem
pub fn new() -> Self
pub fn create_circuit(&mut self, circuit_id: String) -> Result<(), ZkError>
Sourcepub fn add_variable(
&mut self,
circuit_id: &str,
variable_id: String,
variable_type: VariableType,
) -> Result<(), ZkError>
pub fn add_variable( &mut self, circuit_id: &str, variable_id: String, variable_type: VariableType, ) -> Result<(), ZkError>
Add variable to circuit
Sourcepub fn add_constraint(
&mut self,
circuit_id: &str,
left: CircuitExpression,
right: CircuitExpression,
output: CircuitExpression,
) -> Result<(), ZkError>
pub fn add_constraint( &mut self, circuit_id: &str, left: CircuitExpression, right: CircuitExpression, output: CircuitExpression, ) -> Result<(), ZkError>
Add constraint to circuit
Sourcepub fn generate_keys(&mut self, circuit_id: &str) -> Result<(), ZkError>
pub fn generate_keys(&mut self, circuit_id: &str) -> Result<(), ZkError>
Generate proving and verifying keys
Sourcepub fn generate_proof(
&mut self,
circuit_id: &str,
witness: HashMap<String, FieldElement>,
public_inputs: Vec<FieldElement>,
) -> Result<ZkProof, ZkError>
pub fn generate_proof( &mut self, circuit_id: &str, witness: HashMap<String, FieldElement>, public_inputs: Vec<FieldElement>, ) -> Result<ZkProof, ZkError>
Generate zero-knowledge proof
Sourcepub fn verify_proof(
&mut self,
proof: &ZkProof,
) -> Result<VerificationResult, ZkError>
pub fn verify_proof( &mut self, proof: &ZkProof, ) -> Result<VerificationResult, ZkError>
Verify zero-knowledge proof
Sourcepub fn generate_semantic_proof(
&mut self,
statement: MathematicalStatement,
witness: HashMap<String, FieldElement>,
) -> Result<SemanticProof, ZkError>
pub fn generate_semantic_proof( &mut self, statement: MathematicalStatement, witness: HashMap<String, FieldElement>, ) -> Result<SemanticProof, ZkError>
Generate semantic proof for mathematical statement
Sourcepub fn verify_semantic_proof(
&mut self,
semantic_proof: &mut SemanticProof,
) -> Result<(), ZkError>
pub fn verify_semantic_proof( &mut self, semantic_proof: &mut SemanticProof, ) -> Result<(), ZkError>
Verify semantic proof
Sourcepub fn prove_matrix_multiply(
&mut self,
m: usize,
k: usize,
n: usize,
a: &[i128],
b: &[i128],
) -> Result<(bool, Vec<i128>), ZkError>
pub fn prove_matrix_multiply( &mut self, m: usize, k: usize, n: usize, a: &[i128], b: &[i128], ) -> Result<(bool, Vec<i128>), ZkError>
Prove, in zero knowledge, that C = A·B where A is m×k and B is k×n
(both row-major, integer field values), WITHOUT revealing A or B.
This builds a real R1CS circuit: every A[i][p] and B[p][j] is a private
witness, every result entry C[i][j] is a public input, and for each (i,j)
the circuit enforces Σ_p A[i][p]·B[p][j] = C[i][j]. A Groth16 proof over that
circuit is generated and verified. Ok(true) means the proof verifies — i.e.
the prover really knows A, B whose product is the published C. (Contrast
the previous placeholder, which proved an empty circuit and attested nothing.)
C is computed here from the integer inputs so the constraint is exact; the
returned flag reflects genuine cryptographic verification, not a structural
check. The result entries are returned so the caller can publish/compare them.
Sourcepub fn get_performance_stats(&self) -> ZkGlobalMetrics
pub fn get_performance_stats(&self) -> ZkGlobalMetrics
Get performance statistics
Sourcepub fn list_circuits(&self) -> Vec<String>
pub fn list_circuits(&self) -> Vec<String>
List all circuits
Sourcepub fn get_circuit_info(&self, circuit_id: &str) -> Option<ArithmeticCircuit>
pub fn get_circuit_info(&self, circuit_id: &str) -> Option<ArithmeticCircuit>
Get circuit information
Auto Trait Implementations§
impl Freeze for ZkProofSystem
impl RefUnwindSafe for ZkProofSystem
impl Send for ZkProofSystem
impl Sync for ZkProofSystem
impl Unpin for ZkProofSystem
impl UnsafeUnpin for ZkProofSystem
impl UnwindSafe for ZkProofSystem
Blanket Implementations§
§impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more