failures += +!test
try {
- result = sign(NANO_ORG_VECTOR.blockHash + '0', NANO_ORG_VECTOR.secretKey)
+ result = sign(NANO_ORG_VECTOR.blockHash + '0', NANO_ORG_VECTOR.privateKey, NANO_ORG_VECTOR.publicKey)
result = false
} catch (err) {
if (err != null && typeof err === 'object' && 'message' in err) {
failures += +!test
try {
- result = sign('1'.repeat(65538), NANO_ORG_VECTOR.secretKey)
+ result = sign('1'.repeat(65538), NANO_ORG_VECTOR.privateKey, NANO_ORG_VECTOR.publicKey)
result = false
} catch (err) {
if (err != null && typeof err === 'object' && 'message' in err) {
failures += +!test
try {
- result = sign(NANO_ORG_VECTOR.blockHash + '0', NANO_ORG_VECTOR.secretKey)
+ result = sign(NANO_ORG_VECTOR.blockHash + '0', NANO_ORG_VECTOR.privateKey, NANO_ORG_VECTOR.publicKey)
result = false
} catch (err) {
if (err != null && typeof err === 'object' && 'message' in err) {
failures += +!test
try {
- result = sign('1'.repeat(65538), NANO_ORG_VECTOR.secretKey)
+ result = sign('1'.repeat(65538), NANO_ORG_VECTOR.privateKey, NANO_ORG_VECTOR.publicKey)
result = false
} catch (err) {
if (err != null && typeof err === 'object' && 'message' in err) {
try {
outbuf = new Uint8Array(65)
- result = sign(NANO_ORG_VECTOR.blockHashBytes, NANO_ORG_VECTOR.secretKeyBytes, outbuf)
+ result = sign(NANO_ORG_VECTOR.blockHashBytes, NANO_ORG_VECTOR.privateKeyBytes, NANO_ORG_VECTOR.publicKeyBytes, outbuf)
result = false
} catch (err) {
if (err != null && typeof err === 'object' && 'message' in err) {
passes += +test
failures += +!test
-// Check sync imports with string inputs
+// Check string inputs
result = derive(NANO_ORG_VECTOR.privateKey)
test = result.toLowerCase() === NANO_ORG_VECTOR.publicKey.toLowerCase()
check(`derive from private key string ${NANO_ORG_VECTOR.privateKey}`, test)
passes += +test
failures += +!test
-result = sign(NANO_ORG_VECTOR.blockHash, NANO_ORG_VECTOR.secretKey)
+result = sign(NANO_ORG_VECTOR.blockHash, NANO_ORG_VECTOR.privateKey, NANO_ORG_VECTOR.publicKey)
test = result.toLowerCase() === NANO_ORG_VECTOR.signature.toLowerCase()
check(`sign message string ${NANO_ORG_VECTOR.blockHash}`, test)
passes += +test
passes += +test
failures += +!test
-// Check sync imports with byte inputs
+// Check byte inputs
result = derive(NANO_ORG_VECTOR.privateKeyBytes)
test = [...result].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}`, test)
passes += +test
failures += +!test
-result = sign(NANO_ORG_VECTOR.blockHashBytes, NANO_ORG_VECTOR.secretKeyBytes)
+result = sign(NANO_ORG_VECTOR.blockHashBytes, NANO_ORG_VECTOR.privateKeyBytes, NANO_ORG_VECTOR.publicKeyBytes)
test = [...result].map(b => b.toString(16).padStart(2, '0')).join('').toLowerCase() === NANO_ORG_VECTOR.signature.toLowerCase()
check(`sign message bytes ${NANO_ORG_VECTOR.blockHash}`, test)
passes += +test
passes += +test
failures += +!test
-// Check sync imports with byte inputs and preallocated output buffer
+// Check byte inputs and preallocated output buffer
inbuf = new Uint8Array(bigBuf.buffer.slice(), 0, 32)
inbuf.set(NANO_ORG_VECTOR.privateKeyBytes)
outbuf = new Uint8Array(32)
passes += +test
failures += +!test
-inbuf = new Uint8Array(bigBuf.buffer.slice(), 0, 64)
-inbuf.set(NANO_ORG_VECTOR.secretKeyBytes)
+inbuf = new Uint8Array(bigBuf.buffer.slice(), 0, 32)
+inbuf.set(NANO_ORG_VECTOR.privateKeyBytes)
outbuf = new Uint8Array(64)
-sign(NANO_ORG_VECTOR.blockHashBytes, inbuf, outbuf)
+sign(NANO_ORG_VECTOR.blockHashBytes, inbuf, NANO_ORG_VECTOR.publicKeyBytes, 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
passes += +test
failures += +!test
-inbuf = new Uint8Array(bigBuf.buffer.slice(), 1, 64)
-inbuf.set(NANO_ORG_VECTOR.secretKeyBytes)
+inbuf = new Uint8Array(bigBuf.buffer.slice(), 1, 32)
+inbuf.set(NANO_ORG_VECTOR.privateKeyBytes)
outbuf = new Uint8Array(bigBuf.buffer.slice(), 0, 64)
-sign(NANO_ORG_VECTOR.blockHashBytes, inbuf, outbuf)
+sign(NANO_ORG_VECTOR.blockHashBytes, inbuf, NANO_ORG_VECTOR.publicKeyBytes, outbuf)
test = [...outbuf].map(b => b.toString(16).padStart(2, '0')).join('').toLowerCase() === NANO_ORG_VECTOR.signature.toLowerCase()
test &&= [...new Uint8Array(outbuf.buffer, 0, 64)].map(b => b.toString(16).padStart(2, '0')).join('').toLowerCase() === NANO_ORG_VECTOR.signature.toLowerCase()
test &&= [...new Uint8Array(outbuf.buffer, 64, 64)].map(b => b.toString(16).padStart(2, '0')).join('').toLowerCase() === 'ff'.repeat(64)
passes += +test
failures += +!test
-// Check sync imports with byte inputs and offset output buffer
+// Check byte inputs and offset output buffer
outbuf = new Uint8Array(new ArrayBuffer(128), 32, 32)
derive(NANO_ORG_VECTOR.privateKeyBytes, outbuf)
test = [...outbuf].map(b => b.toString(16).padStart(2, '0')).join('').toLowerCase() === NANO_ORG_VECTOR.publicKey.toLowerCase()
failures += +!test
outbuf = new Uint8Array(new ArrayBuffer(128), 64, 64)
-sign(NANO_ORG_VECTOR.blockHashBytes, NANO_ORG_VECTOR.secretKeyBytes, outbuf)
+sign(NANO_ORG_VECTOR.blockHashBytes, NANO_ORG_VECTOR.privateKeyBytes, NANO_ORG_VECTOR.publicKeyBytes, outbuf)
test = [...outbuf].map(b => b.toString(16).padStart(2, '0')).join('').toLowerCase() === NANO_ORG_VECTOR.signature.toLowerCase()
test &&= [...new Uint8Array(outbuf.buffer, 0, 64)].map(b => b.toString(16).padStart(2, '0')).join('').toLowerCase() === '00'.repeat(64)
test &&= [...new Uint8Array(outbuf.buffer, 64, 64)].map(b => b.toString(16).padStart(2, '0')).join('').toLowerCase() === NANO_ORG_VECTOR.signature.toLowerCase()
passes += +test
failures += +!test
- result = sign(message, privateKey + publicKey)
+ result = sign(message, privateKey, publicKey)
test = result.toLowerCase() === signature.slice(0, 128)
check(`sign message string ${message}`, test)
passes += +test
const privateKeyBytes = new Uint8Array(privateKey.match(/.{2}/g)?.map(b => parseInt(b, 16)) ?? [])
const publicKeyBytes = new Uint8Array(publicKey.match(/.{2}/g)?.map(b => parseInt(b, 16)) ?? [])
- const secretKeyBytes = new Uint8Array([...privateKeyBytes, ...publicKeyBytes])
const messageBytes = new Uint8Array(message.match(/.{2}/g)?.map(b => parseInt(b, 16)) ?? [])
const signatureBytes = new Uint8Array(signature.match(/.{2}/g)?.slice(0, 64).map(b => parseInt(b, 16)) ?? [])
passes += +test
failures += +!test
- result = sign(messageBytes, secretKeyBytes)
+ result = sign(messageBytes, privateKeyBytes, publicKeyBytes)
test = [...result].map(b => b.toString(16).padStart(2, '0')).join('').toLowerCase() === signature.slice(0, 128)
check(`sign message bytes ${message}`, test)
passes += +test