Skip to content

Commit 5eba6ae

Browse files
committed
docs: update readme
1 parent 8448f1a commit 5eba6ae

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

README.md

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# Base58 Encoding Library
22

3-
A .NET 9.0 Base58 encoding and decoding library with support for multiple alphabet variants.
3+
A .NET 10.0 Base58 encoding and decoding library with support for multiple alphabet variants.
44

55
## Features
66

7-
- **Multiple Alphabets**: Built-in support for Bitcoin(IFPS/Sui), Ripple, and Flickr alphabets
7+
- **Multiple Alphabets**: Built-in support for Bitcoin(IFPS/Sui/Solana), Ripple, and Flickr alphabets
88
- **Memory Efficient**: Uses stackalloc operations when possible to minimize allocations
99
- **Type Safe**: Leverages ReadOnlySpan and ReadOnlyMemory for safe memory operations
1010
- **Intrinsics**: Uses SIMD `Vector128/Vector256` and unrolled loop for counting leading zeros
11+
- **Optimized Hot Paths**: Fast fixed-length encode/decode for 32-byte and 64-byte inputs using Firedancer-like optimizations
1112

1213
## Usage
1314

@@ -24,9 +25,27 @@ byte[] decoded = Base58.Bitcoin.Decode(encoded);
2425
// Ripple / Flickr
2526
Base58.Ripple.Encode(data);
2627
Base58.Flickr.Encode(data);
28+
```
29+
30+
## Performance
31+
32+
The library automatically uses optimized fast paths for common fixed-size inputs:
33+
- **32-byte inputs** (Bitcoin/Solana addresses, SHA-256 hashes): 8.5x faster encoding
34+
- **64-byte inputs** (SHA-512 hashes): Similar performance improvements
35+
36+
These optimizations are based on Firedancer's specialized Base58 algorithms and are transparent to the user. Unlike Firedancer however, we fallback to the generic approach in case of edge-cases.
37+
38+
**Algorithm Details:**
39+
- Uses **Mixed Radix Conversion (MRC)** with intermediate base 58^5 representation
40+
- Precomputed multiplication tables replace expensive division operations
41+
- Converts binary data to base 58^5 limbs, then to raw base58 digits
42+
- Matrix multiplication approach processes 5 base58 digits simultaneously
43+
- Separate encode/decode tables for 32-byte and 64-byte fixed sizes
44+
- Achieves ~2.5x speedup through table-based optimizations vs iterative division
45+
46+
**References:**
47+
- [Firedancer C implementation](https://github.com/firedancer-io/firedancer/tree/main/src/ballet/base58)
2748

28-
// Custom
29-
new Base58(Base58Alphabet.Custom(""));
3049
```
3150
3251
## Benchmarks
@@ -71,4 +90,4 @@ Job=DefaultJob
7190
7291
## License
7392
74-
This project is available under the MIT License.
93+
This project is available under the MIT License.

0 commit comments

Comments
 (0)