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).

Threshold conditions allows each subcondition to carry an integer weight.

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 threshold conditions is as a boolean weighted threshold gate. A tree of threshold conditions forms a boolean weighted threhsold 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, weightopt)

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 Attributes Default Description
subcondition Condition

Condition to add

weight Number <optional>
1

Integer weight of the subcondition.

Source:

addSubconditionUri(Subcondition)

Add a subcondition (unfulfilled).

This will automatically parse the URI and call addSubcondition.

Parameters:
Name Type Description
Subcondition String

URI.

Source:

addSubfulfillment(Fulfillment, weightopt)

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 Attributes Default Description
Fulfillment Fulfillment

to add

weight Number <optional>
1

Integer weight of the subcondition.

Source:

addSubfulfillmentUri(Subfulfillment)

Add a fulfilled subcondition.

This will automatically parse the URI and call addSubfulfillment.

Parameters:
Name Type Description
Subfulfillment String

URI.

Source:

getBitmask() → {Number}

Get full bitmask.

This is a type of condition that can contain subconditions. A complete bitmask must contain the set of types that must be supported in order to validate this fulfillment. Therefore, we need to calculate the bitwise OR of this condition's FEATURE_BITMASK and all subcondition's and subfulfillment's bitmasks.

Source:
Returns:

Complete bitmask for this fulfillment.

Type
Number

setThreshold(threshold)

Set the threshold.

Determines the weighted threshold that is used to consider this condition fulfilled. If the added weight of all 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