ThresholdSha256

types~ ThresholdSha256

THRESHOLD-SHA-256: Threshold gate condition using SHA-256.

Threshold conditions can be used to create m-of-n multi-signature groups.

Threshold conditions can represent the AND operator by setting the threshold to equal the number of subconditions (n-of-n) or the OR operator by setting the thresold to one (1-of-n).

Since threshold conditions operate on conditions, they can be nested as well which allows the creation of deep threshold trees of public keys.

By using Merkle trees, threshold fulfillments do not need to to provide the structure of unfulfilled subtrees. That means only the public keys that are actually used in a fulfillment, will actually appear in the fulfillment, saving space.

One way to formally interpret a threshold condition is as a booleanthreshold gate. A tree of threshold conditions forms a boolean threshold circuit.

THRESHOLD-SHA-256 is assigned the type ID 2. It relies on the SHA-256 and THRESHOLD feature suites which corresponds to a feature bitmask of 0x09.

Constructor

new ThresholdSha256()

Source:

Methods

addSubcondition(subcondition)

Add a subcondition (unfulfilled).

This can be used to generate a new threshold condition from a set of subconditions or to provide a non-fulfilled subcondition when creating a threshold fulfillment.

Parameters:
Name Type Description
subcondition Condition | String

Condition object or URI string representing a new subcondition to be added.

Source:

addSubfulfillment(subfulfillment)

Add a fulfilled subcondition.

When constructing a threshold fulfillment, this method allows you to provide a fulfillment for one of the subconditions.

Note that you do not have to add the subcondition if you're adding the fulfillment. The condition can be calculated from the fulfillment and will be added automatically.

Parameters:
Name Type Description
subfulfillment Fulfillment | String

Fulfillment object or URI string representing a new subfulfillment to be added.

Source:

getSubtypes() → {Number}

Get set of used type names.

This is a type of condition that can contain subconditions. A complete set of subtypes must contain all types that must be supported in order to validate this fulfillment. Therefore, we need to join the type of this fulfillment with all of the sets of subtypes for each of the subconditions.

Source:
Returns:

Complete set of types for this fulfillment.

Type
Number

setThreshold(threshold)

Set the threshold.

Determines the threshold that is used to consider this condition fulfilled. If the number of valid subfulfillments is greater or equal to this number, the threshold condition is considered to be fulfilled.

Parameters:
Name Type Description
threshold Number

Integer threshold

Source:

validate(message) → {Boolean}

Check whether this fulfillment meets all validation criteria.

This will validate the subfulfillments and verify that there are enough subfulfillments to meet the threshold.

Parameters:
Name Type Description
message Buffer

Message to validate against.

Source:
Returns:

Whether this fulfillment is valid.

Type
Boolean