Skip to content

Commit b249a8f

Browse files
committed
readme update initial commit
1 parent f0d5c4e commit b249a8f

File tree

2 files changed

+36
-23
lines changed

2 files changed

+36
-23
lines changed

mithril-stm/README.md

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
Mithril-stm ![CI workflow](https://github.com/input-output-hk/mithril/actions/workflows/ci.yml/badge.svg) ![crates.io](https://img.shields.io/crates/v/mithril_stm.svg)
22
=======
3-
This crate is ongoing work, has not been audited, and it's API is by no means final. Do not use in production.
43

54
### A rust implementation of Stake-based Threshold Multisignatures (STMs)
65
`mithril-stm` implements Stake-based Threshold Multisignatures as described in the paper
@@ -22,19 +21,27 @@ This library provides implementations of:
2221

2322
The user-facing documentation for the above modules can be found [here]().
2423

24+
25+
Disclaimer
26+
=======
27+
This crate is ongoing work, has not been audited, and it's API is by no means final. Do not use in production.
28+
29+
2530
# Example
2631
```rust
2732
use mithril_stm::key_reg::KeyReg;
2833
use mithril_stm::stm::{StmClerk, StmInitializer, StmParameters, StmSig, StmSigner};
29-
use rayon::prelude::*;
34+
use mithril_stm::AggregationError;
3035

31-
use mithril_stm::error::AggregationFailure;
36+
use blake2::{digest::consts::U32, Blake2b};
37+
use rayon::prelude::*;
3238
use rand_chacha::ChaCha20Rng;
3339
use rand_core::{RngCore, SeedableRng};
3440

35-
type H = blake2::Blake2b;
41+
type H = Blake2b<U32>;
3642

37-
fn main() {
43+
#[test]
44+
fn test_full_protocol() {
3845
let nparties = 32;
3946
let mut rng = ChaCha20Rng::from_seed([0u8; 32]);
4047
let mut msg = [0u8; 16];
@@ -68,7 +75,7 @@ fn main() {
6875

6976
let ps = ps
7077
.into_par_iter()
71-
.map(|p| p.new_signer(closed_reg.clone()))
78+
.map(|p| p.new_signer(closed_reg.clone()).unwrap())
7279
.collect::<Vec<StmSigner<H>>>();
7380

7481
/////////////////////
@@ -78,7 +85,7 @@ fn main() {
7885
let sigs = ps
7986
.par_iter()
8087
.filter_map(|p| p.sign(&msg))
81-
.collect::<Vec<StmSig<H>>>();
88+
.collect::<Vec<StmSig>>();
8289

8390
let clerk = StmClerk::from_signer(&ps[0]);
8491
let avk = clerk.compute_avk();
@@ -91,9 +98,21 @@ fn main() {
9198
// Aggregate with random parties
9299
let msig = clerk.aggregate(&sigs, &msg);
93100

94-
assert!(msig.is_ok(), "aggregation failed");
95-
assert!(msig.unwrap().verify(&msg, &clerk.compute_avk(), &params).is_ok());
101+
match msig {
102+
Ok(aggr) => {
103+
println!("Aggregate ok");
104+
assert!(aggr.verify(&msg, &clerk.compute_avk(), &params).is_ok());
105+
}
106+
Err(AggregationError::NotEnoughSignatures(n, k)) => {
107+
println!("Not enough signatures");
108+
assert!(n < params.k && k == params.k)
109+
}
110+
Err(AggregationError::UsizeConversionInvalid) => {
111+
println!("Invalid usize conversion");
112+
}
113+
}
96114
}
115+
97116
```
98117

99118
# Test and Benchmarks
@@ -103,38 +122,36 @@ benchmarks.
103122

104123
We have run the benchmarks on an Apple M1 Pro machine with 16 GB of RAM, on macOS 12.6.
105124

106-
Note that single signatures in batch compat version does not depend on any variable and size of an individual signature is `176` bytes.
125+
> Note that single signatures in batch compat version does not depend on any variable and <mark> the size of an individual signature is 176 bytes. </mark>
107126
108127
```shell
109128
+----------------------+
110129
| Size of benchmarks |
111130
+----------------------+
112-
| Results obtained by using the parameters suggested in paper.
131+
| Results obtained by using the parameters suggested by the paper.
113132
+----------------------+
114133
+----------------------+
115134
| Aggregate signatures |
116135
+----------------------+
117136
+----------------------+
118137
| Hash: Blake2b 512 |
119138
+----------------------+
120-
k = 445 | m = 2728 | nr parties = 3000; 118760 bytes (old version = 356632 bytes)
139+
k = 445 | m = 2728 | nr parties = 3000; 118760 bytes
121140
+----------------------+
122141
| Hash: Blake2b 256 |
123142
+----------------------+
124-
k = 445 | m = 2728 | nr parties = 3000; 99384 bytes (old version = 222536 bytes)
143+
k = 445 | m = 2728 | nr parties = 3000; 99384 bytes
125144
+----------------------+
126145
+----------------------+
127146
| Aggregate signatures |
128147
+----------------------+
129148
| Hash: Blake2b 512 |
130149
+----------------------+
131-
k = 554 | m = 3597 | nr parties = 3000; 133936 bytes (old version = 419808 bytes)
150+
k = 554 | m = 3597 | nr parties = 3000; 133936 bytes
132151
+----------------------+
133152
| Hash: Blake2b 256 |
134153
+----------------------+
135-
k = 554 | m = 3597 | nr parties = 3000; 113728 bytes (old version = 261488 bytes)
136-
make build && ./mithrildemo --nparties 16 -k 5 -m 5 --phi-f 0.9
137-
154+
k = 554 | m = 3597 | nr parties = 3000; 113728 bytes
138155
```
139156

140157
```shell
@@ -155,7 +172,5 @@ STM/Blake2b/Aggregation/k: 250, m: 1523, nr_parties: 2000
155172
time: [190.81 ms 191.15 ms 191.54 ms]
156173
STM/Blake2b/Verification/k: 250, m: 1523, nr_parties: 2000
157174
time: [13.944 ms 14.010 ms 14.077 ms]
158-
159-
160175
```
161176

mithril-stm/tests/integration.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
use blake2::{digest::consts::U32, Blake2b};
2-
31
use mithril_stm::key_reg::KeyReg;
42
use mithril_stm::stm::{StmClerk, StmInitializer, StmParameters, StmSig, StmSigner};
53
use mithril_stm::AggregationError;
64

7-
use rayon::prelude::*;
8-
5+
use blake2::{digest::consts::U32, Blake2b};
96
use rand_chacha::ChaCha20Rng;
107
use rand_core::{RngCore, SeedableRng};
8+
use rayon::prelude::*;
119

1210
type H = Blake2b<U32>;
1311

0 commit comments

Comments
 (0)