From: Chris Duncan Date: Thu, 4 Dec 2025 22:44:27 +0000 (-0800) Subject: Abbreviate public key and secret key. X-Git-Tag: v0.11.0~6^2~43 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=8d3f57a342114aa4d7854fef451e16c3a886ea7e;p=libnemo.git Abbreviate public key and secret key. --- diff --git a/src/lib/crypto/secp256k1.ts b/src/lib/crypto/secp256k1.ts index cb0210e..9857760 100644 --- a/src/lib/crypto/secp256k1.ts +++ b/src/lib/crypto/secp256k1.ts @@ -66,7 +66,7 @@ export class Secp256k1 { static L: 32 = 32 // field / group byte length static L2: 64 = 64 - static publicKeyLength: Secp256k1Lengths = { + static pkLength: Secp256k1Lengths = { compressed: 33, uncompressed: 65 } @@ -279,7 +279,7 @@ export class Secp256k1 { const tail = bytes.subarray(1) const x = this.bytesToBigint(tail.subarray(0, this.L)) // No actual validation is done here: use .assertValidity() - if (length === this.publicKeyLength.compressed && (head === 0x02 || head === 0x03)) { + if (length === this.pkLength.compressed && (head === 0x02 || head === 0x03)) { // Equation is y² == x³ + ax + b. We calculate y from x. // y = √y²; there are two solutions: y, -y. Determine proper solution based on prefix let y = this.lift_x(x) @@ -289,7 +289,7 @@ export class Secp256k1 { p = this.Point(x, y, 1n) } // Uncompressed 65-byte point, 0x04 prefix - if (length === this.publicKeyLength.uncompressed && head === 0x04) p = this.Point(x, this.bytesToBigint(tail.subarray(this.L, this.L2)), 1n) + if (length === this.pkLength.uncompressed && head === 0x04) p = this.Point(x, this.bytesToBigint(tail.subarray(this.L, this.L2)), 1n) // Validate point return p ? p.assertValidity() : this.err('bad point: not on curve') } @@ -318,22 +318,22 @@ export class Secp256k1 { } /** Normalize private key to scalar (bigint). Verifies scalar is in range 1