import { KEY_BYTELENGTH } from '.'
import { Blake2b } from './blake2b'
import { crypto_derive } from './crypto_derive'
+import { errors } from './errors'
import { ge_scalarmult_base_tobytes } from './ge'
import { sc_muladd, sc_reduce } from './sc'
import { clamp } from './utils'
for (let i = 0; i < KEY_BYTELENGTH; i++) {
c |= A[i] ^ pub[i]
}
- if (c != 0) return -1
+ if (c != 0) return 1
// Hash private key to `h`
blake2b.init().update(prv, KEY_BYTELENGTH).digest(h)
--- /dev/null
+//! SPDX-FileCopyrightText: 2026 Chris Duncan <chris@codecow.com>
+//! SPDX-License-Identifier: GPL-3.0-or-later
+
+export const errors = [
+ null,
+ 'Invalid public key',
+ 'Invalid message length',
+ 'Invalid block count'
+]
\ No newline at end of file
import { crypto_derive } from './crypto_derive'
import { crypto_sign } from './crypto_sign'
import { crypto_verify_decodepubkey, crypto_verify_relaxed, crypto_verify_strict } from './crypto_verify'
+import { errors } from './errors'
export const BLOCKHASH_BYTELENGTH: i32 = 32
export const KEY_BYTELENGTH: i32 = 32
INPUT_PRV.fill(0)
INPUT_PUB.fill(0)
INPUT_MSG.fill(0)
- throw new Error('Invalid message length')
+ throw new Error(errors[2])
}
// Copy input buffers to local parameters, then clear input buffer
// Clear signature output buffer if signing failed
if (result != 0) {
OUTPUT_SIGN.fill(0)
- throw new Error('Failed to sign, check keypair and message are valid')
+ throw new Error(errors[result])
}
}
if (mlen < 0 || mlen > MAX_MESSAGE_BYTELENGTH) {
INPUT_MSG.fill(0)
INPUT_PUB.fill(0)
- throw new Error('Invalid message length')
+ throw new Error(errors[2])
}
// Copy input buffer to local parameters, then clear input buffer
if (count < 1 || MAX_VERIFY_BLOCKS < count) {
INPUT_MSG.fill(0)
INPUT_PUB.fill(0)
- throw new Error('Invalid block count')
+ throw new Error(errors[3])
}
// Copy public key input buffer to local parameter, then clear input buffer