[−][src]Function grin_core::libtx::aggsig::calculate_partial_sig
pub fn calculate_partial_sig(
secp: &Secp256k1,
sec_key: &SecretKey,
sec_nonce: &SecretKey,
nonce_sum: &PublicKey,
pubkey_sum: Option<&PublicKey>,
msg: &Message
) -> Result<Signature, Error>
Calculates a partial signature given the signer's secure key, the sum of all public nonces and (optionally) the sum of all public keys.
Arguments
secp
- A Secp256k1 Context initialized for Signingsec_key
- The signer's secret keysec_nonce
- The signer's secret nonce (the public version of which was added to thenonce_sum
total)nonce_sum
- The sum of the public nonces of all signers participating in the full signature. This value is encoded in e.pubkey_sum
- (Optional) The sum of the public keys of all signers participating in the full signature. If included, this value is encoded in e.msg
- The message to sign.
Example
use rand::thread_rng; use core::libtx::aggsig; use util::secp::key::{PublicKey, SecretKey}; use util::secp::{ContextFlag, Secp256k1, Message}; let secp = Secp256k1::with_caps(ContextFlag::SignOnly); let secret_nonce = aggsig::create_secnonce(&secp).unwrap(); let secret_key = SecretKey::new(&secp, &mut thread_rng()); let pub_nonce_sum = PublicKey::from_secret_key(&secp, &secret_nonce).unwrap(); // ... Add all other participating nonces let pub_key_sum = PublicKey::from_secret_key(&secp, &secret_key).unwrap(); // ... Add all other participating keys let mut msg_bytes = [0; 32]; // ... Encode message let message = Message::from_slice(&msg_bytes).unwrap(); let sig_part = aggsig::calculate_partial_sig( &secp, &secret_key, &secret_nonce, &pub_nonce_sum, Some(&pub_key_sum), &message, ).unwrap();