Skip to content

Commit

Permalink
Fix some docs. Use enable_hd=true by default. Add CI for docs
Browse files Browse the repository at this point in the history
  • Loading branch information
maurges committed Feb 22, 2024
1 parent 18ac63b commit 568acc3
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 21 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ jobs:
run: cargo clippy --all --all-features --lib --exclude cggmp21-tests -- --no-deps -D clippy::all -D clippy::unwrap_used -D clippy::expect_used
- name: Run clippy tests
run: cargo clippy --tests --all-features --lib -- -D clippy::all
check-doc:
runs-on: ubuntu-latest
steps:
- uses: dtolnay/rust-toolchain@nightly
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: "true"
- name: Check docs
run: RUSTDOCFLAGS="--cfg docsrs -D warnings" cargo +nightly doc --workspace --all-features --no-deps
bench:
runs-on: ubuntu-latest
permissions:
Expand Down
2 changes: 1 addition & 1 deletion cggmp21-keygen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ where
execution_id: eid,
tracer: None,
#[cfg(feature = "hd-wallets")]
hd_enabled: false,
hd_enabled: true,
_params: std::marker::PhantomData,
}
}
Expand Down
16 changes: 9 additions & 7 deletions cggmp21/src/signing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ where
/// Specifies HD derivation path
///
/// Note: when generating a presignature, derivation path doesn't need to be known in advance. Instead
/// of using this method, [`Presingature::set_derivation_path`] could be used to set derivation path
/// of using this method, [`Presignature::set_derivation_path`] could be used to set derivation path
/// after presignature was generated.
///
/// ## Example
Expand Down Expand Up @@ -1152,13 +1152,15 @@ where
impl<E: Curve> Presignature<E> {
/// Specifies HD derivation path
///
/// Outputs a presignature that can be used to sign a message with a child key derived from master
/// `epub` using `derivation_path`. Note that all signers need to set the same derivation path,
/// otherwise output signature will be invalid.
/// Outputs a presignature that can be used to sign a message with a child
/// key derived from master `epub` using `derivation_path`. Note that all
/// signers need to set the same derivation path, otherwise output signature
/// will be invalid.
///
/// `epub` must be an [extended public key](DirtyIncompleteKeyShare::extended_public_key) assoicated
/// with the key share that was used to generate presignature. Using wrong `epub` will simply
/// lead to invalid signature.
/// `epub` must be an [extended public
/// key](crate::key_share::DirtyIncompleteKeyShare::extended_public_key)
/// assoicated with the key share that was used to generate presignature.
/// Using wrong `epub` will simply lead to invalid signature.
#[cfg(feature = "hd-wallets")]
pub fn set_derivation_path<Index>(
mut self,
Expand Down
2 changes: 1 addition & 1 deletion cggmp21/src/trusted_dealer.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Trusted dealer
//!
//! Trusted dealer can be used to generate key shares in one place. Note
//! that in creates SPOF/T (single point of failure/trust). Trusted
//! that it creates an SPOF/T (single point of failure/trust). Trusted
//! dealer is mainly intended to be used in tests, or it can be used to
//! import key into TSS.
//!
Expand Down
16 changes: 6 additions & 10 deletions key-share/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ use serde_with::As;
/// * Signer with index $i$ (index is in range $0 \le i < n$) holds secret share $x_i = F(I_i)$
/// * Shared secret key is $\sk = F(0)$.
///
/// If key share is polynomial, [`vss_setup`](Self::vss_setup) fiels should be `Some(_)`.
/// If key share is polynomial, [`vss_setup`](DirtyKeyInfo::vss_setup) fiels should be `Some(_)`.
///
/// $I_j$ mentioned above is defined in [`VssSetup::I`]. Reasonable default would be $I_j = j+1$.
/// * Additive key share:
Expand All @@ -83,7 +83,7 @@ use serde_with::As;
///
/// # HD wallets support
/// If `hd-wallets` feature is enabled, key share provides basic support of deterministic key derivation:
/// * [`chain_code`](Self::chain_code) field is added. If it's `Some(_)`, then the key is HD-capable.
/// * [`chain_code`](DirtyKeyInfo::chain_code) field is added. If it's `Some(_)`, then the key is HD-capable.
/// `(shared_public_key, chain_code)` is extended public key of the wallet (can be retrieved via
/// [extended_public_key](DirtyCoreKeyShare::extended_public_key) method).
/// * Setting `chain_code` to `None` disables HD wallets support for the key
Expand Down Expand Up @@ -428,12 +428,10 @@ impl<T> From<ValidateError<T, InvalidCoreShare>> for InvalidCoreShare {
}

/// Reconstructs a secret key from set of at least
/// [`min_signers`](KeyShare::min_signers) key shares
/// [`min_signers`](CoreKeyShare::min_signers) key shares
///
/// Requires at least [`min_signers`](KeyShare::min_signers) distinct key shares
/// from the same generation (key refresh produces key shares of the next
/// generation). Accepts both [`KeyShare`] and [`IncompleteKeyShare`].
/// Returns error if input is invalid.
/// Requires at least [`min_signers`](CoreKeyShare::min_signers) distinct key
/// shares. Returns error if input is invalid.
///
/// Note that, normally, secret key is not supposed to be reconstructed, and key
/// shares should never be at one place. This basically defeats purpose of MPC and
Expand All @@ -442,8 +440,6 @@ impl<T> From<ValidateError<T, InvalidCoreShare>> for InvalidCoreShare {
pub fn reconstruct_secret_key<E: Curve>(
key_shares: &[impl AsRef<CoreKeyShare<E>>],
) -> Result<SecretScalar<E>, ReconstructError> {
use crate::utils::subset;

if key_shares.is_empty() {
return Err(ReconstructErrorReason::NoKeyShares.into());
}
Expand Down Expand Up @@ -472,7 +468,7 @@ pub fn reconstruct_secret_key<E: Curve>(

if let Some(VssSetup { I, .. }) = vss {
let S = key_shares.iter().map(|s| s.as_ref().i).collect::<Vec<_>>();
let I = subset(&S, I).ok_or(ReconstructErrorReason::Subset)?;
let I = crate::utils::subset(&S, I).ok_or(ReconstructErrorReason::Subset)?;
let lagrange_coefficients =
(0..).map(|j| generic_ec_zkp::polynomial::lagrange_coefficient(Scalar::zero(), j, &I));
let mut sk = lagrange_coefficients
Expand Down
4 changes: 2 additions & 2 deletions key-share/src/trusted_dealer.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Trusted dealer
//!
//! Trusted dealer can be used to generate key shares in one place. Note
//! that in creates SPOF/T (single point of failure/trust). Trusted
//! that it creates an SPOF/T (single point of failure/trust). Trusted
//! dealer is mainly intended to be used in tests.
//!
//! ## Example
Expand Down Expand Up @@ -52,7 +52,7 @@ impl<E: Curve> TrustedDealerBuilder<E> {
n,
shared_secret_key: None,
#[cfg(feature = "hd-wallets")]
enable_hd: false,
enable_hd: true,
}
}

Expand Down

0 comments on commit 568acc3

Please sign in to comment.