client_side_validation 0.12.0

Client-side validation foundation library
Documentation
{-
  Description: Merklization and MPC workflows
  Author: Dr Maxim Orlovsky <orlovsky@lnp-bp.org>
  Copyright (C) 2024 LNP/BP Standards Association. All rights reserved.
  License: Apache-2.0
-}

Merklization vesper lexicon=types+commitments


-- General merklization workflows

commitment MerkleHash, hasher SHA256, tagged urn:ubideco:merkle:node#2024-01-31
  serialized MerkleNode

rec MerkleNode
  enum branching, NodeBranching, void 0, single 1, branch 2
  is depth, U8
  is width, U256
  bytes node1, len 32, aka MerkleHash
  bytes node2, len 32, aka MerkleHash


-- Multi-protocol commitment workflows

commitment MerkleHash, hasher SHA256, tagged urn:ubideco:merkle:node#2024-01-31
  serialized Leaf

union Leaf
  rec inhabited, tag 0
    bytes protocol, len 32, aka ProtocolId
    bytes message, len 32, aka Message
  rec entropy, tag 1
    is entropy, U64
    is pos, U32

commitment Commitment, hasher SHA256, tagged urn:ubideco:mpc:commitment#2024-01-31
  serialized MerkleConcealed

rec MerkleConcealed
  enum depth {
    U5, _0 0, _1 1, _2 2, _3 3, _4 4, _5 5, _6 6, _7 7
    _8 8, _9 9, _10 10, _11 11, _12 12, _13 13, _14 14, _15 15
    _16 16, _17 17, _18 18, _19 19, _20 20, _21 21, _22 22, _23 23
    _24 24, _25 25, _26 26, _27 27, _28 28, _29 29, _30 30, _31 31
    
  }
  is cofactor, U16
  bytes merkleRoot, len 32, aka MerkleHash

commitment Commitment, hasher SHA256, tagged urn:ubideco:mpc:commitment#2024-01-31
  concealed MerkleConcealed, concealed MerkleConcealed

rec MerkleBlock
  enum method, Method, sha256t 0
  enum depth {
    U5, _0 0, _1 1, _2 2, _3 3, _4 4, _5 5, _6 6, _7 7
    _8 8, _9 9, _10 10, _11 11, _12 12, _13 13, _14 14, _15 15
    _16 16, _17 17, _18 18, _19 19, _20 20, _21 21, _22 22, _23 23
    _24 24, _25 25, _26 26, _27 27, _28 28, _29 29, _30 30, _31 31
    
  }
  is cofactor, U16
  list crossSection, len 1..MAX32
    union TreeNode
      rec concealedNode, tag 0
        enum depth {
          U5, _0 0, _1 1, _2 2, _3 3, _4 4, _5 5, _6 6, _7 7
          _8 8, _9 9, _10 10, _11 11, _12 12, _13 13, _14 14, _15 15
          _16 16, _17 17, _18 18, _19 19, _20 20, _21 21, _22 22, _23 23
          _24 24, _25 25, _26 26, _27 27, _28 28, _29 29, _30 30, _31 31
          
        }
        bytes hash, len 32, aka MerkleHash
      rec commitmentLeaf, tag 1
        bytes protocolId, len 32, aka ProtocolId
        bytes message, len 32, aka Message
    is some, U64, option, wrapped, tag 1

commitment Commitment, hasher SHA256, tagged urn:ubideco:mpc:commitment#2024-01-31
  concealed MerkleConcealed, concealed MerkleConcealed

rec MerkleTree
  enum method, Method, sha256t 0
  enum depth {
    U5, _0 0, _1 1, _2 2, _3 3, _4 4, _5 5, _6 6, _7 7
    _8 8, _9 9, _10 10, _11 11, _12 12, _13 13, _14 14, _15 15
    _16 16, _17 17, _18 18, _19 19, _20 20, _21 21, _22 22, _23 23
    _24 24, _25 25, _26 26, _27 27, _28 28, _29 29, _30 30, _31 31
    
  }
  is entropy, U64
  is cofactor, U16
  map messages, len 0..MAX24
    bytes key, len 32, aka ProtocolId
    bytes value, len 32, aka Message
  map map, len 0..MAX24
    is key, U32
    tuple value
      bytes _, len 32, aka ProtocolId
      bytes _, len 32, aka Message