Skip to main content

@midnight-ntwrk/compact-runtime v0.7.0Readme | API


@midnight-ntwrk/compact-runtime v0.7.0 / persistentCommit

Function: persistentCommit()

persistentCommit<a>(
rt_type,
value,
opening): Uint8Array

The Compact builtin persistent_commit function

This function is a non-circuit-optimised commitment function from arbitrary values representable in Compact, and a 256-bit bytestring opening, to a 256-bit bytestring. It is guaranteed to persist between upgrades. It should be used to derive state data, and not for consistency checks where avoidable.

Note that data containing Opaque elements may throw runtime errors, and cannot be relied upon as a consistent representation.

Type parameters

a

Parameters

rt_type: CompactType<a>

value: a

opening: Uint8Array

Returns

Uint8Array

Throws

If rt_type encodes a type containing Compact 'Opaque' types, or opening is not 32 bytes long