#monero #base58 #base58-check

base58-monero

Library with support for encoding/decoding Monero base58 strings

9 releases (2 stable)

1.1.0 Mar 11, 2023
1.0.0 Jun 27, 2022
0.3.2 Nov 15, 2021
0.3.1 Sep 27, 2021
0.1.1 Mar 9, 2019

#1409 in Magic Beans

Download history 10243/week @ 2023-01-28 10089/week @ 2023-02-04 11262/week @ 2023-02-11 10518/week @ 2023-02-18 9835/week @ 2023-02-25 11276/week @ 2023-03-04 12376/week @ 2023-03-11 11131/week @ 2023-03-18 9762/week @ 2023-03-25 8541/week @ 2023-04-01 8687/week @ 2023-04-08 10385/week @ 2023-04-15 10020/week @ 2023-04-22 8470/week @ 2023-04-29 11610/week @ 2023-05-06 8792/week @ 2023-05-13

41,087 downloads per month
Used in 31 crates (11 directly)

MIT license

62KB
1K SLoC

Build Status Codecov branch unsafe forbidden Crates.io Documentation License: MIT MSRV

Rust Monero Base58

Library with support for encoding/decoding Monero base58 strings, with and without checksum verification.

Bitcoin base58 vs Monero base58

Monero base58 is not like Bitcoin base58, bytes are converted in 8-byte blocks. The last block can have less than 8 bytes, but at least 1 byte. Eight bytes converts to 11 or less Base58 characters; if a particular block converts to <11 characters, the conversion pads it with "1"s (1 is 0 in Base58). Likewise, the final block can convert to 11 or less Base58 digits.

Due to the conditional padding, the 69-byte string, like Monero addresses, will always convert to 95 Base58 characters (8 * 11 + 7); where 7 is length of the last block of 5 bytes.

The alphabet is composed of 58 characters visually not similar to avoid confusion, e.g. both 1 and l are not part of the alphabet together, only 1 is present. The full alphabet is composed of: 123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz

Features

By default only check feature is enabled. If you don't want to include all default features in your project:

[dependencies.base58-monero]
version = "1"
default-features = false

check

Enables encode_check and decode_check functions. By default check feature is enable.

stream

This feature is not extensively tested and have performance issues, use it at your own risk!

Enables encode_stream and decode_stream functions. By default stream feature is not enable. This feature enables async stream for encoding/decoding bytes. This should be used when encoding larger amount of data or in asyncronous environment. stream can be used with check to enable encode_stream_check and decode_stream_check. To use stream feature you can add in your Cargo.toml:

[dependencies.base58-monero]
version = "1"
features = ["stream"]

Tests

Doctests needs stream feature to run, run tests with all features:

cargo test --all-features

Benchmarks

Results obtained on an Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz with a standard Monero address as data source. Performances are shown in nanosecond per iteration of compute, the smaller the better:

Operation Regular _check
encode 652 ns (+/- 107) 1,272 ns (+/- 760)
decode 612 ns (+/- 82) 1,187 ns (+/- 541)

Check versions compute or verify the checksum while encoding or decoding the data.

Benchmarks can be found under /benches and run with cargo +nightly bench.

Releases and Changelog

See CHANGELOG.md and RELEASING.md.

About

This started as a research project sponsored by TrueLevel SA. It is now maintained by community members.

Licensing

The code in this project is licensed under the MIT License

Dependencies

~0.5–6MB
~98K SLoC