Skip to content

Instantly share code, notes, and snippets.

@jkyberneees
Last active September 5, 2018 09:11
Show Gist options
  • Select an option

  • Save jkyberneees/2c31d9f8ba2e9071ced890d34a76c39b to your computer and use it in GitHub Desktop.

Select an option

Save jkyberneees/2c31d9f8ba2e9071ced890d34a76c39b to your computer and use it in GitHub Desktop.
// Alice precomputes shared key with Bob (one time)
const sharedKey = nacl.box.before(bob.publicKey, alice.secretKey)
const message // <-- message object from Bob side
const payload = nacl.box.open.after(
message.box,
message.nonce,
sharedKey // <-- using shared key
)
// assert.equal('Hello Alice', nacl.util.encodeUTF8(payload))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment