Multisig Wallet with ECDSA Signature and Verification
This project demonstrates how to generate, sign, and verify messages using the secp256k1 elliptic curve digital signature algorithm (ECDSA) in Rust. It also includes a basic structure for a multisig wallet with support for multiple signatures, built using secp256k1 and SHA-256.
Features
- ECDSA Signing: Sign a message using a secret key (private key).
- ECDSA Verification: Verify the authenticity of a signed message using a corresponding public key.
- Multisig Wallet: A basic structure for managing multiple signers and tracking signature states.
Dependencies
This project relies on the following Rust crates:
secp256k1: Provides the ECDSA signing and verification functionality.sha2: Used for hashing the message using SHA-256.rand: Provides random number generation for creating secure secret keys.
Add the following dependencies to your Cargo.toml:
[]
= "0.21"
= "0.9"
= "0.8"
Installation
Usage
Signing and Verifying Messages The main functionality of this project is centered around signing and verifying messages. Below is a basic example of how to use this functionality in the main function.
use ;
use OsRng;
Functions
-
sign_message(message: &[u8], secret_key: &SecretKey) -> Signature: This function takes a message and a secret key, hashes the message using SHA-256, and signs it using the ECDSA algorithm.
-
verify_signature(message: &[u8], signature: &Signature, pubkey: &PublicKey) -> bool: This function verifies if a signature is valid for the given message and public key by hashing the message and performing ECDSA verification.