signMessage
Signs a message or some arbitrary bytes.
Usage
- main.ts
import { voi } from '@kibisis/chains';
import { createKatavault, utf8ToBytes } from '@kibisis/katavault-core';
import { verifyBytes } from 'algosdk';
const address = 'SH2KEL633QIJLURBOOJTIKR5EIIYR4A2VYZC2DB6ZD4ZZL6XHYFBETEOGU';
const katavault = await createKatavault({
chains: [voi],
});
const message = 'hello humie!';
let signature: Uint8Array;
await katavault.authenticateWithPasskey({
user: {
name: 'Kibi',
username: 'kibi@kibis.is',
},
});
signature = await katavault.signMessage({
address,
message,
});
console.log('verified:', verifyBytes(utf8ToBytes(message), signature, address)));
/*
verified: true
*/
Parameters
params
- Type:
SignMessageParameters
The signer, the message and optional output encoding.
Returns
Promise<string | Uint8Array>
A promise that resolves to the signature of the signed message.
If the encoding parameter was specified, the signature will be encoded in that format, otherwise the signature will be in raw bytes.
note
The signed message is prepended with "MX" for domain separation.
Throws
AccountDoesNotExistError
If the specified address does not exist in the wallet.
NotAuthenticatedError
If the provider has not been authenticated.