1#![no_std]
2#![cfg_attr(docsrs, feature(doc_cfg))]
3#![doc(
4 html_logo_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg",
5 html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg"
6)]
7#![forbid(unsafe_code)]
8#![warn(missing_docs, rust_2018_idioms, unused_qualifications)]
9#![doc = include_str!("../README.md")]
10
11#[cfg(feature = "ecdh")]
51pub mod ecdh;
52#[cfg(feature = "ecdsa-core")]
53pub mod ecdsa;
54#[cfg(any(feature = "test-vectors", test))]
55pub mod test_vectors;
56
57#[cfg(feature = "arithmetic")]
58mod arithmetic;
59
60pub use elliptic_curve::{
61 self,
62 bigint::{Odd, U384},
63 consts::U48,
64};
65
66#[cfg(feature = "arithmetic")]
67pub use arithmetic::{AffinePoint, ProjectivePoint, scalar::Scalar};
68#[cfg(feature = "pkcs8")]
69pub use elliptic_curve::pkcs8;
70#[cfg(feature = "hash2curve")]
71pub use hash2curve;
72
73use elliptic_curve::{array::Array, consts::U49};
74
75const ORDER_HEX: &str = "ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973";
77
78#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, PartialOrd, Ord)]
80pub struct NistP384;
81
82impl elliptic_curve::Curve for NistP384 {
83 type FieldBytesSize = U48;
85
86 type Uint = U384;
88
89 const ORDER: Odd<U384> = Odd::<U384>::from_be_hex(ORDER_HEX);
91}
92
93impl elliptic_curve::PrimeCurve for NistP384 {}
94
95impl elliptic_curve::point::PointCompression for NistP384 {
96 const COMPRESS_POINTS: bool = false;
98}
99
100impl elliptic_curve::point::PointCompaction for NistP384 {
101 const COMPACT_POINTS: bool = false;
103}
104
105#[cfg(feature = "pkcs8")]
106impl pkcs8::AssociatedOid for NistP384 {
107 const OID: pkcs8::ObjectIdentifier = pkcs8::ObjectIdentifier::new_unwrap("1.3.132.0.34");
108}
109
110pub type CompressedPoint = Array<u8, U49>;
112
113pub type Sec1Point = elliptic_curve::sec1::Sec1Point<NistP384>;
115
116pub type FieldBytes = elliptic_curve::FieldBytes<NistP384>;
121
122#[cfg(feature = "arithmetic")]
124pub type NonZeroScalar = elliptic_curve::NonZeroScalar<NistP384>;
125
126#[cfg(feature = "arithmetic")]
128pub type PublicKey = elliptic_curve::PublicKey<NistP384>;
129
130pub type SecretKey = elliptic_curve::SecretKey<NistP384>;
132
133#[cfg(not(feature = "arithmetic"))]
134impl elliptic_curve::sec1::ValidatePublicKey for NistP384 {}
135
136#[cfg(feature = "oprf")]
137impl hash2curve::OprfParameters for NistP384 {
138 const ID: &'static [u8] = b"P384-SHA384";
140}