Trait subcoin_script::SignatureChecker

source ·
pub trait SignatureChecker {
    // Required methods
    fn check_ecdsa_signature(
        &mut self,
        sig: &EcdsaSignature,
        pk: &PublicKey,
        script_code: &Script,
        sig_version: SigVersion,
    ) -> Result<bool, SignatureError>;
    fn check_schnorr_signature(
        &mut self,
        sig: &SchnorrSignature,
        pk: &XOnlyPublicKey,
        sig_version: SigVersion,
        exec_data: &ScriptExecutionData,
    ) -> Result<bool, SignatureError>;
    fn check_lock_time(&self, lock_time: ScriptNum) -> bool;
    fn check_sequence(&self, sequence: ScriptNum) -> bool;

    // Provided methods
    fn verify_ecdsa_signature(
        &self,
        sig: &EcdsaSignature,
        msg: &Message,
        pk: &PublicKey,
    ) -> bool { ... }
    fn verify_schnorr_signature(
        &self,
        sig: &SchnorrSignature,
        msg: &Message,
        pk: &XOnlyPublicKey,
    ) -> bool { ... }
}
Expand description

Trait for verifying Bitcoin transaction signatures.

Required Methods§

source

fn check_ecdsa_signature( &mut self, sig: &EcdsaSignature, pk: &PublicKey, script_code: &Script, sig_version: SigVersion, ) -> Result<bool, SignatureError>

Checks an ECDSA signature in the context of a Bitcoin transaction.

§Arguments
  • sig - The ECDSA signature to check.
  • pk - The public key corresponding to the signature.
  • script_code - The script code for the transaction input.
  • sig_version - The signature version (e.g., SigVersion::Base or SigVersion::WitnessV0).
§Returns
  • Ok(true) if the signature is valid.
  • Ok(false) if the signature is invalid.
  • Err(SignatureError) if an error occurs.
§Notes

In the context of multisignature transactions, it is expected that not all signatures may be valid. An invalid signature may be considered legitimate as long as the multisig conditions are met.

source

fn check_schnorr_signature( &mut self, sig: &SchnorrSignature, pk: &XOnlyPublicKey, sig_version: SigVersion, exec_data: &ScriptExecutionData, ) -> Result<bool, SignatureError>

Checks a Schnorr signature in the context of a Bitcoin transaction.

§Arguments
  • sig - The Schnorr signature to check.
  • pk - The public key corresponding to the signature.
  • sig_version - The signature version (e.g., SigVersion::Taproot).
  • exec_data - Additional execution data for Taproot scripts.
§Returns
  • Ok(true) if the signature is valid.
  • Ok(false) if the signature is invalid.
  • Err(SignatureError) if an error occurs.
source

fn check_lock_time(&self, lock_time: ScriptNum) -> bool

Checks whether the absolute time lock (lock_time) in a transaction is satisfied.

source

fn check_sequence(&self, sequence: ScriptNum) -> bool

Checks whether the relative time lock (sequence) for a specific input in a transaction is satisfied.

Provided Methods§

source

fn verify_ecdsa_signature( &self, sig: &EcdsaSignature, msg: &Message, pk: &PublicKey, ) -> bool

Verifies an ECDSA signature against a message and public key.

§Arguments
  • sig - The ECDSA signature to verify.
  • msg - The message that was signed.
  • pk - The public key corresponding to the signature.
§Returns
  • true if the signature is valid.
  • false if the signature is invalid or an error occurs.
source

fn verify_schnorr_signature( &self, sig: &SchnorrSignature, msg: &Message, pk: &XOnlyPublicKey, ) -> bool

Verifies a Schnorr signature against a message and public key.

§Arguments
  • sig - The Schnorr signature to verify.
  • msg - The message that was signed.
  • pk - The public key corresponding to the signature.
§Returns
  • true if the signature is valid.
  • false if the signature is invalid or an error occurs.

Implementors§