Internet-Draft | The Multibase Data Format | August 2023 |
Benet & Sporny | Expires 21 February 2024 | [Page] |
Raw binary data is often encoded using a mechanism that enables the data to be included in human-readable text-based formats. This mechanism is often referred to as "base-encoding the data". Base-encoding is often used when expressing binary data in hyperlinks, cryptographic keys in web pages, or security tokens in application software. There are a variety of base-encodings, such as base32, base58, and base64. It is not always possible to differentiate one base-encoding from another. The purpose of this specification is to provide a mechanism to be able to deterministically identify the base-encoding for a particular string of data.¶
This specification is a joint work product of Protocol Labs, and the W3C Credentials Community Group. Feedback related to this specification should logged in the issue tracker or be sent to [email protected].¶
This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.¶
Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.¶
Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."¶
This Internet-Draft will expire on 21 February 2024.¶
Copyright (c) 2023 IETF Trust and the persons identified as the document authors. All rights reserved.¶
This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Revised BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Revised BSD License.¶
This specification describes a forward-compatible data model for expressing raw binary data in a variety of base-encoding formats such as base32, base58. and base64.¶
When text is encoded as bytes, we can usually use a one-size-fits-all encoding (UTF-8) because we're always encoding to the same set of 256 bytes. When that doesn't work, usually for historical or performance reasons, we can usually infer the encoding from the context.¶
However, when bytes are encoded as text (using a base encoding), the choice of base encoding is often restricted by the context. Worse, these restrictions can change based on where the data appears in the text. In some cases, we can only use [a-z0-9]. In others, we can use a larger set of characters but need a compact encoding. This has lead to a large set of "base encodings", one for every use-case. Unlike when encoding text to bytes, we can't just standardize around a single base encoding because there is no optimal encoding for all cases.¶
Unfortunately, it's not always clear what base encoding is used; that's where this specification comes in. It answers the question:¶
Given data 'd' encoded into text 's', what base is it encoded with?¶
A multibase-encoded value follows a simple format:¶
base-encoding-character base-encoded-data¶
The encoding algorithm is a single character value that is always the first byte of the data. The possible values for this field are provided in The Multibase Algorithm Registry.¶
The following is an encoding of "Hello World!" using the version of base-58 that utilizes the Bitcoin encoding character set:¶
z2NEpo7TZRRrLZSi2U¶
The first byte (z) specifies the multibase encoding algorithm. The rest of the data specifies the value of the output of the multibase encoding algorithm.¶
There are a number of security considerations to take into account when implementing or utilizing this specification. TBD¶
The multibase examples are chosen to show different encoding algorithms and different output lengths at play. The input test data for all of the examples in this section is:¶
Multibase is awesome! \o/¶
F4D756C74696261736520697320617765736F6D6521205C6F2F¶
BJV2WY5DJMJQXGZJANFZSAYLXMVZW63LFEEQFY3ZP¶
zYAjKoNbau5KiqmHPmSxYCvn66dA1vLmwbt¶
MTXVsdGliYXNlIGlzIGF3ZXNvbWUhIFxvLw==¶
The editors would like to thank the following individuals for feedback on and implementations of the specification (in alphabetical order):¶
The following initial entries should be added to the Multibase Algorithms Registry to be created and maintained at (the suggested URI) http://www.iana.org/assignments/multibase-algorithms:¶
Algorithm | Identifier (character) | Status | Specification |
---|---|---|---|
identity | 0x00 | default | 8-bit binary (encoder and decoder keeps data unmodified) |
base16 | f | default | Hexadecimal (lowercase) |
base16upper | F | default | Hexadecimal (uppercase) |
base32 | b | default | RFC4648 case-insensitive - no padding |
base32upper | B | default | RFC4648 case-insensitive - no padding |
base58btc | z | default | Base58 bitcoin |
base64 | m | default | RFC4648 no padding |
base64url | u | default | RFC4648 no padding |
base64urlpad | U | default | RFC4648 with padding |
NOTE: The most up to date place for developers to find the table above is https://github.com/multiformats/multibase/blob/master/multibase.csv.¶