| Crates.io | spark-address |
| lib.rs | spark-address |
| version | 0.1.0 |
| created_at | 2025-05-18 06:44:35.831155+00 |
| updated_at | 2025-05-18 06:44:35.831155+00 |
| description | Minimal, no_std-compatible Bech32m encoder/decoder for Spark addresses |
| homepage | https://github.com/ethanmarcuss/spark-address |
| repository | https://github.com/ethanmarcuss/spark-address |
| max_upload_size | |
| id | 1678419 |
| size | 37,477 |
A minimal, no-std-compatible Rust library for encoding and decoding Spark Bech32m addresses.
no_std + alloc environmentsAdd the crate to your Cargo.toml:
spark-address = "0.1"
Enable optional features if you need them:
spark-address = { version = "0.1", default-features = false, features = ["validate-secp256k1"] }
use spark_address::{
encode_spark_address, decode_spark_address, SparkAddressData, Network,
};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Compressed 33-byte secp256k1 public key (hex encoded)
let pubkey = "0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798";
// Build the data structure we want to encode
let data = SparkAddressData {
identity_public_key: pubkey.into(),
network: Network::Mainnet,
};
// Encode → `sp1…`
let addr = encode_spark_address(&data)?;
println!("Spark address: {addr}");
// Decode back
let decoded = decode_spark_address(&addr)?;
assert_eq!(decoded, data);
Ok(())
}
| Feature | Default | Description |
|---|---|---|
std |
✓ | Use the Rust standard library. Disable it for #![no_std] targets. |
validate-secp256k1 |
Verify that the supplied public key is a valid compressed secp256k1 key (uses the secp256k1 crate). |
The crate has no transitive dependencies beyond bech32 and hex (plus secp256k1 when validation is enabled).
A Spark address is a standard Bech32m string consisting of:
sp, spt, sps, sprt, or spl.0x0a) that wraps a 33-byte compressed secp256k1 public key.For full details see the implementation in src/lib.rs.
Licensed under either of
at your option.