* @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)
}
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. */