How to use the exonum-client.sign function in exonum-client

To help you get started, we’ve selected a few exonum-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github exonum / exonum-java-binding / exonum-java-binding-cryptocurrency-demo / frontend / src / plugins / blockchain.js View on Github external
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))
}