Skip to main content

kobe_spark/
lib.rs

1//! Spark protocol (Bitcoin L2) wallet utilities for Kobe.
2//!
3//! Implements the [Spark](https://docs.spark.money) identity-key derivation
4//! and Bech32m address encoding from a unified [`kobe_primitives::Wallet`]:
5//!
6//! - **Derivation path**: `m/8797555'/{account}'/0'` — hardened BIP-32
7//!   secp256k1. The purpose `8797555` is the Spark-specific constant
8//!   (`SHA-256("spark")` truncated).
9//! - **Address**: `spark1…` (Mainnet), `sparkt1…` (Testnet), `sparks1…`
10//!   (Signet), `sparkrt1…` (Regtest), `sparkl1…` (Local) — Bech32m-encoded
11//!   compressed identity public key wrapped in a minimal protobuf header.
12//!
13//! # Example
14//!
15//! ```no_run
16//! use kobe_primitives::Wallet;
17//! use kobe_spark::{Deriver, Network};
18//!
19//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
20//! let wallet = Wallet::from_mnemonic(
21//!     "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about",
22//!     None,
23//! )?;
24//! let account = Deriver::with_network(&wallet, Network::Mainnet).derive(0)?;
25//! assert!(account.address().starts_with("spark1"));
26//! # Ok(())
27//! # }
28//! ```
29
30#![cfg_attr(not(feature = "std"), no_std)]
31
32#[cfg(feature = "alloc")]
33extern crate alloc;
34
35#[cfg(feature = "alloc")]
36mod deriver;
37
38#[cfg(feature = "alloc")]
39pub use deriver::{Deriver, Network, SPARK_PURPOSE};
40pub use kobe_primitives::{DeriveError, DerivedAccount, DerivedPublicKey};