Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const buildMessage = (header, body, keyPair) => {
const unsignedMessage = appendBuffer(new Uint8Array(header), body)
// calculate payload and insert it into buffer
Exonum.Uint32.serialize(unsignedMessage.length + SIGNATURE_LENGTH, unsignedMessage, PAYLOAD_SIZE_OFFSET)
// calculate signature
const signature = Exonum.sign(keyPair.secretKey, unsignedMessage)
// append signature to the message
return appendBuffer(unsignedMessage, Exonum.hexadecimalToUint8Array(signature))
}