Loading Documentation...
Getting Started Beginner 5 min read

Quick Start Guide

Get up and running with Forge EC in under 5 minutes. This tutorial will walk you through installing the library and creating your first cryptographic operations.

Prerequisites

Before getting started with Forge EC, ensure you have the following installed:

  • Rust 1.70+ - Install from rustup.rs
  • Cargo - Comes with Rust installation
  • Git - For cloning repositories (optional)
Note: Forge EC requires Rust 1.70 or later for full feature support and optimal performance.

Installation

Add Forge EC to your Rust project using Cargo:

Cargo.toml
[dependencies]
forge-ec = "0.1.0"

Or install using the command line:

Terminal
cargo add forge-ec

Your First Example

Let's create a simple example that demonstrates key generation and digital signatures:

main.rs
use forge_ec::ecdsa::*;
use forge_ec::curves::secp256k1::*;

fn main() -> Result<(), Box> {
    println!("🦀 Welcome to Forge EC!");

    // Generate a new private key
    let private_key = PrivateKey::new();
    let public_key = private_key.public_key();

    println!("✅ Generated keypair successfully");

    // Message to sign
    let message = b"Hello, Forge EC!";

    // Sign the message
    let signature = private_key.sign(message)?;
    println!("✅ Message signed");

    // Verify the signature
    let is_valid = public_key.verify(message, &signature)?;
    println!("✅ Signature verification: {}", is_valid);

    Ok(())
}

Run this example with:

Terminal
cargo run
Expected Output:
🦀 Welcome to Forge EC!
✅ Generated keypair successfully
✅ Message signed
✅ Signature verification: true

Key Generation

Forge EC provides secure key generation using cryptographically secure random number generators:

Key Generation Example
use forge_ec::ecdsa::PrivateKey;
use forge_ec::curves::secp256k1::Secp256k1;

// Generate a new random private key
let private_key = PrivateKey::::new();

// Derive the corresponding public key
let public_key = private_key.public_key();

// Export keys for storage (hex format)
let private_hex = private_key.to_hex();
let public_hex = public_key.to_hex();

println!("Private key: {}", private_hex);
println!("Public key: {}", public_hex);
Security Warning: Never share your private key or store it in plain text. Always use secure storage mechanisms in production applications.

Digital Signatures

Create digital signatures to prove authenticity and integrity of your data:

Signing Example
use forge_ec::ecdsa::*;
use forge_ec::curves::secp256k1::*;

fn sign_message(private_key: &PrivateKey, message: &[u8]) -> Result {
    // Hash the message (SHA-256 is used internally)
    let signature = private_key.sign(message)?;

    println!("Message signed successfully");
    println!("Signature: {}", signature.to_hex());

    Ok(signature)
}

// Usage
let private_key = PrivateKey::new();
let message = b"Important document content";
let signature = sign_message(&private_key, message)?;

Signature Verification

Verify digital signatures to ensure data authenticity:

Verification Example
use forge_ec::ecdsa::*;

fn verify_signature(
    public_key: &PublicKey,
    message: &[u8],
    signature: &Signature
) -> Result {
    let is_valid = public_key.verify(message, signature)?;

    if is_valid {
        println!("✅ Signature is valid - message is authentic");
    } else {
        println!("❌ Signature is invalid - message may be tampered");
    }

    Ok(is_valid)
}

// Usage
let is_authentic = verify_signature(&public_key, message, &signature)?;
assert!(is_authentic);

Next Steps

Congratulations! You've successfully created your first Forge EC application. Here's what to explore next:

Installation Guide

Learn about advanced installation options and feature flags

Read Guide →

Configuration

Customize Forge EC for your specific use case and requirements

Configure →

API Reference

Explore the complete API documentation for all modules

Browse API →

Security Guidelines

Learn best practices for secure cryptographic implementations

Learn Security →