Skip to content

Commit 5c1fc54

Browse files
committed
solving compilation problems
1 parent c7327bf commit 5c1fc54

File tree

4 files changed

+28
-7
lines changed

4 files changed

+28
-7
lines changed

mithril-client/src/verifier.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,21 @@ impl Verifier for VerifierImpl {
9393
) -> Result<(), ProtocolError> {
9494
debug!("Verify multi signature for {:?}", message);
9595
let clerk = self.create_clerk(signers_with_stakes, protocol_parameters);
96-
let multi_signature: ProtocolMultiSignature =
97-
key_decode_hex(multi_signature).map_err(ProtocolError::VerifyMultiSignatureError)?;
98-
clerk
96+
97+
// todo: these two declarations are patches. Probably better ways to do this.
98+
let avk = clerk
9999
.as_ref()
100100
.unwrap()
101-
.verify_msig(&multi_signature, message)
101+
.compute_avk();
102+
let protocol_parameters = ProtocolParameters {
103+
k: protocol_parameters.k,
104+
m: protocol_parameters.m,
105+
phi_f: protocol_parameters.phi_f as f64,
106+
};
107+
let multi_signature: ProtocolMultiSignature =
108+
key_decode_hex(multi_signature).map_err(ProtocolError::VerifyMultiSignatureError)?;
109+
multi_signature
110+
.verify(message, &avk, &protocol_parameters)
102111
.map_err(|e| ProtocolError::VerifyMultiSignatureError(e.to_string()))
103112
}
104113
}

mithril-core/src/dense_mapping.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ pub(crate) fn ev_lt_phi(phi_f: f64, ev: [u8; 64], stake: Stake, total_stake: Sta
110110

111111
#[cfg(test)]
112112
mod tests {
113-
use proptest::prelude::*;
113+
use super::*;
114114
use num_bigint::{BigInt, Sign};
115115
use num_rational::Ratio;
116-
use super::*;
116+
use proptest::prelude::*;
117117
// Implementation of `ev_lt_phi` without approximation. We only get the precision of f64 here.
118118
fn simple_ev_lt_phi(phi_f: f64, ev: [u8; 64], stake: Stake, total_stake: Stake) -> bool {
119119
let ev_max = BigInt::from(2u8).pow(512);

mithril-core/src/stm.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ pub type PartyId = u64;
144144
pub type Index = u64;
145145

146146
/// Used to set protocol parameters.
147+
// todo: this is the criteria to consider parameters valid:
148+
// Let A = max assumed adversarial stake
149+
// Let a = A / max_stake
150+
// Let p = φ(a) // f needs tuning, something close to 0.2 is reasonable
151+
// Then, we're secure if SUM[from i=k to i=m] Binomial(i successes, m experiments, p chance of success) <= 2^-100 or thereabouts.
152+
// The latter turns to 1 - BinomialCDF(k-1,m,p)
147153
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
148154
#[repr(C)]
149155
pub struct StmParameters {

mithril-signer/src/single_signer.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use thiserror::Error;
44

55
use mithril_common::crypto_helper::{
66
key_decode_hex, key_encode_hex, Bytes, ProtocolInitializer, ProtocolKeyRegistration,
7-
ProtocolParameters, ProtocolPartyId, ProtocolSingleSignature, ProtocolSigner, ProtocolSignerSecretKey, ProtocolStake,
7+
ProtocolParameters, ProtocolPartyId, ProtocolSigner, ProtocolSignerSecretKey, ProtocolStake,
88
};
99
use mithril_common::entities::{self, SignerWithStake, SingleSignature};
1010

@@ -207,6 +207,12 @@ mod tests {
207207
assert!(!sign_result.as_ref().unwrap().is_empty());
208208
for sig in sign_result.unwrap() {
209209
let decoded_sig: ProtocolSingleSignature = key_decode_hex(&sig.signature).unwrap();
210+
// todo: patch
211+
let protocol_parameters = ProtocolParameters {
212+
k: protocol_parameters.k,
213+
m: protocol_parameters.m,
214+
phi_f: protocol_parameters.phi_f as f64,
215+
};
210216
assert!(decoded_sig.verify(&protocol_parameters, &avk, message).is_ok());
211217
assert_eq!(
212218
decoded_sig.pk,

0 commit comments

Comments
 (0)