computeSignerGrantHash
Computes the 32-byte hash that a signer key signs for a signer-key grant. It equals pox-5 get-signer-grant-message-hash for the same signer-manager, authId and chain.
Usage
import { computeSignerGrantHash } from '@stacks/bitcoin-staking';
import { bytesToHex } from '@stacks/common';
const hash = computeSignerGrantHash({
signerManager: 'SP2C2YFP12AJZB4MABJBAJ55XECVS7E4PMMZ89YZR.my-signer-manager',
authId: 1n,
chainId: 1,
});
bytesToHex(hash); // '33b15ac6e3b6a588de6e4e6860d88802e17decabf8ef0c3efc03f8d250fb47e5'Notes
The hash is
sha256("SIP018" || sha256(domain) || sha256(message))over the Clarity-serialized tuples from buildSignerGrantMessage, as in pox-5 (pox-5.clar L2865-L2877).Compare it with the node's result from fetchSignerGrantMessageHash, which calls the read-only function.
Signature
opts is a SignerKeyGrantOptions.
Returns
Uint8Array
The 32-byte SHA-256 hash.
Parameters
opts.signerManager (required)
Type:
string
Stacks principal of the signer-manager being authorized.
opts.authId (required)
Type:
IntegerType
Replay nonce of the grant.
opts.chainId (required)
Type:
number
Chain ID of the network the grant is for: 1 on mainnet, 0x80000000 on testnet.
Was this helpful?