Skip to content

Latest commit

 

History

History
146 lines (113 loc) · 5.67 KB

File metadata and controls

146 lines (113 loc) · 5.67 KB

Nonce Specification

Version: 0.0.1
Status: Pre-draft
© 2024 Cryptid Technologies, Inc.

This specification is subject to the Community Specification License 1.0.

Contents

  1. Foreword
  2. Introduction
    1. Current Status
    2. Normative References
    3. Terms and Definitions
  3. Specification
  4. Examples
    1. A Nonce with Random Data
    2. A Nonce with Multisig Data

Attention is drawn to the possibility that some of the elements of this document may be the subject of patent rights. No party shall not be held responsible for identifying any or all such patent rights.

Any trade name used in this document is information given for the convenience of users and does not constitute an endorsement.

This document was prepared by Cryptid Technologies, Inc.

Known patent licensing exclusions are available in the specification’s repository’s Notices.md file.

Any feedback or questions on this document should be directed to specifications repository.

THESE MATERIALS ARE PROVIDED “AS IS.” The Contributors and Licensees expressly disclaim any warranties (express, implied, or otherwise), including implied warranties of merchantability, non-infringement, fitness for a particular purpose, or title, related to the materials. The entire risk as to implementing or otherwise using the materials is assumed by the implementer and user. IN NO EVENT WILL THE CONTRIBUTORS OR LICENSEES BE LIABLE TO ANY OTHER PARTY FOR LOST PROFITS OR ANY FORM OF INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER FROM ANY CAUSES OF ACTION OF ANY KIND WITH RESPECT TO THIS DELIVERABLE OR ITS GOVERNING AGREEMENT, WHETHER BASED ON BREACH OF CONTRACT, TORT (INCLUDING NEGLIGENCE), OR OTHERWISE, AND WHETHER OR NOT THE OTHER MEMBER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

This specification outlines how to encode a nonce value (i.e. Number used ONCE) in a multiformats compatible way. Nonces are commonly used in a variety of cryptographic operations.

This version of the Nonce specification defines a minimal multiformats compatible encoding. It meets the needs of all use cases so far, however feel free to file an issue if you have a use case this does not cover.

This document refers to varuint encoded values throughout. The normative reference for which can be found in the multiformats unsigned-varint specification.

This document also refers to sigils the identify a codec or data type. The normative reference for the list of sigils can be found in the multiformats multicodecs table.

Varuint : An unsigned integer variable encoded in a variable number bytes.

Sigil : A constant value that maps to a codec or data type.

The following diagram shows the overall structure of a Nonce. A Nonce is identified by the 0x3b sigil followed by a varbytes encoded array of octets.

nonce sigil
 |
 v
0x3b <varbytes>
         ^
         |
    nonce octets

<varbytes> ::= <varuint> N(OCTET)
                   ^        ^
                  /          \
          count of            variable number
            octets            of octets

The Nonce format is designed in such a way that tools only need support for varuint and varbytes processing to know exactly how many octets are in the Nonce object so that it can skip over it if needed.

This example shows how a Nonce containing random data is encoded:

3b                  -- varuint, nonce sigil
  20                -- varuint, length of nonce data
    [32 octets]     -- 32 octets of random data

This example shows how a Nonce containing an EdDSA Multisig—as used in some VLADs—is encoded:

3b                  -- varuint, nonce sigil
  48                -- varuint, length of nonce data
    [               -- 72 octets of the Multisig
      39            -- varuint, Multisig sigil
      ed a1 03      -- varuint, EdDSA sigil
      [68 octets]   -- 68 octets of Multisig data
    ]

In this example the data inside of the Nonce is a Multisig. The Multisig consists of 72 octets that begins with the 0x39 Multisig sigil followed by the 0xed Ed25519 codec sigil signifying that this is an EdDSA signature. The remaining 70 octets are the Multisig attributes of the signature.