bc_components/ec_key/mod.rs
1//! Elliptic curve cryptography key types and operations.
2//!
3//! This module provides types and operations for elliptic curve cryptography
4//! (ECC), specifically focusing on the secp256k1 curve used in Bitcoin and
5//! other cryptocurrencies. It supports both traditional ECDSA (Elliptic Curve
6//! Digital Signature Algorithm) and the newer Schnorr signature scheme
7//! (BIP-340).
8//!
9//! The main components are:
10//!
11//! - `ECPrivateKey`: A 32-byte private key for signing
12//! - `ECPublicKey`: A 33-byte compressed public key for verification
13//! - `ECUncompressedPublicKey`: A 65-byte uncompressed public key (legacy
14//! format)
15//! - `SchnorrPublicKey`: A 32-byte x-only public key for BIP-340 Schnorr
16//! signatures
17//!
18//! All these types implement the `ECKeyBase` trait, which provides common
19//! functionality for elliptic curve keys. The `ECKey` trait extends `ECKeyBase`
20//! to provide functionality for deriving public keys from private keys. The
21//! `ECPublicKeyBase` trait provides functionality for working with uncompressed
22//! public keys.
23//!
24//! ## Signature Schemes
25//!
26//! This module supports two signature schemes:
27//!
28//! - **ECDSA**: The traditional signature scheme used in Bitcoin and other
29//! cryptocurrencies
30//! - **Schnorr**: A newer signature scheme (BIP-340) with advantages like
31//! linearity, non-malleability, and smaller signature size
32
33mod ec_key_base;
34pub use ec_key_base::{ECKey, ECKeyBase};
35
36mod ec_public_key_base;
37pub use ec_public_key_base::ECPublicKeyBase;
38
39mod ec_private_key;
40pub use ec_private_key::{ECDSA_PRIVATE_KEY_SIZE, ECPrivateKey};
41
42mod ec_public_key;
43pub use ec_public_key::{ECDSA_PUBLIC_KEY_SIZE, ECPublicKey};
44
45mod ec_uncompressed_public_key;
46pub use ec_uncompressed_public_key::{
47 ECDSA_UNCOMPRESSED_PUBLIC_KEY_SIZE, ECUncompressedPublicKey,
48};
49
50mod schnorr_public_key;
51pub use schnorr_public_key::{SCHNORR_PUBLIC_KEY_SIZE, SchnorrPublicKey};