2026-03-13 21:49:11 +00:00
|
|
|
// -*- mode: rust; -*-
|
|
|
|
|
//
|
|
|
|
|
// This file is part of curve25519.
|
|
|
|
|
// Copyright (c) 2016-2021 isis lovecruft
|
|
|
|
|
// Copyright (c) 2016-2019 Henry de Valence
|
|
|
|
|
// See LICENSE for licensing information.
|
|
|
|
|
//
|
|
|
|
|
// Authors:
|
|
|
|
|
// - isis agora lovecruft <isis@patternsinthevoid.net>
|
|
|
|
|
// - Henry de Valence <hdevalence@hdevalence.ca>
|
2026-03-07 20:52:28 +00:00
|
|
|
|
2026-03-13 21:49:11 +00:00
|
|
|
#![no_std]
|
|
|
|
|
#![cfg_attr(docsrs, feature(doc_cfg))]
|
|
|
|
|
#![cfg_attr(docsrs, doc(auto_cfg(hide(docsrs))))]
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
// Documentation:
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
#![doc(
|
|
|
|
|
html_logo_url = "https://cdn.jsdelivr.net/gh/dalek-cryptography/curve25519/docs/assets/dalek-logo-clear.png"
|
|
|
|
|
)]
|
|
|
|
|
#![doc = include_str!("../README.md")]
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
// Linting:
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
#![cfg_attr(allow_unused_unsafe, allow(unused_unsafe))]
|
|
|
|
|
#![warn(
|
|
|
|
|
clippy::mod_module_files,
|
|
|
|
|
clippy::unwrap_used,
|
|
|
|
|
missing_docs,
|
|
|
|
|
rust_2018_idioms,
|
|
|
|
|
unused_lifetimes,
|
|
|
|
|
unused_qualifications
|
|
|
|
|
)]
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
// External dependencies:
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "alloc")]
|
|
|
|
|
#[allow(unused_imports)]
|
|
|
|
|
#[macro_use]
|
|
|
|
|
extern crate alloc;
|
|
|
|
|
|
|
|
|
|
// TODO: move std-dependent tests to `tests/`
|
2026-05-19 01:50:26 +00:00
|
|
|
#[cfg(any(test, feature = "std"))]
|
2026-03-13 21:49:11 +00:00
|
|
|
#[macro_use]
|
|
|
|
|
extern crate std;
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "digest")]
|
|
|
|
|
pub use digest;
|
|
|
|
|
|
|
|
|
|
// Internal macros. Must come first!
|
|
|
|
|
#[macro_use]
|
|
|
|
|
pub(crate) mod macros;
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
// curve25519 public modules
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
// Scalar arithmetic mod l = 2^252 + ..., the order of the Ristretto group
|
|
|
|
|
pub mod scalar;
|
|
|
|
|
|
|
|
|
|
// Point operations on the Montgomery form of Curve25519
|
|
|
|
|
pub mod montgomery;
|
|
|
|
|
|
|
|
|
|
// Point operations on the Edwards form of Curve25519
|
|
|
|
|
pub mod edwards;
|
|
|
|
|
|
|
|
|
|
// Point operations on the short Weierstrass form of Curve25519
|
|
|
|
|
pub mod short_weierstrass;
|
|
|
|
|
|
|
|
|
|
// Group operations on the Ristretto group
|
|
|
|
|
pub mod ristretto;
|
|
|
|
|
|
|
|
|
|
// Useful constants, like the Ed25519 basepoint
|
|
|
|
|
pub mod constants;
|
|
|
|
|
|
|
|
|
|
// External (and internal) traits.
|
|
|
|
|
pub mod traits;
|
|
|
|
|
|
2026-03-26 12:09:10 +00:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
// ed25519 public modules
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
pub mod ed_sigs;
|
|
|
|
|
|
2026-03-13 21:49:11 +00:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
// curve25519 internal modules
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
// Finite field arithmetic mod p = 2^255 - 19
|
|
|
|
|
pub(crate) mod field;
|
|
|
|
|
|
|
|
|
|
// Arithmetic backends (using u32, u64, etc) live here
|
|
|
|
|
#[cfg(docsrs)]
|
|
|
|
|
pub mod backend;
|
|
|
|
|
#[cfg(not(docsrs))]
|
|
|
|
|
pub(crate) mod backend;
|
|
|
|
|
|
|
|
|
|
// Generic code for window lookups
|
|
|
|
|
pub(crate) mod window;
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "lizard")]
|
|
|
|
|
mod lizard;
|
|
|
|
|
|
|
|
|
|
pub use crate::{
|
|
|
|
|
edwards::EdwardsPoint, montgomery::MontgomeryPoint, ristretto::RistrettoPoint, scalar::Scalar,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Build time diagnostics for validation
|
|
|
|
|
#[cfg(curve25519_diagnostics = "build")]
|
|
|
|
|
mod diagnostics;
|