Expand and correct documentation

This commit is contained in:
Luke Parker
2022-09-29 05:25:29 -04:00
parent 19cd609cba
commit ca091a5f04
18 changed files with 137 additions and 118 deletions

View File

@@ -51,15 +51,15 @@ pub(crate) fn validate_map<T>(
Ok(())
}
/// Parameters for a multisig
/// Parameters for a multisig.
// These fields can not be made public as they should be static
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub struct FrostParams {
/// Participants needed to sign on behalf of the group
/// Participants needed to sign on behalf of the group.
t: u16,
/// Amount of participants
/// Amount of participants.
n: u16,
/// Index of the participant being acted for
/// Index of the participant being acted for.
i: u16,
}
@@ -122,7 +122,7 @@ pub enum FrostError {
InternalError(&'static str),
}
/// Calculate the lagrange coefficient for a signing set
/// Calculate the lagrange coefficient for a signing set.
pub fn lagrange<F: PrimeField>(i: u16, included: &[u16]) -> F {
let mut num = F::one();
let mut denom = F::one();
@@ -141,18 +141,18 @@ pub fn lagrange<F: PrimeField>(i: u16, included: &[u16]) -> F {
num * denom.invert().unwrap()
}
/// Core keys generated by performing a FROST keygen protocol
/// Core keys generated by performing a FROST keygen protocol.
#[derive(Clone, PartialEq, Eq, Zeroize)]
pub struct FrostCore<C: Curve> {
/// FROST Parameters
/// FROST Parameters.
#[zeroize(skip)]
params: FrostParams,
/// Secret share key
/// Secret share key.
secret_share: C::F,
/// Group key
/// Group key.
group_key: C::G,
/// Verification shares
/// Verification shares.
#[zeroize(skip)]
verification_shares: HashMap<u16, C::G>,
}
@@ -273,14 +273,14 @@ impl<C: Curve> FrostCore<C> {
}
}
/// FROST keys usable for signing
/// FROST keys usable for signing.
#[derive(Clone, Debug, Zeroize)]
pub struct FrostKeys<C: Curve> {
/// Core keys
/// Core keys.
#[zeroize(skip)]
core: Arc<FrostCore<C>>,
/// Offset applied to these keys
/// Offset applied to these keys.
pub(crate) offset: Option<C::F>,
}
@@ -315,10 +315,10 @@ impl<C: Curve> FrostKeys<C> {
FrostKeys { core: Arc::new(core), offset: None }
}
/// Offset the keys by a given scalar to allow for account and privacy schemes
/// This offset is ephemeral and will not be included when these keys are serialized
/// Keys offset multiple times will form a new offset of their sum
/// Not IETF compliant
/// Offset the keys by a given scalar to allow for account and privacy schemes.
/// This offset is ephemeral and will not be included when these keys are serialized.
/// Keys offset multiple times will form a new offset of their sum.
/// Not IETF compliant.
pub fn offset(&self, offset: C::F) -> FrostKeys<C> {
let mut res = self.clone();
// Carry any existing offset
@@ -336,12 +336,12 @@ impl<C: Curve> FrostKeys<C> {
self.core.secret_share
}
/// Returns the group key with any offset applied
/// Returns the group key with any offset applied.
pub fn group_key(&self) -> C::G {
self.core.group_key + (C::generator() * self.offset.unwrap_or_else(C::F::zero))
}
/// Returns all participants' verification shares without any offsetting
/// Returns all participants' verification shares without any offsetting.
pub(crate) fn verification_shares(&self) -> HashMap<u16, C::G> {
self.core.verification_shares()
}