From: Chris Duncan Date: Sat, 15 Aug 2026 07:57:59 +0000 (-0700) Subject: Remove extraneous tests. X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=58aa37c5d125993b9a70c8794bb3ebb38bd41cd3;p=nano25519.git Remove extraneous tests. --- diff --git a/test.mjs b/test.mjs index b4b5158..7c55e09 100644 --- a/test.mjs +++ b/test.mjs @@ -342,40 +342,30 @@ failures += +!test // Check sync imports with byte inputs and preallocated output buffer outbuf = new Uint8Array(32) -result = derive(NANO_ORG_VECTOR.privateKeyBytes, outbuf) -test = overlaps(result, outbuf) -test &&= [...result].map(b => b.toString(16).padStart(2, '0')).join('').toLowerCase() === NANO_ORG_VECTOR.publicKey.toLowerCase() +derive(NANO_ORG_VECTOR.privateKeyBytes, outbuf) test &&= [...outbuf].map(b => b.toString(16).padStart(2, '0')).join('').toLowerCase() === NANO_ORG_VECTOR.publicKey.toLowerCase() check(`derive from private key bytes ${NANO_ORG_VECTOR.privateKey} and allocate result to output buffer`, test) passes += +test failures += +!test outbuf = new Uint8Array(64) -result = sign(NANO_ORG_VECTOR.blockHashBytes, NANO_ORG_VECTOR.secretKeyBytes, outbuf) -test = overlaps(result, outbuf) -test &&= [...result].map(b => b.toString(16).padStart(2, '0')).join('').toLowerCase() === NANO_ORG_VECTOR.signature.toLowerCase() +sign(NANO_ORG_VECTOR.blockHashBytes, NANO_ORG_VECTOR.secretKeyBytes, outbuf) test &&= [...outbuf].map(b => b.toString(16).padStart(2, '0')).join('').toLowerCase() === NANO_ORG_VECTOR.signature.toLowerCase() check(`sign message bytes ${NANO_ORG_VECTOR.blockHash} and allocate result to output buffer`, test) passes += +test failures += +!test outbuf = new Uint8Array(new ArrayBuffer(96), 0, 32) -result = derive(NANO_ORG_VECTOR.privateKeyBytes, outbuf) -test = overlaps(result, outbuf) -test &&= [...result].map(b => b.toString(16).padStart(2, '0')).join('').toLowerCase() === NANO_ORG_VECTOR.publicKey.toLowerCase() +derive(NANO_ORG_VECTOR.privateKeyBytes, outbuf) test &&= [...outbuf].map(b => b.toString(16).padStart(2, '0')).join('').toLowerCase() === NANO_ORG_VECTOR.publicKey.toLowerCase() -test &&= [...new Uint8Array(result.buffer)].map(b => b.toString(16).padStart(2, '0')).join('').toLowerCase() !== NANO_ORG_VECTOR.publicKey.toLowerCase() test &&= [...new Uint8Array(outbuf.buffer)].map(b => b.toString(16).padStart(2, '0')).join('').toLowerCase() !== NANO_ORG_VECTOR.publicKey.toLowerCase() check(`derive from private key bytes ${NANO_ORG_VECTOR.privateKey} and allocate result to output buffer`, test) passes += +test failures += +!test outbuf = new Uint8Array(new ArrayBuffer(96), 0, 64) -result = sign(NANO_ORG_VECTOR.blockHashBytes, NANO_ORG_VECTOR.secretKeyBytes, outbuf) -test = overlaps(result, outbuf) -test &&= [...result].map(b => b.toString(16).padStart(2, '0')).join('').toLowerCase() === NANO_ORG_VECTOR.signature.toLowerCase() +sign(NANO_ORG_VECTOR.blockHashBytes, NANO_ORG_VECTOR.secretKeyBytes, outbuf) test &&= [...outbuf].map(b => b.toString(16).padStart(2, '0')).join('').toLowerCase() === NANO_ORG_VECTOR.signature.toLowerCase() -test &&= [...new Uint8Array(result.buffer)].map(b => b.toString(16).padStart(2, '0')).join('').toLowerCase() !== NANO_ORG_VECTOR.publicKey.toLowerCase() test &&= [...new Uint8Array(outbuf.buffer)].map(b => b.toString(16).padStart(2, '0')).join('').toLowerCase() !== NANO_ORG_VECTOR.publicKey.toLowerCase() check(`sign message bytes ${NANO_ORG_VECTOR.blockHash} and allocate result to output buffer`, test) passes += +test @@ -384,11 +374,8 @@ failures += +!test // Check sync imports with byte inputs and offset output buffer length = 33 + crypto.getRandomValues(new Uint8Array(1))[0] outbuf = new Uint8Array(new ArrayBuffer(length), length - 32, 32) -result = derive(NANO_ORG_VECTOR.privateKeyBytes, outbuf) -test = overlaps(result, outbuf) -test &&= [...result].map(b => b.toString(16).padStart(2, '0')).join('').toLowerCase() === NANO_ORG_VECTOR.publicKey.toLowerCase() +derive(NANO_ORG_VECTOR.privateKeyBytes, outbuf) test &&= [...outbuf].map(b => b.toString(16).padStart(2, '0')).join('').toLowerCase() === NANO_ORG_VECTOR.publicKey.toLowerCase() -test &&= [...new Uint8Array(result.buffer)].map(b => b.toString(16).padStart(2, '0')).join('').toLowerCase() !== NANO_ORG_VECTOR.publicKey.toLowerCase() test &&= [...new Uint8Array(outbuf.buffer)].map(b => b.toString(16).padStart(2, '0')).join('').toLowerCase() !== NANO_ORG_VECTOR.publicKey.toLowerCase() check(`derive from private key bytes ${NANO_ORG_VECTOR.privateKey} to offset outbuf`, test) passes += +test @@ -396,11 +383,8 @@ failures += +!test length = 65 + crypto.getRandomValues(new Uint8Array(1))[0] outbuf = new Uint8Array(new ArrayBuffer(length), length - 64, 64) -result = sign(NANO_ORG_VECTOR.blockHashBytes, NANO_ORG_VECTOR.secretKeyBytes, outbuf) -test = overlaps(result, outbuf) -test &&= [...result].map(b => b.toString(16).padStart(2, '0')).join('').toLowerCase() === NANO_ORG_VECTOR.signature.toLowerCase() +sign(NANO_ORG_VECTOR.blockHashBytes, NANO_ORG_VECTOR.secretKeyBytes, outbuf) test &&= [...outbuf].map(b => b.toString(16).padStart(2, '0')).join('').toLowerCase() === NANO_ORG_VECTOR.signature.toLowerCase() -test &&= [...new Uint8Array(result.buffer)].map(b => b.toString(16).padStart(2, '0')).join('').toLowerCase() !== NANO_ORG_VECTOR.publicKey.toLowerCase() test &&= [...new Uint8Array(outbuf.buffer)].map(b => b.toString(16).padStart(2, '0')).join('').toLowerCase() !== NANO_ORG_VECTOR.publicKey.toLowerCase() check(`sign message bytes ${NANO_ORG_VECTOR.blockHash} to offset outbuf`, test) passes += +test