From: Chris Duncan Date: Fri, 4 Jul 2025 08:02:35 +0000 (-0700) Subject: Update all "secret key" references to "private key" for consistency. X-Git-Tag: v0.10.5~121 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=5f0e5cad9aa30a6706fc1a589dd29f8d829cfb0f;p=libnemo.git Update all "secret key" references to "private key" for consistency. --- diff --git a/src/lib/block.ts b/src/lib/block.ts index e1af35f..997f930 100644 --- a/src/lib/block.ts +++ b/src/lib/block.ts @@ -144,7 +144,7 @@ abstract class Block { const result = (await Block.#pool.assign({ method: 'detached', msg: hex.toArray(this.hash), - secretKey: hex.toArray(`${account.privateKey}`) + privateKey: hex.toArray(`${account.privateKey}`) }))[0] this.signature = result.signature } catch (err) { diff --git a/src/lib/workers/nano-nacl.ts b/src/lib/workers/nano-nacl.ts index 465c9b2..834d374 100644 --- a/src/lib/workers/nano-nacl.ts +++ b/src/lib/workers/nano-nacl.ts @@ -29,7 +29,7 @@ export class NanoNaCl extends WorkerInterface { try { switch (d.method) { case 'detached': { - d.signature = await this.detached(Uint8Array.from(d.msg), Uint8Array.from(d.secretKey)) + d.signature = await this.detached(Uint8Array.from(d.msg), Uint8Array.from(d.privateKey)) break } case 'convert': { @@ -494,7 +494,7 @@ export class NanoNaCl extends WorkerInterface { static crypto_sign_BYTES: 64 = 64 static crypto_sign_PUBLICKEYBYTES: 32 = 32 - static crypto_sign_SECRETKEYBYTES: 32 = 32 + static crypto_sign_PRIVATEKEYBYTES: 32 = 32 static crypto_sign_SEEDBYTES: 32 = 32 /* High-level API */ @@ -526,14 +526,14 @@ export class NanoNaCl extends WorkerInterface { return str } - static sign (msg: Uint8Array, secretKey: Uint8Array): Uint8Array { - this.checkArrayTypes(msg, secretKey) - if (secretKey.byteLength !== this.crypto_sign_SECRETKEYBYTES) { - throw new Error(`expected key size ${this.crypto_sign_SECRETKEYBYTES} bytes; actual key size ${secretKey.byteLength} bytes`) + static sign (msg: Uint8Array, privateKey: Uint8Array): Uint8Array { + this.checkArrayTypes(msg, privateKey) + if (privateKey.byteLength !== this.crypto_sign_PRIVATEKEYBYTES) { + throw new Error(`expected key size ${this.crypto_sign_PRIVATEKEYBYTES} bytes; actual key size ${privateKey.byteLength} bytes`) } const signedMsg = new Uint8Array(this.crypto_sign_BYTES + msg.length) - const publicKey = this.parseHex(this.convert(secretKey)) - this.crypto_sign(signedMsg, msg, msg.length, secretKey, publicKey) + const publicKey = this.parseHex(this.convert(privateKey)) + this.crypto_sign(signedMsg, msg, msg.length, privateKey, publicKey) return signedMsg } @@ -554,8 +554,8 @@ export class NanoNaCl extends WorkerInterface { return m } - static detached (msg: Uint8Array, secretKey: Uint8Array): string { - const signedMsg = this.sign(msg, secretKey) + static detached (msg: Uint8Array, privateKey: Uint8Array): string { + const signedMsg = this.sign(msg, privateKey) const sig = new Uint8Array(this.crypto_sign_BYTES) for (let i = 0; i < sig.length; i++) { sig[i] = signedMsg[i]