]> git.codecow.com Git - nano25519.git/commitdiff
Rename env import overrides.
authorChris Duncan <chris@zoso.dev>
Wed, 23 Sep 2026 21:26:06 +0000 (14:26 -0700)
committerChris Duncan <chris@zoso.dev>
Wed, 23 Sep 2026 21:26:06 +0000 (14:26 -0700)
asconfig.json
src/assembly/abort.ts [deleted file]
src/assembly/index.ts
src/assembly/tests.ts

index 480f0cbf68f8c5f06fdc5861a0d77f581cdd7af5..ec0034c5a58037b2d108801c79f796c386439f73 100644 (file)
@@ -23,7 +23,7 @@
                ],
                "noColors": true,
                "use": [
-                       "abort=src/assembly/abort/abort"
+                       "abort=src/assembly/env/abort"
                ]
        }
-}
\ No newline at end of file
+}
diff --git a/src/assembly/abort.ts b/src/assembly/abort.ts
deleted file mode 100644 (file)
index dd9a3da..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-//! 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)
-}
index a51f8638add9e65445b581c2dd4db6b058a55438..74ad5b93ba42bb590097d4c9b91a4dfb030145d8 100644 (file)
@@ -5,13 +5,11 @@ import { BLOCKHASH_BYTELENGTH, KEY_BYTELENGTH, MAX_MESSAGE_BYTELENGTH, MAX_VERIF
 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)
index ed4d5120d3bfee828dc838f9d746e00de16b565e..bf3c13af418598139ed4e610ad450668ac6f44a5 100644 (file)
@@ -1,8 +1,8 @@
 //! 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'