aptos_sdk/account/mod.rs
1//! Account management for the Aptos SDK.
2#![allow(clippy::module_inception)] // account::account is intentional naming
3#![allow(rustdoc::broken_intra_doc_links)] // Docs don't use one of the features
4//!
5//! This module provides account types that wrap cryptographic keys
6//! and provide a unified interface for signing transactions.
7//!
8//! # Account Types
9//!
10//! - [`Ed25519Account`] - Single-key Ed25519 account (legacy format, most common)
11//! - [`Ed25519SingleKeyAccount`] - Ed25519 account using modern `SingleKey` format
12//! - [`MultiEd25519Account`] - M-of-N multi-signature Ed25519 account
13//! - [`Secp256k1Account`] - Single-key Secp256k1 account (Bitcoin/Ethereum curve)
14//! - [`Secp256r1Account`] - Single-key Secp256r1/P-256 account. **Deprecated for
15//! transaction signing** (off-chain use only): bare `secp256r1` signatures are
16//! rejected by Aptos validators. Use [`WebAuthnAccount`] for on-chain P-256 signing.
17//! - [`WebAuthnAccount`] - Secp256r1/P-256 account using the WebAuthn/Passkey
18//! envelope; the supported path for signing Aptos transactions with a P-256 key
19//! (requires `secp256r1` feature)
20//! - [`MultiKeyAccount`] - M-of-N multi-signature account with mixed key types
21//!
22//! # Ed25519 example
23//!
24//! ```rust,ignore
25//! use aptos_sdk::account::Ed25519Account;
26//!
27//! // Generate a new random account
28//! let account = Ed25519Account::generate();
29//! println!("Address: {}", account.address());
30//!
31//! // Create from a private key
32//! let private_key_hex = "0x...";
33//! let account = Ed25519Account::from_private_key_hex(private_key_hex).unwrap();
34//! ```
35
36mod account;
37#[cfg(feature = "ed25519")]
38mod ed25519;
39#[cfg(feature = "mnemonic")]
40mod mnemonic;
41#[cfg(feature = "ed25519")]
42mod multi_ed25519;
43mod multi_key;
44mod rotation;
45#[cfg(feature = "secp256k1")]
46mod secp256k1;
47#[cfg(feature = "secp256r1")]
48mod secp256r1;
49#[cfg(feature = "secp256r1")]
50mod webauthn;
51
52pub use account::{Account, AnyAccount, AuthenticationKey};
53#[cfg(feature = "ed25519")]
54pub use ed25519::{Ed25519Account, Ed25519SingleKeyAccount};
55#[cfg(feature = "mnemonic")]
56pub use mnemonic::{DerivationPath, Mnemonic, PathComponent};
57#[cfg(feature = "ed25519")]
58pub use multi_ed25519::MultiEd25519Account;
59pub use multi_key::{AnyPrivateKey, MultiKeyAccount};
60pub use rotation::{RotationProofChallenge, build_rotate_auth_key_payload};
61#[cfg(feature = "secp256k1")]
62pub use secp256k1::Secp256k1Account;
63#[cfg(feature = "secp256r1")]
64#[allow(deprecated)] // Re-exported for back-compat; the type itself is deprecated.
65pub use secp256r1::Secp256r1Account;
66#[cfg(feature = "secp256r1")]
67pub use webauthn::{DEFAULT_WEBAUTHN_ORIGIN, DEFAULT_WEBAUTHN_RP_ID, WebAuthnAccount};