Skip to content
Lattice

HASSignatureVerifierLib

Git Source

Title: HASSignatureVerifierLib

Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from hiero-ledger/hiero-contracts (https://github.com/hiero-ledger/hiero-contracts)

Stateless wrapper around HAS isAuthorizedRaw / isAuthorized, shaped like SignatureChecker: a view that returns false instead of bubbling the system contract's reverts. Plugs into AccountSignerLib.isValidSignatureNow as the HederaAccount signer type.

Both HAS functions are view-classified by the network, so staticcall is valid. Gas is the ecrecover precompile cost (3,000) per simple key. The raw path rejects key lists / threshold keys by reverting — use isAuthorized with a protobuf SignatureMap for those.

Functions

__HASSignatureVerifier_init

Registers the IHASSignatureVerifier ERC-165 interface.

Must be called between preInitializer / postInitializer.

function __HASSignatureVerifier_init() internal;

registerInterface

Writes true to the ERC-165 map slot for IHASSignatureVerifier.

function registerInterface() internal;

isAuthorizedRaw

True if signature is valid over messageHash for account's simple key; false otherwise (including every system-contract revert).

function isAuthorizedRaw(address account, bytes32 messageHash, bytes memory signature)
        internal
        view
        returns (bool authorized);

Parameters

NameTypeDescription
accountaddress
messageHashbytes32
signaturebytes

Returns

NameTypeDescription
authorizedbool

isAvailable

True when the HAS system contract is actually live on this chain and answering.

Used to REFUSE arming a Hedera signer on a chain that cannot verify one. The check is a capability probe, deliberately not a chain-id allowlist: an allowlist goes stale (previewnet, a Solo local network, any future Hedera chain id) and would have to be edited to stay correct, whereas this asks the system contract itself.

Why returndata LENGTH is the signal, not the boolean: calling an address with no code SUCCEEDS on the EVM and yields EMPTY returndata, so ok alone cannot tell a live HAS from a bare chain. A live HAS answers isAuthorizedRaw with one 32-byte word whatever the verdict. The probe therefore uses a well-formed 65-byte (ECDSA-shaped) blob — HAS reverts on a malformed length, which would make a live chain look dead — and only asks whether a word came back, never what it said.

function isAvailable() internal view returns (bool available);

Returns

NameTypeDescription
availablebool

isAuthorized

True if signatureMap satisfies account's key structure over message; false otherwise.

function isAuthorized(address account, bytes memory message, bytes memory signatureMap)
        internal
        view
        returns (bool authorized);

Parameters

NameTypeDescription
accountaddress
messagebytes
signatureMapbytes

Returns

NameTypeDescription
authorizedbool