Skip to content

Tranduy1dol/curve1024

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

100 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Curve1024

Rust License: MIT

Introduce

Curve1024 is a complete, from-scratch 1024-bit Elliptic Curve Cryptography (ECC) library written purely in Rust. Designed with cryptographic sovereignty and memory safety at its core, Curve1024 relies on zero external cryptographic dependencies.

By utilizing a monstrous 1024-bit base field ($p \approx 2^{1024}$) and a 512-bit scalar field ($r \approx 2^{512}$), this library provides an absolute 256-bit symmetric security margin. It is specifically targeted at high-security, long-term, and offline signing environments where extreme attack resistance is prioritized.

Key Features

The Library

  • Pure-Rust 1024-bit BigNum Arithmetic (U1024): Custom, memory-safe large integer operations over 1024-bit fields, circumventing vulnerabilities inherent in legacy C/C++ implementations.
  • 1024-bit Elliptic Curve: Pre-computed curve parameters with CM discriminant D=−3, embedding degree k=18, and a 512-bit scalar field providing 256-bit symmetric security.
  • Optimized Field Arithmetic: Heavily utilizes Montgomery multiplication to bypass expensive large-integer divisions, ensuring a viable performance-to-security trade-off.
  • Complex Multiplication (CM): Constructs the curve equation and generator point from CM parameters using Hilbert class polynomials, sextic twist enumeration, and cofactor clearing.
  • Cross-validated with BLS12-381: Library correctness is independently verified against the well-known zkcrypto/bls12_381 test vectors.
  • Robust Attack Resistance:
    • Pollard's rho: Requires $O(2^{256})$ operations.
    • MOV Attack: The extension field $\mathbb{F}_{p^{18}}$ is a massive 18,432 bits, making index-calculus DLP infeasible.
    • Anomalous (SSSA): Curve cardinality is rigorously checked ($#E(\mathbb{F}_p) \neq p$).

The CLI Tool (curve1024-sig)

  • GPG-like Interface: An intuitive command-line interface for managing keys and signing/verifying files.
  • Multiple Signature Schemes: Offers drop-in support for both Schnorr and ECDSA digital signature algorithms out of the box.
  • File Signatures: Directly signs files, appending the signature securely to the file with a specific magic footer identifying the schema.

Usage

As a Library

Add curve1024 to your Cargo.toml dependencies.

use curve1024::{
    AffinePoint, Curve1024BaseField, Curve1024Config, EcdsaSignature, KeyPair, 
    PrimeFieldElement, SchnorrSignature, U1024,
};

fn main() {
    // 1. Generate a new 1024-bit keypair
    let keypair = KeyPair::<Curve1024Config>::generate();
    let message = b"Confidential system payload";

    // 2. Sign using Schnorr
    let schnorr_sig = SchnorrSignature::<Curve1024Config>::sign(&keypair.private_key, message);
    let schnorr_valid = schnorr_sig.verify(&keypair.public_key, message);
    assert!(schnorr_valid);

    // 3. Or sign using ECDSA
    let ecdsa_sig = EcdsaSignature::sign::<Curve1024Config>(&keypair.private_key, message);
    let ecdsa_valid = ecdsa_sig.verify::<Curve1024Config>(&keypair.public_key, message);
    assert!(ecdsa_valid);
}

The CLI Tool (curve1024-sig)

You can install the CLI tool directly from the repository using cargo install.

cargo install --git https://github.com/Tranduy1dol/curve1024.git curve1024-sig

Alternatively, you can build it from source:

git clone https://github.com/Tranduy1dol/curve1024.git
cd curve1024
cargo build --release

CLI Commands Overview:

A GPG-like tool for elliptic curve key management and digital signatures

Usage: curve1024-sig <COMMAND>

Commands:
  keygen      
  sign        
  verify      
  export-pub  
  help        Print this message or the help of the given subcommand(s)

Options:
  -h, --help  Print help

🔒 Security Disclaimer

Warning & Academic Transparency: While this library achieves high mathematical correctness and effectively neutralizes standard algorithmic attacks, the scalar multiplication algorithm currently leverages a Double-and-Add approach. Thus, it may be vulnerable to timing side-channel attacks. Curve1024 is currently best suited for academic demonstrations, secure protocol designs, and offline signing operations.

📜 License

This project is open-source and strictly licensed under the MIT License.

About

A complete, from-scratch 1024-bit Elliptic Curve Cryptography (ECC) library written purely in Rust.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages