mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
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:
@@ -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());
|
||||
|
||||
@@ -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))
|
||||
};
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -55,7 +55,7 @@ pub fn multiexp<
|
||||
}
|
||||
|
||||
for s in 0 .. tables.len() {
|
||||
res += tables[s][nibbles[s][b] as usize];
|
||||
res += tables[s][usize::from(nibbles[s][b])];
|
||||
}
|
||||
}
|
||||
res
|
||||
@@ -75,7 +75,7 @@ pub fn multiexp_vartime<
|
||||
|
||||
for s in 0 .. tables.len() {
|
||||
if nibbles[s][b] != 0 {
|
||||
res += tables[s][nibbles[s][b] as usize];
|
||||
res += tables[s][usize::from(nibbles[s][b])];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user