+++ /dev/null
-//! SPDX-FileCopyrightText: 2026 Chris Duncan <chris@codecow.com>
-//! SPDX-License-Identifier: GPL-3.0-or-later
-
-import { ERROR_UNKNOWN, } from './errors'
-
-/**
- * The module's only import, installed as AssemblyScript's `abort` by
- * `use: ["abort=src/assembly/abort/abort"]` in `asconfig.json`.
- *
- * It takes four integers and no pointers, so the host never reads wasm memory
- * to report an error. The previous handler decoded a UTF-16 string out of
- * linear memory, which is the pointer arithmetic this replaces.
- */
-@external('env', 'abort')
-declare function env_abort (code: i32, line: i32, a: i32, b: i32): void
-
-let errorCode: i32 = ERROR_UNKNOWN
-let detailA: i32 = 0
-let detailB: i32 = 0
-
-/**
- * Throws, reporting `code` and up to two context integers to the host.
- *
- * **Must stay `@inline`.** AssemblyScript fills in the line number at the
- * `throw`, so inlining is what makes the host report the caller's line rather
- * than this file's.
- */
-//@ts-expect-error
-@inline
-export function raise (code: i32, a: i32 = 0, b: i32 = 0): void {
- errorCode = code
- detailA = a
- detailB = b
- throw new Error()
-}
-
-/**
- * Reads the pending code, resets it, and hands it to the host. Resetting
- * *before* the call matters: `env_abort` throws, so nothing after it runs, and
- * a stale code would otherwise be attributed to the next uncoded abort.
- */
-export function abort (message: string | null, fileName: string | null, line: u32, col: u32): void {
- const code = errorCode
- const a = detailA
- const b = detailB
- errorCode = ERROR_UNKNOWN
- detailA = 0
- detailB = 0
- env_abort(code, i32(line), a, b)
-}
import { crypto_derive, } from './crypto_derive'
import { crypto_sign, } from './crypto_sign'
import { crypto_verify_decodepubkey, crypto_verify_donna, crypto_verify_sodium, } from './crypto_verify'
-import { BUFFER_INPUT_MSG, BUFFER_INPUT_PRV, BUFFER_INPUT_PUB, BUFFER_INPUT_SIG, BUFFER_OUTPUT_DERIVE, BUFFER_OUTPUT_SIGN, BUFFER_OUTPUT_VERIFY, ERROR_INDEX_OUT_OF_RANGE, ERROR_BYTE_OUT_OF_RANGE, ERROR_INVALID_BLOCK_COUNT, ERROR_INVALID_MESSAGE_LENGTH, ERROR_INVALID_PUBLIC_KEY, ERROR_SELFTEST_XFAIL_ONE, ERROR_SELFTEST_XFAIL_PAIR, ERROR_SELFTEST_XPASS, ERROR_UNKNOWN, } from './errors'
-import { raise, } from './abort'
+import { raise, } from './env'
+import { BUFFER_INPUT_MSG, BUFFER_INPUT_PRV, BUFFER_INPUT_PUB, BUFFER_INPUT_SIG, BUFFER_OUTPUT_DERIVE, BUFFER_OUTPUT_SIGN, BUFFER_OUTPUT_VERIFY, ERROR_BYTE_OUT_OF_RANGE, ERROR_INDEX_OUT_OF_RANGE, ERROR_INVALID_BLOCK_COUNT, ERROR_INVALID_MESSAGE_LENGTH, ERROR_INVALID_PUBLIC_KEY, ERROR_SELFTEST_XFAIL_ONE, ERROR_SELFTEST_XFAIL_PAIR, ERROR_SELFTEST_XPASS, ERROR_UNKNOWN, } from './errors'
import './tests'
-export { BLOCKHASH_BYTELENGTH, KEY_BYTELENGTH, MAX_MESSAGE_BYTELENGTH, MAX_VERIFY_BLOCKS, MAX_VERIFY_BLOCKS_BYTELENGTH, SIGNATURE_BYTELENGTH }
-export { BUFFER_INPUT_MSG, BUFFER_INPUT_PRV, BUFFER_INPUT_PUB, BUFFER_INPUT_SIG, BUFFER_OUTPUT_DERIVE, BUFFER_OUTPUT_SIGN, BUFFER_OUTPUT_VERIFY }
-export { ERROR_INDEX_OUT_OF_RANGE, ERROR_BYTE_OUT_OF_RANGE, ERROR_INVALID_BLOCK_COUNT, ERROR_INVALID_MESSAGE_LENGTH, ERROR_INVALID_PUBLIC_KEY, ERROR_SELFTEST_XFAIL_ONE, ERROR_SELFTEST_XFAIL_PAIR, ERROR_SELFTEST_XPASS, ERROR_UNKNOWN }
+export { BLOCKHASH_BYTELENGTH, BUFFER_INPUT_MSG, BUFFER_INPUT_PRV, BUFFER_INPUT_PUB, BUFFER_INPUT_SIG, BUFFER_OUTPUT_DERIVE, BUFFER_OUTPUT_SIGN, BUFFER_OUTPUT_VERIFY, ERROR_BYTE_OUT_OF_RANGE, ERROR_INDEX_OUT_OF_RANGE, ERROR_INVALID_BLOCK_COUNT, ERROR_INVALID_MESSAGE_LENGTH, ERROR_INVALID_PUBLIC_KEY, ERROR_SELFTEST_XFAIL_ONE, ERROR_SELFTEST_XFAIL_PAIR, ERROR_SELFTEST_XPASS, ERROR_UNKNOWN, KEY_BYTELENGTH, MAX_MESSAGE_BYTELENGTH, MAX_VERIFY_BLOCKS, MAX_VERIFY_BLOCKS_BYTELENGTH, SIGNATURE_BYTELENGTH }
// Static I/O buffers
const INPUT_MSG = new StaticArray<u8>(MAX_MESSAGE_BYTELENGTH)
//! SPDX-FileCopyrightText: 2026 Chris Duncan <chris@codecow.com>
//! SPDX-License-Identifier: GPL-3.0-or-later
-import { raise, } from './abort'
import { KEY_BYTELENGTH } from './constants'
+import { raise, } from './env'
import { ERROR_SELFTEST_XFAIL_ONE, ERROR_SELFTEST_XFAIL_PAIR, ERROR_SELFTEST_XPASS, } from './errors'
import { equalbytes } from './utils'