@nimiq/core / Commitment
Class: Commitment
Defined in: @nimiq/core/types/wasm/web.d.ts:1036
A cryptographic commitment to a RandomSecret. The commitment is public, while the secret is, well, secret.
Constructors
Constructor
new Commitment(
bytes):Commitment
Defined in: @nimiq/core/types/wasm/web.d.ts:1065
Creates a new commitment from a byte array.
Throws when the byte array is not exactly 32 bytes long.
Parameters
bytes
Uint8Array
Returns
Commitment
Properties
serializedSize
readonlyserializedSize:number
Defined in: @nimiq/core/types/wasm/web.d.ts:1085
SIZE
readonlystaticSIZE:number
Defined in: @nimiq/core/types/wasm/web.d.ts:1084
Methods
__getClassname()
__getClassname():
string
Defined in: @nimiq/core/types/wasm/web.d.ts:1039
Returns
string
[dispose]()
[dispose]():
void
Defined in: @nimiq/core/types/wasm/web.d.ts:1038
Returns
void
equals()
equals(
other):boolean
Defined in: @nimiq/core/types/wasm/web.d.ts:1083
Returns if this commitment is equal to the other commitment.
Parameters
other
Commitment
Returns
boolean
free()
free():
void
Defined in: @nimiq/core/types/wasm/web.d.ts:1037
Returns
void
serialize()
serialize():
Uint8Array
Defined in: @nimiq/core/types/wasm/web.d.ts:1069
Serializes the commitment to a byte array.
Returns
Uint8Array
toHex()
toHex():
string
Defined in: @nimiq/core/types/wasm/web.d.ts:1079
Formats the commitment into a hex string.
Returns
string
derive()
staticderive(random_secret):Commitment
Defined in: @nimiq/core/types/wasm/web.d.ts:1043
Derives a commitment from an existing random secret.
Parameters
random_secret
Returns
Commitment
deserialize()
staticdeserialize(bytes):Commitment
Defined in: @nimiq/core/types/wasm/web.d.ts:1059
Deserializes a commitment from a byte array.
Throws when the byte array contains less than 32 bytes.
Parameters
bytes
Uint8Array
Returns
Commitment
fromAny()
staticfromAny(commitment):Commitment
Defined in: @nimiq/core/types/wasm/web.d.ts:1053
Parses a commitment from a Commitment instance, a hex string representation, or a byte array.
Throws when a Commitment cannot be parsed from the argument.
Parameters
commitment
string | Uint8Array<ArrayBufferLike> | Commitment
Returns
Commitment
fromHex()
staticfromHex(hex):Commitment
Defined in: @nimiq/core/types/wasm/web.d.ts:1075
Parses a commitment from its hex representation.
Throws when the string is not valid hex format or when it represents less than 32 bytes.
Parameters
hex
string
Returns
Commitment
sum()
staticsum(commitments):Commitment
Defined in: @nimiq/core/types/wasm/web.d.ts:1047
Sums up multiple commitments into one aggregated commitment.
Parameters
commitments
(string | Uint8Array<ArrayBufferLike> | Commitment)[]
Returns
Commitment