API Reference

Utils

This package provides the API for all Utils modules.

For an overview of the module, read the Utils guide.

import "./node_modules/@openzeppelin/compact-contracts/utils/Utils";

There's no easy way to get the constraints of circuits at this time so the constraints of the circuits listed below have been omitted.

Ledger

None.

Witnesses

None.

Circuits

isKeyOrAddressZero(
  keyOrAddress: Either<ZswapCoinPublicKey, ContractAddress>
) → Boolean

circuit

#

Returns whether keyOrAddress is the zero address.

Midnight's burn address is represented as left<ZswapCoinPublicKey, ContractAddress>(default<ZswapCoinPublicKey>) in Compact, so we've chosen to represent the zero address as this structure as well.

isKeyZero(key: ZswapCoinPublicKey) → Boolean

circuit

#

Returns whether key is the zero address.

isKeyOrAddressEqual(
  keyOrAddress: Either<ZswapCoinPublicKey, ContractAddress>,
  other: Either<ZswapCoinPublicKey, ContractAddress>
) → Boolean

circuit

#

Returns whether keyOrAddress is equal to other. Assumes that a ZswapCoinPublicKey and a ContractAddress can never be equal.

isContractAddress(
  keyOrAddress: Either<ZswapCoinPublicKey, ContractAddress>
) → Boolean

circuit

#

Returns whether keyOrAddress is a ContractAddress type.

emptyString() → Opaque<"string">

circuit

#

A helper function that returns the empty string: "".

canonicalize<T1, T2>(value: Either<T1, T2>) → Either<T1, T2>

circuit

#

Zeroes out the unused side of an Either value. Prevents crafted inputs where both left and right fields carry data from bypassing checks that only inspect the active side.