\r
this.Square(chk, r[0])\r
this.Multiply(chk, chk, den)\r
- if (this.neq25519(chk, num)) {\r
- this.Multiply(r[0], r[0], this.I)\r
- }\r
+ this.Multiply(this.neq25519(chk, num) ? r[0] : new Float64Array(16), r[0], this.I)\r
\r
this.Square(chk, r[0])\r
this.Multiply(chk, chk, den)\r
\r
- if (this.neq25519(chk, num)) return -1\r
+ const result = this.neq25519(chk, num) ? -1 : 0\r
\r
- if (this.par25519(r[0]) === (p[31] >> 7)) {\r
- this.Subtract(r[0], new Float64Array(16), r[0])\r
- }\r
+ this.Subtract(this.par25519(r[0]) === (p[31] >> 7) ? r[0] : new Float64Array(16), new Float64Array(16), r[0])\r
this.Multiply(r[3], r[0], r[1])\r
- return 0\r
+ return result\r
}\r
\r
static crypto_sign (sm: Uint8Array, m: Uint8Array, n: number, sk: Uint8Array, pk: Uint8Array): void {\r
static open (signedMessage: Uint8Array<ArrayBuffer>, publicKey: Uint8Array<ArrayBuffer>): Uint8Array<ArrayBuffer>\r
static open (signedMessage: unknown, publicKey: unknown): Uint8Array<ArrayBuffer> {\r
try {\r
- if (!(signedMessage instanceof Uint8Array)) {\r
+ if (!(signedMessage instanceof Uint8Array) || signedMessage.byteLength < this.crypto_sign_BYTES) {\r
throw new TypeError('Signed message must be Uint8Array')\r
}\r
if (!(publicKey instanceof Uint8Array) || publicKey.byteLength !== this.crypto_sign_PUBLICKEYBYTES) {\r