try {
const signature = NanoNaCl.detached(
hex.toBytes(await this.hash()),
- hex.toBytes(`${account.privateKey}${account.publicKey}`)
+ hex.toBytes(`${account.privateKey}`)
)
this.signature = signature
} catch (err) {
}\r
\r
// Note: difference from C - smlen returned, not passed as argument.\r
- function crypto_sign (sm: Uint8Array, m: Uint8Array, n: number, sk: Uint8Array): number {\r
+ function crypto_sign (sm: Uint8Array, m: Uint8Array, n: number, sk: Uint8Array, pk: Uint8Array): number {\r
const d = new Uint8Array(64)\r
const h = new Uint8Array(64)\r
const r = new Uint8Array(64)\r
scalarbase(p, r)\r
pack(sm, p)\r
\r
- for (let i = 32; i < 64; i++) sm[i] = sk[i]\r
+ for (let i = 0; i < 32; i++) sm[i + 32] = pk[i]\r
crypto_hash(h, sm, n + 64)\r
reduce(h)\r
\r
\r
const crypto_sign_BYTES = 64\r
const crypto_sign_PUBLICKEYBYTES = 32\r
- const crypto_sign_SECRETKEYBYTES = 64\r
+ const crypto_sign_SECRETKEYBYTES = 32\r
const crypto_sign_SEEDBYTES = 32\r
\r
/* High-level API */\r
if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\r
throw new Error('bad secret key size')\r
var signedMsg = new Uint8Array(crypto_sign_BYTES + msg.length)\r
- crypto_sign(signedMsg, msg, msg.length, secretKey)\r
+ const publicKey = parseHex(convert(secretKey))\r
+ crypto_sign(signedMsg, msg, msg.length, secretKey, publicKey)\r
return signedMsg\r
}\r
\r
export async function sign (key: string, ...input: string[]): Promise<string> {
const account = await Account.fromPrivateKey(key)
const data = hash(input)
- return NanoNaCl.detached(
+ const signature = NanoNaCl.detached(
hex.toBytes(data),
- hex.toBytes(`${account.privateKey}${account.publicKey}`))
+ hex.toBytes(`${account.privateKey}`))
+ return signature
}
/**