net.corda.core.crypto / CompositeKey

# CompositeKey

`sealed class CompositeKey`

A tree data structure that enables the representation of composite public keys.

In the simplest case it may just contain a single node encapsulating a PublicKey – a Leaf.

For more complex scenarios, such as "Both Alice and Bob need to sign to consume a state S", we can represent the requirement by creating a tree with a root Node, and Alice and Bob as children – Leafs. The root node would specify weights for each of its children and a threshold – the minimum total weight required (e.g. the minimum number of child signatures required) to satisfy the tree signature requirement.

Using these constructs we can express e.g. 1 of N (OR) or N of N (AND) signature requirements. By nesting we can create multi-level requirements such as "either the CEO or 3 of 5 of his assistants need to sign".

### Types

Builder | `class Builder` A helper class for building a CompositeKey.Node.
Leaf | `class Leaf : CompositeKey` The leaf node of the tree – a wrapper around a PublicKey primitive
Node | `class Node : CompositeKey` Represents a node in the key tree. It maintains a list of child nodes – sub-trees, and associated weights carried by child node signatures.

### Properties

keys | `abstract val keys: Set<PublicKey>` Returns all PublicKeys contained within the tree leaves
singleKey | `val singleKey: PublicKey` Returns the enclosed PublicKey for a CompositeKey with a single leaf node

### Functions

containsAny | `fun containsAny(otherKeys: Iterable<PublicKey>): <ERROR CLASS>` Checks whether any of the given keys matches a leaf on the tree
isFulfilledBy | `abstract fun isFulfilledBy(keys: Iterable<PublicKey>): Boolean` Checks whether keys match a sufficient amount of leaf nodes `fun isFulfilledBy(key: PublicKey): <ERROR CLASS>`
toBase58String | `fun toBase58String(): String` This is generated by serializing the composite key with Kryo, and encoding the resulting bytes in base58. A custom serialization format is being used.

### Companion Object Functions

parseFromBase58 | `fun parseFromBase58(encoded: String): <ERROR CLASS>`

### Inheritors

Leaf | `class Leaf : CompositeKey` The leaf node of the tree – a wrapper around a PublicKey primitive
Node | `class Node : CompositeKey` Represents a node in the key tree. It maintains a list of child nodes – sub-trees, and associated weights carried by child node signatures.