[−][src]Function grin_core::libtx::aggsig::verify_partial_sig
pub fn verify_partial_sig(
secp: &Secp256k1,
sig: &Signature,
pub_nonce_sum: &PublicKey,
pubkey: &PublicKey,
pubkey_sum: Option<&PublicKey>,
msg: &Message
) -> Result<(), Error>
Verifies a partial signature from a public key. All nonce and public
key sum values must be identical to those provided in the call to
calculate_partial_sig
. Returns
Result::Ok
if the signature is valid, or a Signature
ErrorKind otherwise
Arguments
secp
- A Secp256k1 Context initialized for Validationsig
- The signature to validate, created via a call tocalculate_partial_sig
pub_nonce_sum
- The sum of the public nonces of all signers participating in the full signature. This value is encoded in e.pubkey
- Corresponding Public Key of the private key used to sign the message.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 verify.
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::Full); 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(); // Now verify the signature, ensuring the same values used to create // the signature are provided: let public_key = PublicKey::from_secret_key(&secp, &secret_key).unwrap(); let result = aggsig::verify_partial_sig( &secp, &sig_part, &pub_nonce_sum, &public_key, Some(&pub_key_sum), &message, );