Skip to content

Commit d3406a2

Browse files
curiecryptiquerejeta
authored andcommitted
Removed dependency of StmSig on hasher
1 parent bf76f93 commit d3406a2

File tree

7 files changed

+80
-226
lines changed

7 files changed

+80
-226
lines changed

mithril-common/src/crypto_helper/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub type ProtocolClerk = StmClerk<D>;
4949
pub type ProtocolKeyRegistration = KeyRegWrapper;
5050

5151
/// Alias of [MithrilCore:StmSig](struct@mithril::stm::StmSig).
52-
pub type ProtocolSingleSignature = StmSig<D>;
52+
pub type ProtocolSingleSignature = StmSig;
5353

5454
/// Alias of [MithrilCore:StmAggrSig](struct@mithril::stm::StmAggrSig).
5555
pub type ProtocolMultiSignature = StmAggrSig<D>;

mithril-core/Comparison.md

Lines changed: 0 additions & 144 deletions
This file was deleted.

mithril-core/README.md

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -110,46 +110,44 @@ We have run the benchmarks on a 2,7 GHz Quad-Core Intel Core i7 machine with 16
110110
|-------------------|
111111
| Trivial proofs |
112112
+-------------------+
113-
| This gives and upper bound of the size
114-
| as it assumes that at most one signature
115-
| is provided by each participant.
113+
| Results obtained by using the parameters suggested in paper.
116114
+-------------------+
117115
+-------------------+
118116
| Hash: Blake2b 512 |
119117
+-------------------+
120-
k = 25 | nr parties = 300; 19000 bytes
118+
k = 445 | m = 2728 | nr parties = 3000; 118760 bytes
121119
+-------------------+
122-
| Hash: SHA256 |
120+
| Hash: Blake2b 256 |
123121
+-------------------+
124-
k = 25 | nr parties = 300; 11800 bytes
122+
k = 445 | m = 2728 | nr parties = 3000; 99384 bytes
125123
+-------------------+
126124
| Hash: Blake2b 512 |
127125
+-------------------+
128-
k = 250 | nr parties = 2000; 222000 bytes
126+
k = 554 | m = 3597 | nr parties = 3000; 133936 bytes
129127
+-------------------+
130-
| Hash: SHA256 |
128+
| Hash: Blake2b 256 |
131129
+-------------------+
132-
k = 250 | nr parties = 2000; 134000 bytes
133-
130+
k = 554 | m = 3597 | nr parties = 3000; 113728 bytes
134131
```
135132

136133
```shell
137-
STM/Blake2b/Key registration/k: 25, m: 150, nr_parties: 300
138-
time: [1.4680 s 1.4706 s 1.4734 s]
139-
STM/Blake2b/Play all lotteries/k: 25, m: 150, nr_parties: 300
140-
time: [5.1228 ms 5.1296 ms 5.1361 ms]
141-
STM/Blake2b/Aggregation/k: 25, m: 150, nr_parties: 300
142-
time: [89.231 ms 89.371 ms 89.495 ms]
143-
STM/Blake2b/Verification/k: 25, m: 150, nr_parties: 300
144-
time: [33.170 ms 33.225 ms 33.292 ms]
145-
STM/Blake2b/Key registration/k: 250, m: 1523, nr_parties: 2000
146-
time: [9.8741 s 9.9102 s 9.9644 s]
147-
STM/Blake2b/Play all lotteries/k: 250, m: 1523, nr_parties: 2000
148-
time: [48.935 ms 49.058 ms 49.185 ms]
149-
STM/Blake2b/Aggregation/k: 250, m: 1523, nr_parties: 2000
150-
time: [816.11 ms 817.55 ms 819.00 ms]
151-
STM/Blake2b/Verification/k: 250, m: 1523, nr_parties: 2000
152-
time: [293.18 ms 293.63 ms 294.19 ms]
134+
STM/Blake2b/Key registration/k: 25, m: 150, nr_parties: 300
135+
time: [388.95 ms 389.43 ms 389.90 ms]
136+
STM/Blake2b/Play all lotteries/k: 25, m: 150, nr_parties: 300
137+
time: [699.76 µs 701.42 µs 703.63 µs]
138+
STM/Blake2b/Aggregation/k: 25, m: 150, nr_parties: 300
139+
time: [18.888 ms 18.903 ms 18.920 ms]
140+
STM/Blake2b/Verification/k: 25, m: 150, nr_parties: 300
141+
time: [2.1547 ms 2.1609 ms 2.1686 ms]
142+
143+
STM/Blake2b/Key registration/k: 250, m: 1523, nr_parties: 2000
144+
time: [2.5986 s 2.6042 s 2.6101 s]
145+
STM/Blake2b/Play all lotteries/k: 250, m: 1523, nr_parties: 2000
146+
time: [5.9141 ms 5.9346 ms 5.9641 ms]
147+
STM/Blake2b/Aggregation/k: 250, m: 1523, nr_parties: 2000
148+
time: [189.63 ms 190.10 ms 190.69 ms]
149+
STM/Blake2b/Verification/k: 250, m: 1523, nr_parties: 2000
150+
time: [14.040 ms 14.143 ms 14.271 ms]
153151
```
154152

155153
# ToDo list once we go public

mithril-core/proptest-regressions/stm.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ cc bfe6fbad028ad86d75df7c75d29ee8f3279a81acbf50ef971b3dae92d529eeeb # shrinks to
1313
cc 9ef4bbf885dd054e2e54c85d0a54ef324d5ef7af232157c50bd55986640c6cab # shrinks to nparties = 7, m = 11, k = 1, msg = [16, 197, 45, 60, 228, 119, 173, 69, 2, 156, 57, 238, 34, 178, 228, 198]
1414
cc 533659c456e216b566b35d413e0b505c6e4d8d04ab402d79343e46a5a32c7c9d # shrinks to nparties = 18, m = 11, k = 1, msg = [78, 114, 142, 29, 122, 86, 154, 181, 170, 165, 114, 115, 234, 82, 143, 36]
1515
cc f2c14c2a2d3f02a4d98028f41effa69c153529df611e2206e9cbf540e7a99079 # shrinks to nparties = 2, m = 14, k = 1, msg = [69, 0, 87, 0, 53, 5, 58, 203, 42, 90, 66, 244, 89, 95, 198, 22]
16+
cc 55d304e2dd7bed15dace28eaf8d75174ff9b43e12b98257eb0c5f9296dae66d8 # shrinks to nparties = 21, m = 13, k = 3, msg = [21, 101, 128, 247, 30, 236, 71, 44, 165, 161, 251, 81, 117, 162, 221, 120]
17+
cc 174b0d31fe87e15ff2e295149062b3adc65b722d8cff4c08257d4b93d72b086b # shrinks to nparties = 15, m = 10, k = 3, msg = [217, 131, 84, 187, 173, 212, 75, 52, 100, 187, 38, 147, 226, 0, 218, 88]

mithril-core/src/error.rs

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ pub enum MultiSignatureError {
3030
/// Errors which can be output by Mithril single signature verification.
3131
#[derive(Debug, Clone, thiserror::Error)]
3232
pub enum StmSignatureError {
33-
/// The IVK is invalid after aggregating the keys
34-
#[error("Aggregated key does not correspond to the expected key.")]
35-
IvkInvalid(VerificationKey),
36-
3733
/// There is an index out of bounds
3834
#[error("Received index, {0}, is higher than what the security parameter allows, {1}.")]
3935
IndexBoundFailed(u64, u64),
@@ -48,7 +44,7 @@ pub enum StmSignatureError {
4844

4945
/// A party submitted an invalid signature
5046
#[error("A provided signature is invalid")]
51-
SingleSignatureInvalid(Signature),
47+
SignatureInvalid(Signature),
5248

5349
/// This error occurs when the the serialization of the raw bytes failed
5450
#[error("Invalid bytes")]
@@ -66,17 +62,17 @@ pub enum StmAggregateSignatureError<D: Digest + FixedOutput> {
6662
#[error("Aggregated key does not correspond to the expected key.")]
6763
IvkInvalid(VerificationKey),
6864

69-
/// There is an index out of bounds
70-
#[error("Received index, {0}, is higher than what the security parameter allows, {1}.")]
71-
IndexBoundFailed(u64, u64),
72-
7365
/// There is a duplicate index
7466
#[error("Indices are not unique.")]
7567
IndexNotUnique,
7668

7769
/// The aggregated signature is invalid
7870
#[error("Aggregate signature is invalid")]
79-
SignatureInvalid,
71+
AggregateSignatureInvalid,
72+
73+
/// One of the aggregated signatures is invalid
74+
#[error("Individual signature is invalid: {0}")]
75+
IndividualSignatureInvalid(StmSignatureError),
8076

8177
/// This error occurs when the the serialization of the raw bytes failed
8278
#[error("Invalid bytes")]
@@ -135,16 +131,16 @@ pub enum RegisterError {
135131
UnregisteredInitializer,
136132
}
137133

138-
impl From<RegisterError> for StmSignatureError {
139-
fn from(e: RegisterError) -> Self {
140-
match e {
141-
RegisterError::SerializationError => Self::SerializationError,
142-
RegisterError::KeyInvalid(e) => Self::IvkInvalid(e.vk),
143-
RegisterError::KeyRegistered(_) => unreachable!(),
144-
RegisterError::UnregisteredInitializer => unreachable!(),
145-
}
146-
}
147-
}
134+
// impl From<RegisterError> for StmSignatureError {
135+
// fn from(e: RegisterError) -> Self {
136+
// match e {
137+
// RegisterError::SerializationError => Self::SerializationError,
138+
// RegisterError::KeyInvalid(e) => Self::IvkInvalid(e.vk),
139+
// RegisterError::KeyRegistered(_) => unreachable!(),
140+
// RegisterError::UnregisteredInitializer => unreachable!(),
141+
// }
142+
// }
143+
// }
148144

149145
impl<D: Digest + FixedOutput> From<MerkleTreeError<D>> for StmAggregateSignatureError<D> {
150146
fn from(e: MerkleTreeError<D>) -> Self {
@@ -160,8 +156,8 @@ impl From<MultiSignatureError> for StmSignatureError {
160156
fn from(e: MultiSignatureError) -> Self {
161157
match e {
162158
MultiSignatureError::SerializationError => Self::SerializationError,
163-
MultiSignatureError::KeyInvalid(e) => Self::IvkInvalid(e.vk),
164-
MultiSignatureError::SignatureInvalid(e) => Self::SingleSignatureInvalid(e),
159+
MultiSignatureError::SignatureInvalid(e) => Self::SignatureInvalid(e),
160+
MultiSignatureError::KeyInvalid(_) => unreachable!(),
165161
MultiSignatureError::AggregateSignatureInvalid => unreachable!(),
166162
}
167163
}
@@ -173,21 +169,14 @@ impl<D: Digest + FixedOutput> From<MultiSignatureError> for StmAggregateSignatur
173169
MultiSignatureError::SerializationError => Self::SerializationError,
174170
MultiSignatureError::KeyInvalid(e) => Self::IvkInvalid(e.vk),
175171
MultiSignatureError::SignatureInvalid(_e) => unreachable!(),
176-
MultiSignatureError::AggregateSignatureInvalid => Self::SignatureInvalid,
172+
MultiSignatureError::AggregateSignatureInvalid => Self::AggregateSignatureInvalid,
177173
}
178174
}
179175
}
180176

181177
impl<D: Digest + FixedOutput> From<StmSignatureError> for StmAggregateSignatureError<D> {
182178
fn from(e: StmSignatureError) -> Self {
183-
match e {
184-
StmSignatureError::SerializationError => Self::SerializationError,
185-
StmSignatureError::IvkInvalid(e) => Self::IvkInvalid(e),
186-
StmSignatureError::SingleSignatureInvalid(_e) => unreachable!(),
187-
StmSignatureError::IndexBoundFailed(e, _e) => Self::IndexBoundFailed(e, _e),
188-
StmSignatureError::LotteryLost => unreachable!(),
189-
StmSignatureError::EvalInvalid(_e) => unreachable!(),
190-
}
179+
StmAggregateSignatureError::IndividualSignatureInvalid(e)
191180
}
192181
}
193182

mithril-core/src/key_reg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl KeyReg {
7474
MTLeaf(vk, stake)
7575
})
7676
.collect::<Vec<RegParty>>();
77-
reg_parties.sort();
77+
reg_parties.sort_unstable();
7878

7979
ClosedKeyReg {
8080
merkle_tree: Arc::new(MerkleTree::create(&reg_parties)),

0 commit comments

Comments
 (0)