Skip to content

Xuan0ling/simple_schnorr_signature

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Schnorr Signature

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.

Features

  • Key generation (private and public keys)
  • Message signing
  • Signature verification

Prerequisites

  • Rust (v1.65 or higher recommended)

Dependencies

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.

Installation

  1. Clone the repository:

    git clone https://github.com/your-username/schnorr_signature.git
    cd schnorr_signature
  2. Ensure you have Rust installed. If not, install it using rustup:

    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  3. Build the project:

    cargo build
  4. Run the example:

    cargo run

Usage

The main components of the implementation include:

Key Generation

Generate a private and public key pair:

let (private_key, public_key) = keygen();

Signing

Sign a message with the private key:

let message = b"Hello, Schnorr!";
let signature = sign(message, private_key);

Verification

Verify the signature using the public key:

let is_valid = verify(message, &signature, public_key);
println!("Signature valid: {}", is_valid);

Example Output

When you run the program, it will:

  1. Generate a key pair (private and public keys).
  2. Sign the message "Hello, Schnorr!".
  3. Verify the signature and display whether it is valid.

Expected output:

Signature valid: true

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgments

  • curve25519-dalek for the Ristretto implementation.
  • Rust for being an amazing systems programming language.

About

very simple_schnorr_signature

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published