Remove "as", except for floats as needed

Also updates Bulletproofs from C to not be length prefixed, yet rather 
have Rust calculate their length.

Corrects an error in key_gen where self was blamed, instead of the 
faulty participant.
This commit is contained in:
Luke Parker
2022-05-30 02:14:34 -04:00
parent 614badfef7
commit ce4c899422
10 changed files with 38 additions and 24 deletions

View File

@@ -200,7 +200,7 @@ fn complete_r2<R: RngCore + CryptoRng, C: Curve>(
// Step 2. Verify each share
let mut shares = HashMap::new();
for (l, share) in serialized {
shares.insert(l, C::F_from_slice(&share).map_err(|_| FrostError::InvalidShare(params.i()))?);
shares.insert(l, C::F_from_slice(&share).map_err(|_| FrostError::InvalidShare(l))?);
}
// Calculate the exponent for a given participant and apply it to a series of commitments
@@ -240,6 +240,7 @@ fn complete_r2<R: RngCore + CryptoRng, C: Curve>(
// Stripe commitments per t and sum them in advance. Calculating verification shares relies on
// these sums so preprocessing them is a massive speedup
// If these weren't just sums, yet the tables used in multiexp, this would be further optimized
// As of right now, each multiexp will regenerate them
let mut stripes = Vec::with_capacity(usize::from(params.t()));
for t in 0 .. usize::from(params.t()) {
stripes.push(commitments.values().map(|commitments| commitments[t]).sum());

View File

@@ -143,7 +143,7 @@ fn sign_with_share<C: Curve, A: Algorithm<C>>(
let commitments = commitments.remove(l).unwrap();
let mut read_commitment = |c, label| {
let commitment = &commitments[c .. c + C::G_len()];
let commitment = &commitments[c .. (c + C::G_len())];
transcript.append_message(label, commitment);
C::G_from_slice(commitment).map_err(|_| FrostError::InvalidCommitment(*l))
};

View File

@@ -27,7 +27,7 @@ impl Curve for Secp256k1 {
}
fn id_len() -> u8 {
Self::id().len() as u8
u8::try_from(Self::id().len()).unwrap()
}
fn generator() -> Self::G {