#![no_std]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![doc = include_str!("../README.md")]
#![doc(
html_logo_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg",
html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg"
)]
#![forbid(unsafe_code)]
#![warn(
clippy::mod_module_files,
clippy::cast_lossless,
clippy::cast_possible_truncation,
clippy::cast_possible_wrap,
clippy::cast_precision_loss,
clippy::cast_sign_loss,
clippy::checked_conversions,
clippy::implicit_saturating_sub,
clippy::arithmetic_side_effects,
clippy::panic,
clippy::panic_in_result_fn,
clippy::unwrap_used,
missing_docs,
rust_2018_idioms,
unused_lifetimes,
unused_qualifications
)]
#[cfg(feature = "alloc")]
#[allow(unused_extern_crates)]
extern crate alloc;
#[cfg(feature = "arithmetic")]
pub mod arithmetic;
#[cfg(any(feature = "test-vectors", test))]
pub mod test_vectors;
#[cfg(feature = "dsa")]
pub mod dsa;
pub use elliptic_curve::{self, bigint::U256};
#[cfg(feature = "arithmetic")]
pub use arithmetic::{scalar::Scalar, AffinePoint, ProjectivePoint};
#[cfg(feature = "pkcs8")]
pub use elliptic_curve::pkcs8;
use elliptic_curve::{
bigint::ArrayEncoding,
consts::{U32, U33},
generic_array::GenericArray,
FieldBytesEncoding,
};
#[cfg(feature = "dsa")]
type Hash = belt_hash::digest::Output<belt_hash::BeltHash>;
const ORDER_HEX: &str = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD95C8ED60DFB4DFC7E5ABF99263D6607";
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, PartialOrd, Ord)]
pub struct BignP256;
impl elliptic_curve::Curve for BignP256 {
type FieldBytesSize = U32;
type Uint = U256;
const ORDER: U256 = U256::from_be_hex(ORDER_HEX);
}
impl elliptic_curve::PrimeCurve for BignP256 {}
impl elliptic_curve::point::PointCompression for BignP256 {
const COMPRESS_POINTS: bool = false;
}
impl elliptic_curve::point::PointCompaction for BignP256 {
const COMPACT_POINTS: bool = false;
}
#[cfg(feature = "pkcs8")]
impl pkcs8::AssociatedOid for BignP256 {
const OID: pkcs8::ObjectIdentifier =
pkcs8::ObjectIdentifier::new_unwrap("1.2.112.0.2.0.34.101.45.1");
}
pub type CompressedPoint = GenericArray<u8, U33>;
pub type FieldBytes = elliptic_curve::FieldBytes<BignP256>;
pub type EncodedPoint = elliptic_curve::sec1::EncodedPoint<BignP256>;
impl FieldBytesEncoding<BignP256> for U256 {
fn decode_field_bytes(field_bytes: &FieldBytes) -> Self {
U256::from_be_byte_array(*field_bytes)
}
fn encode_field_bytes(&self) -> FieldBytes {
self.to_be_byte_array()
}
}
#[cfg(feature = "arithmetic")]
pub type NonZeroScalar = elliptic_curve::NonZeroScalar<BignP256>;
#[cfg(feature = "arithmetic")]
pub type PublicKey = elliptic_curve::PublicKey<BignP256>;
pub type SecretKey = elliptic_curve::SecretKey<BignP256>;
#[cfg(not(feature = "arithmetic"))]
impl elliptic_curve::sec1::ValidatePublicKey for BignP256 {}
#[cfg(feature = "bits")]
pub type ScalarBits = elliptic_curve::ScalarBits<BignP256>;