// 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
// 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
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