]> git.codecow.com Git - nano25519.git/commitdiff
Fix verify_blocks output and truncate byte accessors description header.
authorChris Duncan <chris@codecow.com>
Thu, 15 Oct 2026 21:08:45 +0000 (14:08 -0700)
committerChris Duncan <chris@codecow.com>
Thu, 15 Oct 2026 21:08:45 +0000 (14:08 -0700)
src/index.ts
src/lib/bytes.ts

index ae2e47203e3d1368c7553d55852dbaf9bc6cbf88..af8c1281f53215c3f2fd565d141628b7da75649e 100644 (file)
@@ -70,7 +70,7 @@ export function verify (sig: Bytes | string, msg: Bytes | string, pub: Bytes | s
  * @param {(Bytes | string)} blocks.hash - 32-byte block hash
  * @returns Array of results with, for each case, true if signature matches block hash and public key, else false
  */
-export function verify_blocks (publicKey: Bytes | string, blocks: { signature: Bytes | string, hash: Bytes | string }[]): boolean[] {
+export function verify_blocks (publicKey: Bytes | string, blocks: { signature: Bytes | string, hash: Bytes | string }[]): readonly boolean[] {
        return nano25519.verify_blocks(publicKey, blocks)
 }
 
index 0bfaeff5fdab0e79858b2f9f460b3c4e074eea3e..d0aa12c866ca2040c8650496ef71e134f5b181e2 100644 (file)
@@ -4,41 +4,14 @@
 import { Nano25519RangeError, Nano25519TypeError, } from './errors'
 
 /**
- * Builtins captured once, when this module is evaluated, so that nothing on a
- * call path resolves a global or a prototype method that hostile code could
- * have replaced in the meantime.
- *
- * Two distinct protections are at work here and they need different captures:
- *
- * - Binding a constructor (`Bytes`) defends against later reassignment of the
- *   global, because call sites read this binding instead of looking up
- *   `Uint8Array` afresh on every call.
- * - Binding a method or accessor defends against later patching of the
- *   prototype, because the function reference is frozen rather than resolved
- *   through the object at call time.
- *
- * Neither defends against code that runs *before* this module is evaluated.
- * That is out of scope: a same-realm attacker who loads first can replace the
- * package's exports outright, and no copy strategy inside the library changes
- * that. What this does close is the caller-controlled surface — a hostile
- * `Uint8Array` subclass reaching input validation through `Symbol.species`, an
- * overridden `length`, or a spoofed `byteLength`.
- *
- * Accessors taken from `%TypedArray%.prototype` read internal slots, so a
- * subclass cannot lie to them. Prefer them to the equivalent property access
- * everywhere in this package.
- *
- * Only capture what is used *after* this module finishes evaluating. Anything
- * used solely to build the tables below runs while the realm is still as
- * trustworthy as it will ever be, so binding it first buys nothing — and
- * pretending otherwise makes this file harder to audit, not safer. That is why
- * `Object.getOwnPropertyDescriptor`, `Object.getPrototypeOf` and
- * `Object.create` appear here as plain globals.
- *
- * This module must stay free of imports. It is the trust root, so it has to
- * finish evaluating before anything that uses it: give it a dependency and the
- * bundler will order that dependency first, and any call it makes into here
- * during its own evaluation will read captures that are still unassigned.
+ * Prototype methods and accessors used on a call path, captured once when this
+ * module is evaluated and called through a bound `Function.prototype.call`, so
+ * that code patching a prototype afterwards cannot change what is validated,
+ * copied, scrubbed or decoded. The `%TypedArray%.prototype` getters also read
+ * internal slots, which a caller's subclass cannot override, so use these
+ * helpers on every typed array instead of its own properties. Global
+ * constructors and static functions are looked up at call time; replacing them,
+ * or running before this module, is out of scope.
  */
 
 /** Type aliases for legibility. */