add docs for utils

This commit is contained in:
aaravm
2024-08-27 22:44:19 +05:30
parent 48ad59c1a9
commit 4eaf0521a4
2 changed files with 25 additions and 0 deletions

View File

@ -1,3 +1,23 @@
/// This module provides utility functions for working with MuSig2 in the context of wallets.
///
/// The `MuSigData` struct represents the data required for MuSig2 signing. It contains the nonce,
/// public key, and secret key.
///
/// The `MusigNonce` struct represents the nonce used in MuSig2 signing. It contains the secret
/// nonce, as well as flags indicating whether it has been accessed for signing or sharing.
///
/// The `generate` function in the `MusigNonce` implementation generates a new `MusigNonce` with a
/// secret nonce based on the current timestamp.
///
/// The `get_sec_for_signing` function in the `MusigNonce` implementation returns the secret nonce
/// for signing, ensuring that it has not been accessed for signing before.
///
/// The `get_pub_for_sharing` function in the `MusigNonce` implementation returns the public nonce
/// for sharing, ensuring that the nonce has not been accessed for sharing or signing before.
///
/// The `create` function in the `MuSigData` implementation creates a new `MuSigData` instance
/// based on an extended private key and a secp256k1 context. It generates a new `MusigNonce` and
/// converts the keypair to the appropriate types for MuSig2 signing.
use crate::wallet::bitcoin::key::{Parity, Secp256k1, XOnlyPublicKey};
use crate::wallet::{wallet_utils::get_seed, KeychainKind};
use anyhow::{anyhow, Error, Result};

View File

@ -1,3 +1,8 @@
/// Generates a secure seed for cryptography using the operating system's random number generator.
///
/// # Returns
///
/// An array of 32 bytes representing the generated seed.
use rand_core::{OsRng, RngCore};
// uses operating system rng which is secure for cryptography