Move FROST to Read

Fixes https://github.com/serai-dex/serai/issues/33 and 
https://github.com/serai-dex/serai/issues/35. Also fixes a few potential 
panics/DoS AFAICT.
This commit is contained in:
Luke Parker
2022-07-13 02:38:29 -04:00
parent c0c8915698
commit 6cc8ce840e
13 changed files with 357 additions and 349 deletions

View File

@@ -1,4 +1,5 @@
use core::{marker::PhantomData, fmt::Debug};
use std::io::Read;
use rand_core::{RngCore, CryptoRng};
@@ -28,11 +29,11 @@ pub trait Algorithm<C: Curve>: Clone {
) -> Vec<u8>;
/// Proccess the addendum for the specified participant. Guaranteed to be ordered
fn process_addendum(
fn process_addendum<Re: Read>(
&mut self,
params: &FrostView<C>,
l: u16,
serialized: &[u8],
reader: &mut Re,
) -> Result<(), FrostError>;
/// Sign a share with the given secret/nonce
@@ -133,11 +134,11 @@ impl<C: Curve, H: Hram<C>> Algorithm<C> for Schnorr<C, H> {
vec![]
}
fn process_addendum(
fn process_addendum<Re: Read>(
&mut self,
_: &FrostView<C>,
_: u16,
_: &[u8],
_: &mut Re,
) -> Result<(), FrostError> {
Ok(())
}