Skip to main content

kobe_primitives/
lib.rs

1//! Multi-chain HD wallet derivation library.
2//!
3//! Core [`Wallet`] type holds a BIP-39 mnemonic and derives seeds for
4//! chain-specific derivers (`kobe-evm`, `kobe-btc`, `kobe-svm`, etc.).
5//!
6//! ```no_run
7//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
8//! let wallet = kobe_primitives::Wallet::from_mnemonic(
9//!     "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about",
10//!     None,
11//! )?;
12//! # Ok(())
13//! # }
14//! ```
15
16#![cfg_attr(not(feature = "std"), no_std)]
17
18#[cfg(feature = "alloc")]
19extern crate alloc;
20
21#[cfg(feature = "alloc")]
22mod derive;
23mod error;
24#[cfg(feature = "alloc")]
25mod wallet;
26
27#[cfg(feature = "bip32")]
28pub mod bip32;
29#[cfg(feature = "camouflage")]
30pub mod camouflage;
31#[cfg(feature = "alloc")]
32pub mod mnemonic;
33#[cfg(feature = "slip10")]
34pub mod slip10;
35
36pub use bip39::Language;
37#[cfg(feature = "rand_core")]
38pub use bip39::rand_core;
39#[cfg(feature = "alloc")]
40pub use derive::{Derive, DeriveExt, DerivedAccount, derive_range};
41pub use error::DeriveError;
42#[cfg(feature = "alloc")]
43pub use wallet::Wallet;
44
45/// Convenient Result alias.
46pub type Result<T> = core::result::Result<T, DeriveError>;
47
48/// Well-known BIP-39 / SLIP-10 test vectors, exposed for downstream test suites.
49///
50/// Gated on the `test-vectors` feature so they do **not** ship with the
51/// default binary/`lib` build. The module contains only `&'static str`
52/// constants and is available in `no_std + no_alloc` environments.
53#[cfg(feature = "test-vectors")]
54pub mod test_vectors {
55    /// All-zero 128-bit entropy — yields the canonical BIP-39 test mnemonic
56    /// (`"abandon abandon … about"`). Cross-verified against the BIP-39
57    /// reference implementations and `iancoleman.io/bip39`.
58    pub const MNEMONIC_ABANDON: &str = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about";
59
60    /// 64-byte BIP-39 seed derived from [`MNEMONIC_ABANDON`] with an empty
61    /// passphrase, lowercase hex.
62    pub const SEED_HEX_ABANDON: &str = "5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4";
63}