TweetNaCl TypeError: unexpected type, use Uint8Array

1.9k Views Asked by At

I have a problem when trying to use sign function from TweetNaCl. It always throws error unexpected type, use Uint8Array.

const nacl = require('tweetnacl')
nacl.util = require('tweetnacl-util')

const b = nacl.sign.keyPair()
// console.log(b.secretKey) the result is already in Uint8Array form

const c = b.secretKey

const sign= nacl.sign("message", c)
//error unexpected type, use Uint8Array
nacl.sign.keyPair()

wil return an object containing secretkey and publickey .. but when trying to sign

nacl.sign("message", privatekey)

error is trown

Anyone knows how to overcome this? thank you :)

0

There are 0 best solutions below