Sign Message
Sign a message
const response = await aptos.signMessage({
message: "Hello world",
nonce: "foo", // a unique identifier for the request
})
const { signature } = response // an array of signatures of the multi-sig accountVerify signatures
// a 4-byte (32 bits) bit-vector of length N
const { bitmap } = response
const input = new Uint8Array(bitmap)
// Getting an array which marks the keys signing the message with 1, while marking 0 for the keys not being used.
const bits = Array.from(input).flatMap((n) =>
Array.from({ length: 8 }).map((_, i) => (n >> i) & 1)
)
// Filter out indexes of the keys we need
const index = bits.map((_, i) => i).filter((i) => bits[i])
const { publicAccount: { publicKey } } = bloctoSDK.aptos
// The filter result is an array of the keys which we need for verifying the signatures
const publicKeys = publicKey.filter((_: string, i: number) => index.includes(i))Demo
Last updated
Was this helpful?