This project demonstrates a Schnorr signature scheme implementation using the Rust programming language. Schnorr signatures provide a simple, efficient, and secure way to sign messages using elliptic curve cryptography.
- Key generation (private and public keys)
- Message signing
- Signature verification
- Rust (v1.65 or higher recommended)
This project uses the following Rust crates:
curve25519-dalek: Provides elliptic curve operations on the Ristretto group.rand: Used for generating cryptographically secure random numbers.sha2: Provides the SHA-512 hashing algorithm.
-
Clone the repository:
git clone https://github.com/your-username/schnorr_signature.git cd schnorr_signature -
Ensure you have Rust installed. If not, install it using rustup:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
-
Build the project:
cargo build
-
Run the example:
cargo run
The main components of the implementation include:
Generate a private and public key pair:
let (private_key, public_key) = keygen();Sign a message with the private key:
let message = b"Hello, Schnorr!";
let signature = sign(message, private_key);Verify the signature using the public key:
let is_valid = verify(message, &signature, public_key);
println!("Signature valid: {}", is_valid);When you run the program, it will:
- Generate a key pair (private and public keys).
- Sign the message
"Hello, Schnorr!". - Verify the signature and display whether it is valid.
Expected output:
Signature valid: true
This project is licensed under the MIT License. See the LICENSE file for details.
- curve25519-dalek for the Ristretto implementation.
- Rust for being an amazing systems programming language.