Skip to content

BTCDecoded/blvm-muhash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

blvm-muhash

crates.io docs.rs CI License: MIT

MuHash3072 for Bitcoin UTXO set hashing. Matches Bitcoin Core gettxoutsetinfo muhash output for AssumeUTXO compatibility.

Features

  • Core-compatible — Produces identical hashes to Bitcoin Core's MuHash3072
  • Incremental — Insert and remove elements without full recomputation
  • Mergeable — Combine hashes for parallel processing
  • No bitcoin- deps* — Pure Rust with sha2, chacha20, cipher

Installation

Add to your Cargo.toml:

[dependencies]
blvm-muhash = "0.1"

Usage

use blvm_muhash::{MuHash3072, serialize_coin_for_muhash};

// Serialize a UTXO for hashing (matches Core TxOutSer format)
let txid = [0u8; 32];
let vout = 0u32;
let height = 100u32;
let is_coinbase = true;
let amount = 50_0000_0000i64; // 50 BTC in satoshis
let script_pubkey = vec![0x76, 0xa9, 0x14]; // P2PKH prefix

let serialized = serialize_coin_for_muhash(&txid, vout, height, is_coinbase, amount, &script_pubkey);

// Hash the UTXO set (iterate in lexicographic order by outpoint)
let hash = MuHash3072::new()
    .insert(&serialized)
    .finalize();

assert_eq!(hash.len(), 32);

API

Item Description
MuHash3072::new() Empty set
insert(self, data) Add element
remove(self, data) Remove element
multiply(self, other) Union of sets
divide(self, other) Difference of sets
finalize(self) Produce 32-byte hash
serialize_coin_for_muhash(...) Serialize (outpoint, coin) for insertion

License

MIT

About

MuHash3072 for Bitcoin UTXO set hashing

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors