1#![no_std]
2#![cfg_attr(docsrs, feature(doc_auto_cfg))]
3#![doc = include_str!("../README.md")]
4#![doc(
5    html_logo_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg",
6    html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg"
7)]
8#![forbid(unsafe_code)]
9#![warn(
10    clippy::mod_module_files,
11    clippy::unwrap_used,
12    missing_docs,
13    rust_2018_idioms,
14    unused_lifetimes,
15    unused_qualifications
16)]
17
18#[cfg(feature = "arithmetic")]
29mod arithmetic;
30
31#[cfg(feature = "ecdh")]
32pub mod ecdh;
33
34#[cfg(feature = "ecdsa-core")]
35pub mod ecdsa;
36
37#[cfg(any(feature = "test-vectors", test))]
38pub mod test_vectors;
39
40#[cfg(feature = "arithmetic")]
41pub use arithmetic::{scalar::Scalar, AffinePoint, ProjectivePoint};
42
43pub use elliptic_curve::{self, bigint::U576};
44
45#[cfg(feature = "pkcs8")]
46pub use elliptic_curve::pkcs8;
47
48use elliptic_curve::{consts::U66, generic_array::GenericArray, FieldBytesEncoding};
49
50#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, PartialOrd, Ord)]
52pub struct NistP521;
53
54impl elliptic_curve::Curve for NistP521 {
55    type FieldBytesSize = U66;
57
58    type Uint = U576;
60
61    const ORDER: U576 = U576::from_be_hex("00000000000001fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409");
63}
64
65impl elliptic_curve::PrimeCurve for NistP521 {}
66
67impl elliptic_curve::point::PointCompression for NistP521 {
68    const COMPRESS_POINTS: bool = false;
70}
71
72impl elliptic_curve::point::PointCompaction for NistP521 {
73    const COMPACT_POINTS: bool = false;
75}
76
77#[cfg(feature = "jwk")]
78impl elliptic_curve::JwkParameters for NistP521 {
79    const CRV: &'static str = "P-521";
80}
81
82#[cfg(feature = "pkcs8")]
83impl pkcs8::AssociatedOid for NistP521 {
84    const OID: pkcs8::ObjectIdentifier = pkcs8::ObjectIdentifier::new_unwrap("1.3.132.0.35");
85}
86
87pub type CompressedPoint = GenericArray<u8, U66>;
89
90pub type EncodedPoint = elliptic_curve::sec1::EncodedPoint<NistP521>;
92
93pub type FieldBytes = elliptic_curve::FieldBytes<NistP521>;
98
99impl FieldBytesEncoding<NistP521> for U576 {}
100
101#[cfg(feature = "arithmetic")]
103pub type NonZeroScalar = elliptic_curve::NonZeroScalar<NistP521>;
104
105#[cfg(feature = "arithmetic")]
107pub type PublicKey = elliptic_curve::PublicKey<NistP521>;
108
109pub type SecretKey = elliptic_curve::SecretKey<NistP521>;
111
112#[cfg(feature = "voprf")]
113impl elliptic_curve::VoprfParameters for NistP521 {
114    const ID: &'static str = "P521-SHA512";
116
117    type Hash = sha2::Sha512;
119}