Crate bc_envelope

source ·
Expand description

Gordian Envelope: A Flexible Container for Structured Data

Introduction

The Gordian Envelope protocol specifies a structured format for hierarchical binary data focused on the ability to transmit it in a privacy-focused way. Envelopes are designed to facilitate “smart documents” and have a number of unique features including: easy representation of a variety of semantic structures, a built-in Merkle-like digest tree, deterministic representation using CBOR, and the ability for the holder of a document to selectively encrypt or elide specific parts of a document without invalidating the document structure including the digest tree, or any cryptographic signatures that rely on it.

Getting Started

[dependencies]
bc-envelope = "0.12.2"

Specification

Gordian Envelope is currently specified in this IETF Internet Draft.

Envelopes are immutable. You create “mutations” by creating new envelopes from old envelopes.

Basic Envelope Creation

Adding Assertions

Adding Assertions with a Predicate and Object

Adding Assertions with an Assertion Envelope

Removing and Replacing Assertions

Queries

Getting the basic parts of an envelope

Getting assertions on an envelope

Getting the specific types of an envelope

  • Envelope::leaf The envelope’s leaf CBOR object, or None if the envelope is not a leaf.
  • Envelope::known_value The envelope’s known value, or None if the envelope is not a known value.

Determining the type of an envelope

Determining the type of an envelope’s subject

Getting assertions and parts of assertions

Extracting parts of envelopes as specific types

Other queries

Wrapping and Unwrapping Envelopes

Formatting Envelopes

Envelope notation

Tree notation

CBOR diagnostic notation

CBOR hexadecimal notation

  • Envelope::hex Formats an envelope in CBOR hexadecimal notation.
  • Envelope::hex_opt Formats an envelope in CBOR hexadecimal notation, with optional annotations.

Working with the Digest Tree

Semantic equivalence

Structural identicality

Signing and Verifying Signatures

Signing

  • Envelope::sign_with Creates a signature for the envelope’s subject and returns a new envelope with a verifiedBy: Signature assertion.
  • Envelope::sign_with_opt Creates a signature for the envelope’s subject and returns a new envelope with a verifiedBy: Signature assertion.
  • Envelope::sign_with_keys Creates several signatures for the envelope’s subject and returns a new envelope with additional verifiedBy: Signature assertions.
  • Envelope::sign_with_keys_opt Creates several signatures for the envelope’s subject and returns a new envelope with additional verifiedBy: Signature assertions.
  • Envelope::sign_with_uncovered_assertions Creates a signature for the envelope’s subject and returns a new envelope with a verifiedBy: Signature assertion.

Verifying by returning a boolean

Verifying by returning a result

Helpers

Splitting Envelopes with SSKR

Encryption

Public Key Encryption

Compression

Eliding, Encrypting, or Compressing Parts of an Envelope

Decorrelating Envelopes using Salt

Walking an Envelope’s Hierarchy

  • Envelope::walk Walk the envelope, calling the visitor function for each element.

Envelope Expressions

Constructing Expressions, Requests, and Responses

Decoding Parameters and Results

Re-exports

Modules

Macros