curve25519_dalek/
lib.rs

1// -*- mode: rust; -*-
2//
3// This file is part of curve25519-dalek.
4// Copyright (c) 2016-2021 isis lovecruft
5// Copyright (c) 2016-2019 Henry de Valence
6// See LICENSE for licensing information.
7//
8// Authors:
9// - isis agora lovecruft <isis@patternsinthevoid.net>
10// - Henry de Valence <hdevalence@hdevalence.ca>
11
12#![no_std]
13#![cfg_attr(
14    all(
15        curve25519_dalek_backend = "simd",
16        nightly,
17        any(target_arch = "x86", target_arch = "x86_64")
18    ),
19    feature(stdarch_x86_avx512)
20)]
21#![cfg_attr(
22    all(curve25519_dalek_backend = "simd", nightly),
23    feature(avx512_target_feature)
24)]
25#![cfg_attr(docsrs, feature(doc_auto_cfg, doc_cfg, doc_cfg_hide))]
26#![cfg_attr(docsrs, doc(cfg_hide(docsrs)))]
27//------------------------------------------------------------------------
28// Documentation:
29//------------------------------------------------------------------------
30#![doc(
31    html_logo_url = "https://cdn.jsdelivr.net/gh/dalek-cryptography/curve25519-dalek/docs/assets/dalek-logo-clear.png"
32)]
33#![doc = include_str!("../README.md")]
34//------------------------------------------------------------------------
35// Linting:
36//------------------------------------------------------------------------
37#![cfg_attr(allow_unused_unsafe, allow(unused_unsafe))]
38#![warn(
39    clippy::unwrap_used,
40    missing_docs,
41    rust_2018_idioms,
42    unused_lifetimes,
43    unused_qualifications
44)]
45// Requires MSRV 1.77 as it does not allow build.rs gating
46#![allow(unexpected_cfgs)]
47
48//------------------------------------------------------------------------
49// External dependencies:
50//------------------------------------------------------------------------
51
52#[cfg(feature = "alloc")]
53#[allow(unused_imports)]
54#[macro_use]
55extern crate alloc;
56
57// TODO: move std-dependent tests to `tests/`
58#[cfg(test)]
59#[macro_use]
60extern crate std;
61
62#[cfg(feature = "digest")]
63pub use digest;
64
65// Internal macros. Must come first!
66#[macro_use]
67pub(crate) mod macros;
68
69//------------------------------------------------------------------------
70// curve25519-dalek public modules
71//------------------------------------------------------------------------
72
73// Scalar arithmetic mod l = 2^252 + ..., the order of the Ristretto group
74pub mod scalar;
75
76// Point operations on the Montgomery form of Curve25519
77pub mod montgomery;
78
79// Point operations on the Edwards form of Curve25519
80pub mod edwards;
81
82// Group operations on the Ristretto group
83pub mod ristretto;
84
85// Useful constants, like the Ed25519 basepoint
86pub mod constants;
87
88// External (and internal) traits.
89pub mod traits;
90
91//------------------------------------------------------------------------
92// curve25519-dalek internal modules
93//------------------------------------------------------------------------
94
95// Finite field arithmetic mod p = 2^255 - 19
96pub(crate) mod field;
97
98// Arithmetic backends (using u32, u64, etc) live here
99#[cfg(docsrs)]
100pub mod backend;
101#[cfg(not(docsrs))]
102pub(crate) mod backend;
103
104// Generic code for window lookups
105pub(crate) mod window;
106
107pub use crate::{
108    edwards::EdwardsPoint, montgomery::MontgomeryPoint, ristretto::RistrettoPoint, scalar::Scalar,
109};
110
111// Build time diagnostics for validation
112#[cfg(curve25519_dalek_diagnostics = "build")]
113mod diagnostics;