Safe58

Topic: base low level architecture concept

This is one of architecture concepts important to know during the software development for Universa integration. Among such topics are:

See Github for more details.

Overview

Safe58 is an improvement over the well-known Base58 encoding for binary data. Original Base64 algorithm is intended to prevent mistypes caused by the similarly-looking symbols. Safe58 enhances the algorithm, mapping these symbols back to their “originals”, thus making the possible mistypes recoverable.

In Universa, Safe58 is used for encoding of Key address.

Alphabet

As with the Base58 (in Bitcoin or IPFS implementations), it uses the alphabet 123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz.

Algorithm

The implementation matches the original Base58 implementation, with the extra addition: at the start of the decoding step, the input data is searched for some symbols omitted from Base58 alphabet. If these symbols are found, they are replaced with their in-alphabet counterparts:

  • I1
  • !1
  • |1
  • l1
  • Oo
  • 0o

Backward compatibility with Base58

When the same alphabet is used, Safe58 and Base58 are very much compatible:

  • Any binary string is encoded to the same text representation by both Safe58 and Base58.
  • Any text representation containing of valid alphabet symbols only gets decoded to the same binary string.

Unit tests

Available in Github.