Skip to main content

Crate kobe_primitives

Crate kobe_primitives 

Source
Expand description

Kobe core primitives — the foundation of every chain crate.

This crate owns the type system shared by every kobe-<chain> crate: the Wallet entry point, the Derive / DeriveExt traits, the typed DerivedPublicKey enum, the unified DeriveError, and the BIP-32 / SLIP-10 / Camouflage primitives that chain crates compose.

§Module map

                       Wallet                (mnemonic + 64-byte BIP-39 seed)
                   ┌─────┴─────┐
   derive_secp256k1│           │  derive_ed25519
                   ▼           ▼
   bip32::DerivedSecp256k1Key     slip10::DerivedEd25519Key
                   │           │
   used by EVM / Cosmos /     │  used by Solana / Sui /
    Tron / Spark / Fil /       │  Aptos / TON
    XRPL / Nostr               │
                   └─────┬─────┘
                         ▼
                  DerivedAccount  ─◄── every chain wraps this
                  (path + sk + pk + address)

camouflage is an orthogonal utility (entropy-layer XOR encryption that turns one BIP-39 mnemonic into another) gated behind its own feature.

§Zeroize policy

Every sensitive byte string is wiped when dropped:

Public keys and on-chain addresses are not zeroized: by design they carry no secret material.

§no_std surface

FeatureNeeds allocPurpose
std (default)std::error::Error, OS RNG
allocWallet, DerivedAccount, mnemonic
bip32bip32::DerivedSecp256k1Key
slip10slip10::DerivedEd25519Key
camouflagecamouflage (PBKDF2 XOR helpers)
rand / rand_coreWallet::generate
test-vectorsRe-export of canonical BIP-39 fixtures

Only DeriveError and test_vectors compile in pure no_std without alloc. Everything else requires at least alloc.

§Quick tour

use kobe_primitives::Wallet;

// 1. Build a wallet from a BIP-39 mnemonic:
let wallet = Wallet::from_mnemonic(
    "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about",
    None,
)?;

// 2. Derive secp256k1 / Ed25519 keys at BIP-32 / SLIP-10 paths
//    (enable the `bip32` / `slip10` features):
assert_eq!(wallet.derive_secp256k1("m/44'/60'/0'/0/0")?.compressed_pubkey().len(), 33);
assert_eq!(wallet.derive_ed25519("m/44'/501'/0'/0'")?.public_key_bytes().len(), 32);

For chain-specific derivation (Bitcoin addresses, Ethereum checksummed addresses, Solana keypairs, etc.), reach for the matching chain crate (kobe-btc, kobe-evm, kobe-svm, …) via the kobe umbrella crate.

Re-exports§

pub use bip39::rand_core;

Modules§

bip32
BIP-32 secp256k1 key derivation utilities.
camouflage
Mnemonic camouflage via entropy-layer XOR encryption.
mnemonic
BIP-39 mnemonic utilities.
slip10
SLIP-0010 Ed25519 key derivation.
test_vectors
Well-known BIP-39 / SLIP-10 test vectors, exposed for downstream test suites.

Structs§

DerivedAccount
A derived HD account — unified across all chains.
ParseDerivationStyleError
Error returned when FromStr fails on a chain’s DerivationStyle.
Wallet
A unified HD wallet that can derive keys for multiple cryptocurrencies.

Enums§

DeriveError
Errors produced by HD derivation, mnemonic handling, and address encoding.
DerivedPublicKey
Strongly typed public key emitted by an HD derivation.
Language
Language to be used for the mnemonic phrase.
PublicKeyKind
Tag describing DerivedPublicKey’s variant without carrying the bytes.

Traits§

DerivationStyle
Trait implemented by every chain’s DerivationStyle enum.
Derive
Unified derivation trait implemented by every chain deriver.
DeriveExt
Extension trait providing batch derivation for every Derive implementor.

Functions§

derive_range
Derive a range of accounts by repeatedly invoking a derivation closure.

Type Aliases§

Result
Convenient Result alias.