Skip to content

Commit 3206e46

Browse files
authored
Code comments and documentation for crypto benchmarks (#588)
* Documented functions and structures * Added images * Added comments on fields. * Added efficiency notes. * Added figures to read-me * `cargo update`
1 parent 3e09387 commit 3206e46

29 files changed

+761
-419
lines changed

crypto-benchmarks.rs/Cargo.lock

Lines changed: 561 additions & 417 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crypto-benchmarks.rs/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ bitvec = "1.0.1"
1616
blst = "0.3.13"
1717
clap = { version = "4.5.28", features = ["derive"] }
1818
criterion = "0.5.1"
19+
embed-doc-image = "0.1.4"
1920
hex = "0.4.3"
2021
num-bigint = { version = "0.4.6", features = ["serde"] }
2122
num-rational = "0.4.2"
@@ -29,6 +30,12 @@ serde = { version = "1.0.217", features = ["derive"] }
2930
serde_cbor = "0.11.2"
3031
statrs = "0.18.0"
3132

33+
[features]
34+
doc-images = []
35+
36+
[package.metadata.docs.rs]
37+
features = ["doc-images"]
38+
3239
[[bench]]
3340
name = "serialization_bench"
3441
harness = false

crypto-benchmarks.rs/ReadMe.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,23 @@ See [Specification.md](Specification.md) for a description of the algorithms imp
77
- Benchmarks: [benches/](benches/)
88

99

10+
## Background material
11+
12+
![BLS scheme from original Leios preprint](figure-7-bls.png)
13+
14+
![Voting scheme from original Leios preprint](figure-8-voting.png)
15+
16+
17+
## Efficiency notes
18+
19+
The benchmark code uses an efficient BLS implementation, but it has not been optimized.
20+
21+
- Some of the hash data structures in the certificate could be replaced by bit sets.
22+
- The optional group checks are turned on for calls to the `blst` library even though in some cases these may not strictly be necessary.
23+
- The rational arthmetic for computing logarithms and performing sortition uses the maximum precision obtainable in `Ratio<BigInt>` even though that precision is not necessarily needed.
24+
- The code has not been profiled.
25+
26+
1027
## Command-line interface
1128

1229
A command-line interface is provided for testing and exploration. Note that all input and output files are CBOR.

crypto-benchmarks.rs/benches/fait_accompli_bench.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Criterion benchmarks for Fait Accompli.
2+
13
use criterion::{criterion_group, criterion_main, Criterion};
24
use quickcheck::{Arbitrary, Gen};
35
use std::collections::BTreeMap;

crypto-benchmarks.rs/benches/serialization_bench.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Criterion benchmarks for serialization and deserialization.
2+
13
use criterion::{criterion_group, criterion_main, Criterion};
24
use quickcheck::{Arbitrary, Gen};
35

crypto-benchmarks.rs/benches/sortition_bench.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Criterion benchmarks for sortition.
2+
13
use criterion::{criterion_group, criterion_main, Criterion};
24
use num_bigint::BigInt;
35
use num_rational::Ratio;

crypto-benchmarks.rs/benches/vote_bench.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Criterion benchmarks for voting.
2+
13
use criterion::{criterion_group, criterion_main, Criterion};
24
use leios_crypto_benchmarks::cert::*;
35
use leios_crypto_benchmarks::registry::{arbitrary_pools, PersistentId, Registry};

crypto-benchmarks.rs/benches/vrf_bench.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Criterion benchmarks for VRF.
2+
13
use criterion::{criterion_group, criterion_main, Criterion};
24

35
use leios_crypto_benchmarks::vrf::{sk_random, sk_to_pk_point, vrf_prove, vrf_verify};
193 KB
Loading
197 KB
Loading

0 commit comments

Comments
 (0)