| Crates.io | curve420 |
| lib.rs | curve420 |
| version | 0.1.1 |
| created_at | 2025-09-07 16:24:35.383885+00 |
| updated_at | 2025-09-07 16:32:50.937155+00 |
| description | Implementation of the Curve420 elliptic curve in Rust |
| homepage | |
| repository | https://github.com/mikalv/curve420 |
| max_upload_size | |
| id | 1828294 |
| size | 45,907 |
A minimal, self-contained Rust implementation of Curve420 with both Montgomery (u-only, X25519-style ECDH) and Twisted Edwards (signatures) models, matching the frozen specification in SPEC.md and constants in curve420.json.
field: prime field arithmetic over p = 2^420 − 335 (53-byte little-endian).montgomery: Montgomery form for ECDH; base u and parameter A match curve420.json.curve (Edwards): Twisted Edwards with a = A + 2, d = A − 2; base point (x, y) matches curve420.json.schnorr: Deterministic Schnorr and blind/partially-blind Schnorr over the Edwards form (prime-order subgroup ℓ; cofactor h = 8).curve420.json / curve420.yaml and restated in SPEC.md.EDW_A = A + 2EDW_D = A − 2cargo testcargo run --example diffie_hellmancargo run --example schnorr_signaturecargo run --example blind_signature, cargo run --example partially_blind_signaturex = u / v, y = (u − 1) / (u + 1)u = (1 + y) / (1 − y), v = u / xproved/ at the repo root:
proved/vectors.json → montgomery_u_only, dh_checksproved/vectors.json → edwards_schnorr, edwards_blind_schnorrd' = (2 − A)/(A + 2) is non-square in Fp → complete Edwards addition (a = −1 view used for proofs).proved/invalid_corpus.json.SAGE/ at the repo root.make prove-security-strong, make vectors, make security-notesApache-2.0
use curve420::{montgomery::{G_MONT, montgomery_ladder}, schnorr};
use num_bigint::BigUint;
fn main() {
// ECDH (Montgomery u-only)
let alice_sk = BigUint::from(123u32);
let bob_sk = BigUint::from(456u32);
let alice_pk = montgomery_ladder(&G_MONT, &alice_sk);
let bob_pk = montgomery_ladder(&G_MONT, &bob_sk);
let alice_shared = montgomery_ladder(&bob_pk, &alice_sk);
let bob_shared = montgomery_ladder(&alice_pk, &bob_sk);
assert_eq!(alice_shared, bob_shared);
// Schnorr (Edwards)
let (sk, pk) = schnorr::keygen();
let msg = b"hello curve420";
let sig = schnorr::sign(&sk, &pk, msg);
assert!(schnorr::verify(&pk, msg, &sig));
}