Skip to content

Commit 4185589

Browse files
committed
doc: add nicer example on landing to doc index.
1 parent 6c1f0b2 commit 4185589

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

src/lib.rs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,26 @@
1313
//!
1414
//! ---
1515
//!
16-
//! ## Key Features
17-
//!
18-
//! - **Composable**: Combine multiple proofs into compound statements
19-
//! - **Generic**: Works with any cryptographic group supporting the required operations
20-
//! - **Flexible Hashing**: Multiple hash function backends for different use cases
21-
//! - **Non-Interactive Ready**: Support for Fiat–Shamir transformation
22-
//!
23-
//! ---
24-
//!
2516
//! ## Basic Usage
2617
//!
18+
//! ```rust
19+
//! # use curve25519_dalek::ristretto::RistrettoPoint;
20+
//! # use curve25519_dalek::scalar::Scalar;
21+
//! # use group::Group;
22+
//!
23+
//! let mut instance = sigma_rs::LinearRelation::new();
24+
//! let mut rng = rand::thread_rng();
25+
//! let witness = vec![Scalar::random(&mut rng), Scalar::random(&mut rng)];
26+
//!
27+
//! let [var_x, var_r] = instance.allocate_scalars();
28+
//! let [var_G, var_H] = instance.allocate_elements();
29+
//! instance.allocate_eq(var_G * var_x + var_H * var_r);
30+
//! instance.set_elements([(var_G, RistrettoPoint::generator()), (var_H, RistrettoPoint::random(&mut rng))]);
31+
//! instance.compute_image(&witness);
32+
//! let narg_string: Vec<u8> = instance.into_nizk(b"your session identifier").unwrap().prove_batchable(&witness, &mut rng).unwrap();
33+
//! println!("{}", hex::encode(narg_string));
34+
//! ```
35+
//!
2736
//! The library provides building blocks for creating zero-knowledge proofs:
2837
//!
2938
//! 1. Define your mathematical relation using [`LinearRelation`]

src/tests/test_validation_criteria.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,10 @@ mod instance_validation {
181181
let mut rng = rand::thread_rng();
182182
let mut linear_relation = LinearRelation::new();
183183

184-
185184
let [x_var, y_var] = linear_relation.allocate_scalars();
186185
let [Z_var, A_var, B_var, C_var] = linear_relation.allocate_elements();
187186
linear_relation.append_equation(Z_var, x_var * A_var + y_var * B_var + C_var);
188187

189-
190188
let [x, y] = [Scalar::random(&mut rng), Scalar::random(&mut rng)];
191189
let Z = G::identity();
192190
let A = G::random(&mut rng);
@@ -252,7 +250,7 @@ mod proof_validation {
252250
assert!(nizk.verify_batchable(&proof).is_ok());
253251

254252
// Test bitflips at various positions
255-
for pos in 0 .. proof.len() {
253+
for pos in 0..proof.len() {
256254
let original_byte = proof[pos];
257255

258256
// Flip each bit in the byte

0 commit comments

Comments
 (0)