|
| 1 | +// Package crypto provides cryptographic primitives for the Aptos blockchain. |
| 2 | +// |
| 3 | +// This internal package implements all cryptographic operations required by the SDK: |
| 4 | +// - Key generation and management |
| 5 | +// - Digital signatures |
| 6 | +// - Authentication key derivation |
| 7 | +// - BCS serialization of cryptographic types |
| 8 | +// |
| 9 | +// # Supported Key Types |
| 10 | +// |
| 11 | +// Ed25519: |
| 12 | +// - Ed25519PrivateKey: Standard Ed25519 signing key |
| 13 | +// - Ed25519PublicKey: Ed25519 verification key |
| 14 | +// - Ed25519Signature: 64-byte Ed25519 signature |
| 15 | +// |
| 16 | +// Secp256k1: |
| 17 | +// - Secp256k1PrivateKey: ECDSA signing key (Bitcoin-style) |
| 18 | +// - Secp256k1PublicKey: Uncompressed public key (65 bytes) |
| 19 | +// - Secp256k1Signature: ECDSA signature (r || s, 64 bytes) |
| 20 | +// |
| 21 | +// Secp256r1 (P-256): |
| 22 | +// - Secp256r1PrivateKey: ECDSA signing key (WebAuthn-compatible) |
| 23 | +// - Secp256r1PublicKey: Uncompressed public key (65 bytes) |
| 24 | +// - Secp256r1Signature: ECDSA signature (r || s, 64 bytes) |
| 25 | +// |
| 26 | +// Post-Quantum: |
| 27 | +// - SlhDsaPrivateKey: SPHINCS+ SLH-DSA-SHA2-128s signing key |
| 28 | +// - SlhDsaPublicKey: SLH-DSA public key (32 bytes) |
| 29 | +// - SlhDsaSignature: SLH-DSA signature (7856 bytes) |
| 30 | +// |
| 31 | +// # Authentication Schemes |
| 32 | +// |
| 33 | +// SingleKey (scheme 0x02): |
| 34 | +// - AnyPublicKey wraps any supported key type |
| 35 | +// - AnySignature wraps the corresponding signature type |
| 36 | +// - Used for modern single-signer accounts |
| 37 | +// |
| 38 | +// MultiKey (scheme 0x03): |
| 39 | +// - Combines multiple AnyPublicKey instances |
| 40 | +// - K-of-N threshold signatures |
| 41 | +// - Supports heterogeneous key types |
| 42 | +// |
| 43 | +// Legacy schemes: |
| 44 | +// - Ed25519Scheme (0x00): Legacy Ed25519 accounts |
| 45 | +// - MultiEd25519Scheme (0x01): Legacy multi-sig Ed25519 |
| 46 | +// |
| 47 | +// # WebAuthn Support |
| 48 | +// |
| 49 | +// The package supports WebAuthn/Passkey authentication: |
| 50 | +// - PartialAuthenticatorAssertionResponse: WebAuthn assertion |
| 51 | +// - AssertionSignature: Wraps Secp256r1 signature |
| 52 | +// - Verification of client data and authenticator data |
| 53 | +// |
| 54 | +// # Keyless Authentication |
| 55 | +// |
| 56 | +// Types for OIDC-based keyless accounts: |
| 57 | +// - KeylessPublicKey: OIDC identity commitment |
| 58 | +// - FederatedKeylessPublicKey: With JWK address |
| 59 | +// - KeylessSignature: ZK proof or OpenID signature |
| 60 | +// |
| 61 | +// # Thread Safety |
| 62 | +// |
| 63 | +// Private key types (Ed25519PrivateKey, Secp256k1PrivateKey, Secp256r1PrivateKey) |
| 64 | +// are thread-safe. Cached public keys and authentication keys are protected by |
| 65 | +// sync.RWMutex using double-checked locking. |
| 66 | +// |
| 67 | +// Public key and signature types are immutable after creation and safe to share. |
| 68 | +// |
| 69 | +// # Security Considerations |
| 70 | +// |
| 71 | +// - Private keys are redacted in String() methods to prevent accidental logging |
| 72 | +// - Signature malleability is prevented by enforcing low-s values |
| 73 | +// - WebAuthn uses constant-time comparison for challenge verification |
| 74 | +// - All pooled resources clear sensitive data before reuse |
| 75 | +package crypto |
0 commit comments