Compiled-Wasm interoperability laboratory

interop.mjs checks real signatures and shared secrets from the installed canister against independent implementations in both directions. Every run generates fresh random synthetic seeds with Node crypto.randomBytes, saves the exact corpus and its SHA256, and checks every record. These seeds are published laboratory fixtures. Never use account keys or deploy these benchmark-only signing endpoints as an application service.

The signature endpoint returns our newly generated public key and full signature, together with our verdict on the supplied reference signature. Noble 1.9.7 verifies our BIP340 outputs and supplies independent incoming signatures. The same auxiliary bytes must give identical Schnorr signatures. OpenSSL supplies and verifies ECDSA and Ed25519 signatures. ECDSA uses SHA256(message) once, low-S compact P1363 signatures, and independent verification rather than byte equality because OpenSSL uses random nonces. Ed25519 uses the same raw seed and must reproduce OpenSSL's exact signature.

X25519 sends seed A with OpenSSL's public B, checks our output against OpenSSL using secret B and our returned public A, then swaps the two parties. Ordinary, Global SIMD and PerFour SIMD agreement/public-key bytes and every validity flag must match. The zero-peer test requires rejection and zero bytes in every implementation. Ed25519 tests cover generated ordinary keys and the explicit mutations; they do not assert identical torsion/malleability policies across all libraries.

The matrix exercises messages of 0/1/31/32/63/64/65/127/128/129/512/2048 bytes and actual cohorts of 1/3/5/100/500. N100 adds message/signature/key mutations and zero-peer DH. Separate calls send the same independent fixed-message32 corpus through the individual Schnorr verifier, Schnorr SIMD W7/W8 and ECDSA21 pipelines, including invalid/mixed/key/hint cases and complete Schnorr fallback checks. No prior-call key or result cache is used. Accepted Schnorr aggregates retain the existing probabilistic full-field coefficient policy.

Use a canonical artifact built with wasm-schnorr-msm-simd and the same feature set for every before/after comparison. The canister's direct curves dependency enables the Ed25519 and X25519 SIMD implementations. Root owns manifest/lockfile resolution, canonical Wasm builds and PocketIC execution.

node --test benches/crypto/interop-vectors.test.mjs
node benches/crypto/interop.mjs --artifact ARTIFACT --out NEW_RESULTS \
  --pocket-ic PINNED_BINARY --batches 1,3,5,100,500

--corpus FILE reverifies and reuses an exact saved corpus. --corpus-only generates/reverifies host inputs without starting a canister. The runner saves exact request/response bytes, source/reference identities, complete execution traces and per-call checks. Its instruction totals include the complete interoperability fixture and are not isolated algorithm measurements.

Both stateless Wire endpoints admit at most 500 records and 2 MiB. Messages are bounded to 2048 bytes, with checked key/signature/seed carrier lengths. ByteBuf prevents per-byte visitor nodes; the explicit node/allocation limits also cover malformed decoder-admitted requests before application admission.