hirosystems / stacks.js

JavaScript libraries for identity, auth, storage and transactions on the Stacks blockchain.
https://stacks.js.org
MIT License
944 stars 307 forks source link

Feature request: stacking helper function for `verify-signer-key-sig` #1673

Closed hstove closed 2 months ago

hstove commented 2 months ago

Problem

When a client wants to verify a Stacking payload, they can validate the signature by re-generating the PoX-4 message hash. This works for users that include a signer-signature, but that param is optional. When the signature is omitted, the pox-4 contract checks the signer-key-authorization map to ensure that an authorization was previously set.

There's a helper read-only function in pox-4 verify-signer-key-sig which essentially does both of these things (either verify the signature or verify that an authorization exists). It would be nice to expose this read-only function in the Stacking library, so that clients can validate a payload before submitting a transaction.

Solution

Add a verifySignerKey() (or similarly named) function that calls the read-only function verify-signer-key-sig.