UNPKG

ts-mls

Version:

[![CI](https://github.com/LukaJCB/ts-mls/actions/workflows/ci.yml/badge.svg)](https://github.com/LukaJCB/ts-mls/actions/workflows/ci.yml) [![npm version](https://badge.fury.io/js/ts-mls.svg)](https://badge.fury.io/js/ts-mls) [![Coverage Status](https://co

47 lines (46 loc) 3.02 kB
import { Encoder } from "./codec/tlsEncoder"; import { Decoder } from "./codec/tlsDecoder"; import { ParentNode } from "./parentNode"; import { LeafNode } from "./leafNode"; export type Node = NodeParent | NodeLeaf; type NodeParent = { nodeType: "parent"; parent: ParentNode; }; type NodeLeaf = { nodeType: "leaf"; leaf: LeafNode; }; export declare const encodeNode: Encoder<Node>; export declare const decodeNode: Decoder<Node>; export declare function getHpkePublicKey(n: Node): Uint8Array; export type RatchetTree = (Node | undefined)[]; export declare function extendRatchetTree(tree: RatchetTree): RatchetTree; /** * If the tree has 2d leaves, then it has 2d+1 - 1 nodes. * The ratchet_tree vector logically has this number of entries, but the sender MUST NOT include blank nodes after the last non-blank node. * The receiver MUST check that the last node in ratchet_tree is non-blank, and then extend the tree to the right until it has a length of the form 2d+1 - 1, adding the minimum number of blank values possible. * (Obviously, this may be done "virtually", by synthesizing blank nodes when required, as opposed to actually changing the structure in memory.) */ export declare function stripBlankNodes(tree: RatchetTree): RatchetTree; export declare const encodeRatchetTree: Encoder<RatchetTree>; export declare const decodeRatchetTree: Decoder<RatchetTree>; export declare function findBlankLeafNodeIndex(tree: RatchetTree): number | undefined; export declare function findBlankLeafNodeIndexOrExtend(tree: RatchetTree): number; export declare function extendTree(tree: RatchetTree, leafNode: LeafNode): [RatchetTree, number]; export declare function addLeafNode(tree: RatchetTree, leafNode: LeafNode): [RatchetTree, number]; export declare function updateLeafNode(tree: RatchetTree, leafNode: LeafNode, leafIndex: number): RatchetTree; export declare function removeLeafNode(tree: RatchetTree, removedLeafIndex: number): RatchetTree; export declare function resolution(tree: (Node | undefined)[], nodeIndex: number): number[]; export declare function filteredDirectPath(leafIndex: number, tree: RatchetTree): number[]; export declare function filteredDirectPathAndCopathResolution(leafIndex: number, tree: RatchetTree): { resolution: number[]; nodeIndex: number; }[]; export declare function removeLeaves(tree: RatchetTree, leafIndices: number[]): RatchetTree; export declare function traverseToRoot<T>(tree: RatchetTree, leafIndex: number, f: (nodeIndex: number, node: ParentNode) => T | undefined): [T, number] | undefined; export declare function findFirstNonBlankAncestor(tree: RatchetTree, nodeIndex: number): number; export declare function findLeafIndex(tree: RatchetTree, leaf: LeafNode): number | undefined; export declare function getCredentialFromLeafIndex(ratchetTree: RatchetTree, leafIndex: number): import("./credential").Credential; export declare function getSignaturePublicKeyFromLeafIndex(ratchetTree: RatchetTree, leafIndex: number): Uint8Array; export {};