minisketch-rs
minisketch-rs
is a wrapper around minisketch,
a C library by Pieter Wuille for efficient set reconciliation.
minisketch is proposed as a part of an Erlay technique for bandwidth-efficient TX propagation in Bitcoin.
This library exposes type-safe Rust bindings for all minisketch
functions by providing Minisketch
structure.
Example
Cargo.toml:
[]
= "0.1"
Example of simple set reconciliation between Alice and Bob:
// Alice's side
let mut sketch_a = try_new?;
println!;
for i in 3_000..3_010
let sersize = sketch_a.serialized_size;
assert_eq!;
// Serialize message for Bob
let mut buf_a = vec!;
sketch_a.serialize?;
println!;
// Bob's side
Code snippet above will print:
Alice's set:
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
Message: 6, [1, 224, 210, 249, 116, 105]
Bob's set:
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
Differences between Alice and Bob: 4
Difference #1: 3000
Difference #2: 3001
Difference #3: 3010
Difference #4: 3011