diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a27cde1..c89e8d4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,8 +49,9 @@ jobs: - name: Rebuild and verify WASM run: | go test ./... - make test-wasm - git diff --exit-code -- assets + make check-wasm + make test-wasm WASM_OUT=dist/ci-wasm + node scripts/check-wasm-rebuild.mjs assets dist/ci-wasm - name: Verify reproducible WASM release archives run: make test-wasm-release diff --git a/README.md b/README.md index 689164d..1c4a3fe 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,9 @@ writer semantics independently in TypeScript. ## Version and Core release -The package asset binding is `0.0.5`, built against the published -`malt-core v0.0.11-rc.2` release at commit -`a8b0f9260ff025e834a803f87161685914604d11`. +The package asset binding is `0.0.6`, built against the published +`malt-core v0.0.11-rc.4` release at commit +`595f1e05aa86b0339addaa0f0e2ac6672faa8e00`. [`malt-core.lock.json`](./malt-core.lock.json) binds that tag, commit, Go module checksums. The `malt.ts-core-lock/v2` lock binds Core source only; Core WASM assets are not required. This repository exclusively owns WASM entrypoints, @@ -107,10 +107,12 @@ indices as eight unsigned big-endian bytes, and `encodeKeyLabel(Uint8Array)` serializes Direct 32-byte keys. `deriveCoordinate({profile, label})` executes Core derivation in the verifier Worker and returns a key or a bigint index. JavaScript performs no label hashing or application path normalization. -Prefix layout 4 authenticates exact original label bytes and targets; distinct +Map layout 4 authenticates exact original label bytes and targets; distinct labels at the same full coordinate are errors. Layout 1 is rejected without a -compatibility reader. Rebuild old Prefix state and its dependent parent Roots; -Positional layout 3 and Root V=0 are unchanged. +compatibility reader. Rebuild old Map state and its dependent parent Roots; +List remains layout 3 and Root V=0 is unchanged. Core rc.4 includes rc.3's +empty-cell scalar-zero encoding; roots and proofs from rc.2 or earlier must +be regenerated from original inputs, including dependent parent Roots. `prepareAuthentication(backend, stateJSON)` builds a complete candidate. `updateAuthentication(backend, candidateJSON, stateJSON)` verifies a complete @@ -170,7 +172,7 @@ session snapshot compatibility APIs. Worker readiness requires the complete current ABI. There are no forwarding aliases or optional old-runtime exports. The `malt-core.lock.json` and packaged binary assets identify the published -Core `v0.0.11-rc.2` release. Its current host and batch APIs are bound to the +Core `v0.0.11-rc.4` release. Its current host and batch APIs are bound to the exact release tag, source commit, and module checksums. Source integration checks remain separate from this published release binding. @@ -205,7 +207,7 @@ See [WASM release assets](docs/wasm-release-assets.md). The former Core WASM manifest/asset-set properties are removed. Consumers use this package's asset checksums and build provenance for the WASM it distributes. -The package uses root-only Positional metadata: `count` plus an optional +The package uses root-only List metadata: `count` plus an optional opaque `payload_cid`. Range bounds are element indices, and non-root vectors have no reserved metadata slot. Application JSON decoding stays in consumers. The packaged verifier and writer assets are built from the exact audited Core diff --git a/assets/verifier/PROVENANCE.json b/assets/verifier/PROVENANCE.json index afb25f8..d1b9516 100644 --- a/assets/verifier/PROVENANCE.json +++ b/assets/verifier/PROVENANCE.json @@ -1,13 +1,13 @@ { "schema": "malt.ts-verifier.provenance/v1", "source_repository": "https://github.com/DeWebProtocol/malt-ts.git", - "build_inputs_sha256": "d4f7b398570ed5fde535de33ebc9a4f57a1204d1f51c6ca271dbc522c9881f96", + "build_inputs_sha256": "1df72aa516dc33125758c7491cbe493fb885a9bcc2effce57a302c52406ad861", "core": { "module_path": "github.com/dewebprotocol/malt-core", - "module_version": "v0.0.11-rc.2", + "module_version": "v0.0.11-rc.4", "source_repository": "https://github.com/DeWebProtocol/malt-core.git", - "source_commit": "a8b0f9260ff025e834a803f87161685914604d11", - "module_sum": "h1:n1znvAKDKeH+vlrZ7o1nvinro2CGb1LoBtf0O3WOPzQ=", + "source_commit": "595f1e05aa86b0339addaa0f0e2ac6672faa8e00", + "module_sum": "h1:txnIBdjlVnQkPMUs6xxNwIEOoZxpQdJbmPDXkZbzgvM=", "go_mod_sum": "h1:uAbiKECccmR8MlDotFWLdAgp+JFStdSn2SqA6ILEXhA=" }, "target": "js/wasm", @@ -16,7 +16,7 @@ "maltDeriveCoordinate" ], "go_version": "go1.26.8", - "go_toolchain": "go version go1.26.8 linux/amd64", + "go_toolchain": "go version go1.26.8 windows/amd64", "build_flags": [ "-p=6", "-mod=readonly", diff --git a/assets/verifier/SHA256SUMS b/assets/verifier/SHA256SUMS index 7805c6e..37ef2f3 100644 --- a/assets/verifier/SHA256SUMS +++ b/assets/verifier/SHA256SUMS @@ -1,3 +1,3 @@ -0b3112c3d5dc2fffdfe1aa430307abacf609d1eebf00445ef54624ed7d03799e malt-verifier.wasm +fdc3af9dce8de3b322de1cad208c750351fe068892363ab1f8937486c062bf77 malt-verifier.wasm 0c949f4996f9a89698e4b5c586de32249c3b69b7baadb64d220073cc04acba14 wasm_exec.js -d77425461b8d70a34b7be7f21294e87a0f7804bceaa89494e1f700f45b9b9ca6 PROVENANCE.json +7be58669bd890583d02be4e621c828287b3aa72d18d06d912035e3ce73369622 PROVENANCE.json diff --git a/assets/verifier/malt-verifier.wasm b/assets/verifier/malt-verifier.wasm index e131b64..5792a8a 100644 Binary files a/assets/verifier/malt-verifier.wasm and b/assets/verifier/malt-verifier.wasm differ diff --git a/assets/writer/PROVENANCE.json b/assets/writer/PROVENANCE.json index 7cb8bb8..7d0b158 100644 --- a/assets/writer/PROVENANCE.json +++ b/assets/writer/PROVENANCE.json @@ -1,13 +1,13 @@ { "schema": "malt.ts-writer.provenance/v1", "source_repository": "https://github.com/DeWebProtocol/malt-ts.git", - "build_inputs_sha256": "d4f7b398570ed5fde535de33ebc9a4f57a1204d1f51c6ca271dbc522c9881f96", + "build_inputs_sha256": "1df72aa516dc33125758c7491cbe493fb885a9bcc2effce57a302c52406ad861", "core": { "module_path": "github.com/dewebprotocol/malt-core", - "module_version": "v0.0.11-rc.2", + "module_version": "v0.0.11-rc.4", "source_repository": "https://github.com/DeWebProtocol/malt-core.git", - "source_commit": "a8b0f9260ff025e834a803f87161685914604d11", - "module_sum": "h1:n1znvAKDKeH+vlrZ7o1nvinro2CGb1LoBtf0O3WOPzQ=", + "source_commit": "595f1e05aa86b0339addaa0f0e2ac6672faa8e00", + "module_sum": "h1:txnIBdjlVnQkPMUs6xxNwIEOoZxpQdJbmPDXkZbzgvM=", "go_mod_sum": "h1:uAbiKECccmR8MlDotFWLdAgp+JFStdSn2SqA6ILEXhA=" }, "target": "js/wasm", @@ -28,7 +28,7 @@ "sha256": "3799df0a77d1843b13a3a08744165180a12e1cd2dca529bee64ad691ac63adaf" }, "go_version": "go1.26.8", - "go_toolchain": "go version go1.26.8 linux/amd64", + "go_toolchain": "go version go1.26.8 windows/amd64", "build_flags": [ "-p=6", "-mod=readonly", diff --git a/assets/writer/SHA256SUMS b/assets/writer/SHA256SUMS index 72ca276..19b63aa 100644 --- a/assets/writer/SHA256SUMS +++ b/assets/writer/SHA256SUMS @@ -1,8 +1,8 @@ -95c9a29d00f076dc3bd6709c1c2e371a72fd0d42c0990f75384f2f83d433aedb malt-writer-kzg.wasm -86ad199013c2b98240bd30fb8b8224643eac860879534a3e7b2b31b13230af6e malt-writer-ipa-direct.wasm -2eb5114553568b75481fd967f11950ce1c37905aa8e18e350b081dfd76720c70 malt-writer-ipa-compact.wasm -6872a6b4a3f79a8d9ef6ff90259c4206931e91a2d27a41335707fb2c59d37101 malt-writer-ipa-fast.wasm +b9a9de50f0dc945454f0e3f7e77b720d885747398cca3cf6b7ea4e80b4abfb86 malt-writer-kzg.wasm +e5432d306116fa54c21ebd78fcf320f2a6cef6f63259e2600573aa9dba0381b5 malt-writer-ipa-direct.wasm +e78d4fc1ac43c3e1b8bef261b7c8aa1b23442976e13fea28f33af1b9744702ab malt-writer-ipa-compact.wasm +8d57eada1383a1f65ab678434d721f9dd5f4f4cd43024231234f2c413cb7d14d malt-writer-ipa-fast.wasm 6311876a80f3c9333f20e6a8ae8b55b7235b1f7411d6ae2224bc90b55fe779a2 malt-writer-worker.mjs 968657d9a8818feb23b6463aca609478c81423a93a8b0dc453705ad009214db0 malt-writer-workers.mjs 0c949f4996f9a89698e4b5c586de32249c3b69b7baadb64d220073cc04acba14 wasm_exec.js -db2db64e7fe5b0bf977d4d1376c4529cfe606c14ff3fe85984321bb87fab65c5 PROVENANCE.json +4440c9b6048ed8b77eba3030c81c1fa669359e558f0938ce50dc90479e0e92d3 PROVENANCE.json diff --git a/assets/writer/malt-writer-ipa-compact.wasm b/assets/writer/malt-writer-ipa-compact.wasm index 6775a7f..5dde1a8 100644 Binary files a/assets/writer/malt-writer-ipa-compact.wasm and b/assets/writer/malt-writer-ipa-compact.wasm differ diff --git a/assets/writer/malt-writer-ipa-direct.wasm b/assets/writer/malt-writer-ipa-direct.wasm index 2710745..bb4dca4 100644 Binary files a/assets/writer/malt-writer-ipa-direct.wasm and b/assets/writer/malt-writer-ipa-direct.wasm differ diff --git a/assets/writer/malt-writer-ipa-fast.wasm b/assets/writer/malt-writer-ipa-fast.wasm index 7323ce3..616da56 100644 Binary files a/assets/writer/malt-writer-ipa-fast.wasm and b/assets/writer/malt-writer-ipa-fast.wasm differ diff --git a/assets/writer/malt-writer-kzg.wasm b/assets/writer/malt-writer-kzg.wasm index 0c419bc..5502841 100644 Binary files a/assets/writer/malt-writer-kzg.wasm and b/assets/writer/malt-writer-kzg.wasm differ diff --git a/go.mod b/go.mod index ecc9a2f..297ba66 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module github.com/dewebprotocol/malt-ts go 1.26.8 -require github.com/dewebprotocol/malt-core v0.0.11-rc.2 +require github.com/dewebprotocol/malt-core v0.0.11-rc.4 require ( github.com/bits-and-blooms/bitset v1.25.0 // indirect diff --git a/go.sum b/go.sum index b4e1ace..81fef46 100644 --- a/go.sum +++ b/go.sum @@ -4,8 +4,8 @@ github.com/consensys/gnark-crypto v0.22.0 h1:RYH7FX1/zkmNrSiABo70HAqew41SRUsoluK github.com/consensys/gnark-crypto v0.22.0/go.mod h1:HL8XflRG4cvau1PEG3CWBTD2kkzUzdlqZF6BBgy57F8= github.com/crate-crypto/go-kzg-4844 v1.1.0 h1:EN/u9k2TF6OWSHrCCDBBU6GLNMq88OspHHlMnHfoyU4= github.com/crate-crypto/go-kzg-4844 v1.1.0/go.mod h1:JolLjpSff1tCCJKaJx4psrlEdlXuJEC996PL3tTAFks= -github.com/dewebprotocol/malt-core v0.0.11-rc.2 h1:n1znvAKDKeH+vlrZ7o1nvinro2CGb1LoBtf0O3WOPzQ= -github.com/dewebprotocol/malt-core v0.0.11-rc.2/go.mod h1:uAbiKECccmR8MlDotFWLdAgp+JFStdSn2SqA6ILEXhA= +github.com/dewebprotocol/malt-core v0.0.11-rc.4 h1:txnIBdjlVnQkPMUs6xxNwIEOoZxpQdJbmPDXkZbzgvM= +github.com/dewebprotocol/malt-core v0.0.11-rc.4/go.mod h1:uAbiKECccmR8MlDotFWLdAgp+JFStdSn2SqA6ILEXhA= github.com/ipfs/go-cid v0.6.2 h1:VuGwJd+KJTaMJ4S4d5EEf9SXc17YUblS5axCbocn9YE= github.com/ipfs/go-cid v0.6.2/go.mod h1:Xhwg8NzHeK9xPCEZkCw4idzPiuNMpX3fARuI5Iwj1Lo= github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y= diff --git a/malt-core.lock.json b/malt-core.lock.json index f0ec730..a6b5b2d 100644 --- a/malt-core.lock.json +++ b/malt-core.lock.json @@ -1,9 +1,9 @@ { "schema": "malt.ts-core-lock/v2", "module_path": "github.com/dewebprotocol/malt-core", - "module_version": "v0.0.11-rc.2", + "module_version": "v0.0.11-rc.4", "source_repository": "https://github.com/DeWebProtocol/malt-core.git", - "source_commit": "a8b0f9260ff025e834a803f87161685914604d11", - "module_sum": "h1:n1znvAKDKeH+vlrZ7o1nvinro2CGb1LoBtf0O3WOPzQ=", + "source_commit": "595f1e05aa86b0339addaa0f0e2ac6672faa8e00", + "module_sum": "h1:txnIBdjlVnQkPMUs6xxNwIEOoZxpQdJbmPDXkZbzgvM=", "go_mod_sum": "h1:uAbiKECccmR8MlDotFWLdAgp+JFStdSn2SqA6ILEXhA=" } diff --git a/package-lock.json b/package-lock.json index 2100168..b813efa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@dewebprotocol/malt", - "version": "0.0.5", + "version": "0.0.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@dewebprotocol/malt", - "version": "0.0.5", + "version": "0.0.6", "license": "Apache-2.0", "devDependencies": { "happy-dom": "20.11.1", diff --git a/package.json b/package.json index 9673bf0..c3fcbf6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@dewebprotocol/malt", - "version": "0.0.5", + "version": "0.0.6", "description": "Stable TypeScript and browser WASM SDK for MALT", "type": "module", "license": "Apache-2.0", diff --git a/scripts/build-wasm-release.sh b/scripts/build-wasm-release.sh index 6930220..9fed625 100755 --- a/scripts/build-wasm-release.sh +++ b/scripts/build-wasm-release.sh @@ -70,11 +70,11 @@ authentication_corpus_sha256="$(sha256sum "${core_module_dir}/conformance/authen chmod 0644 "${verifier_staging}/"* "${writer_staging}/"* ( cd "${verifier_staging}" - sha256sum malt-verifier.wasm wasm_exec.js PROVENANCE.json >SHA256SUMS + sha256sum --text malt-verifier.wasm wasm_exec.js PROVENANCE.json >SHA256SUMS ) ( cd "${writer_staging}" - sha256sum \ + sha256sum --text \ malt-writer-kzg.wasm \ malt-writer-ipa-direct.wasm \ malt-writer-ipa-compact.wasm \ @@ -148,7 +148,7 @@ manifest_name="malt-wasm-release-${release_version}-${manifest_digest}.json" mv "${temporary}/WASM-RELEASE.json" "${temporary}/${manifest_name}" ( cd "${temporary}" - sha256sum "${verifier_archive}" "${writer_archive}" "${manifest_name}" >SHA256SUMS + sha256sum --text "${verifier_archive}" "${writer_archive}" "${manifest_name}" >SHA256SUMS ) for artifact in "${verifier_archive}" "${writer_archive}" "${manifest_name}" SHA256SUMS; do diff --git a/scripts/build-wasm.sh b/scripts/build-wasm.sh index 55a8b49..e945f83 100755 --- a/scripts/build-wasm.sh +++ b/scripts/build-wasm.sh @@ -28,9 +28,9 @@ build_inputs_digest() { "${source_file}" >&2 exit 1 } - sha256sum "${source_file}" + sha256sum --text "${source_file}" done | - sha256sum | + sha256sum --text | awk '{print $1}' ) } @@ -255,11 +255,11 @@ PROVENANCE_PATH="${writer_staging}/PROVENANCE.json" node -e ' ( cd "${verifier_staging}" - sha256sum malt-verifier.wasm wasm_exec.js PROVENANCE.json >SHA256SUMS + sha256sum --text malt-verifier.wasm wasm_exec.js PROVENANCE.json >SHA256SUMS ) ( cd "${writer_staging}" - sha256sum \ + sha256sum --text \ malt-writer-kzg.wasm \ malt-writer-ipa-direct.wasm \ malt-writer-ipa-compact.wasm \ diff --git a/scripts/check-wasm-rebuild.mjs b/scripts/check-wasm-rebuild.mjs new file mode 100644 index 0000000..72c2f2e --- /dev/null +++ b/scripts/check-wasm-rebuild.mjs @@ -0,0 +1,54 @@ +import assert from 'node:assert/strict' +import { createHash } from 'node:crypto' +import fs from 'node:fs' +import path from 'node:path' +import { fileURLToPath } from 'node:url' + +function readAssets(directory) { + const entries = fs.readdirSync(directory, { withFileTypes: true }) + assert(entries.every((entry) => entry.isFile()), `non-file asset in ${directory}`) + const files = new Map(entries.map((entry) => [entry.name, fs.readFileSync(path.join(directory, entry.name))])) + assert(files.has('SHA256SUMS') && files.has('PROVENANCE.json'), 'missing asset metadata') + const checked = new Set() + for (const line of files.get('SHA256SUMS').toString('utf8').trimEnd().split('\n')) { + const match = /^([a-f0-9]{64}) ([a-zA-Z0-9_.-]+)$/.exec(line) + assert(match, `invalid checksum line: ${line}`) + const [, expected, name] = match + assert(name !== 'SHA256SUMS' && files.has(name) && !checked.has(name), `invalid checksum entry: ${name}`) + assert.equal(createHash('sha256').update(files.get(name)).digest('hex'), expected, `checksum mismatch: ${name}`) + checked.add(name) + } + assert.deepEqual([...checked].sort(), [...files.keys()].filter((name) => name !== 'SHA256SUMS').sort(), 'incomplete checksum coverage') + return files +} + +function portableProvenance(contents) { + const provenance = JSON.parse(contents.toString('utf8')) + const toolchain = /^go version (go[0-9]+\.[0-9]+\.[0-9]+) ([a-z0-9]+)\/([a-z0-9]+)$/.exec(provenance.go_toolchain || '') + assert(toolchain && toolchain[1] === provenance.go_version, 'invalid provenance toolchain') + // The compiler version and target must match; the machine running the + // compiler may differ. Keep the actual build host in each published record. + return { ...provenance, go_toolchain: toolchain[1] } +} + +export function validateWasmRebuild(publishedRoot, rebuiltRoot) { + for (const kind of ['verifier', 'writer']) { + const published = readAssets(path.join(publishedRoot, kind)) + const rebuilt = readAssets(path.join(rebuiltRoot, kind)) + assert.deepEqual([...published.keys()].sort(), [...rebuilt.keys()].sort(), `different ${kind} asset sets`) + for (const [name, bytes] of published) { + if (name === 'SHA256SUMS') continue // Both complete manifests were checked above. + if (name === 'PROVENANCE.json') { + assert.deepEqual(portableProvenance(bytes), portableProvenance(rebuilt.get(name)), `${kind} provenance differs`) + } else { + assert(bytes.equals(rebuilt.get(name)), `${kind}/${name} differs`) + } + } + } +} + +if (process.argv[1] && fileURLToPath(import.meta.url) === path.resolve(process.argv[1])) { + assert.equal(process.argv.length, 4, 'usage: node scripts/check-wasm-rebuild.mjs PUBLISHED REBUILT') + validateWasmRebuild(process.argv[2], process.argv[3]) + console.log('WASM rebuild matches all payload bytes and portable provenance.') +} diff --git a/src/release.mjs b/src/release.mjs index e06a6a2..2fb99b7 100644 --- a/src/release.mjs +++ b/src/release.mjs @@ -1,8 +1,8 @@ -export const maltTSVersion = '0.0.5' +export const maltTSVersion = '0.0.6' export const maltCoreRelease = Object.freeze({ - version: 'v0.0.11-rc.2', - commit: 'a8b0f9260ff025e834a803f87161685914604d11', - moduleSum: 'h1:n1znvAKDKeH+vlrZ7o1nvinro2CGb1LoBtf0O3WOPzQ=', + version: 'v0.0.11-rc.4', + commit: '595f1e05aa86b0339addaa0f0e2ac6672faa8e00', + moduleSum: 'h1:txnIBdjlVnQkPMUs6xxNwIEOoZxpQdJbmPDXkZbzgvM=', goModSum: 'h1:uAbiKECccmR8MlDotFWLdAgp+JFStdSn2SqA6ILEXhA=' }) diff --git a/test/core-tag-lookup.test.mjs b/test/core-tag-lookup.test.mjs index 04f24d3..df99c8f 100644 --- a/test/core-tag-lookup.test.mjs +++ b/test/core-tag-lookup.test.mjs @@ -15,7 +15,17 @@ import { expect, it } from 'vitest' const resolver = path.resolve(process.cwd(), 'scripts/resolve-core-tag.sh') const moduleVersion = 'v0.0.7-rc.2' -const realGit = execFileSync('which', ['git'], { encoding: 'utf8' }).trim() +const realGit = execFileSync('bash', ['-c', 'command -v git'], { encoding: 'utf8' }).trim() + +function resolveTag(arguments_, options) { + // Git Bash prepends its own tools to inherited PATH on Windows. Add test + // doubles after Bash starts so the bounded-retry tests exercise them too. + return execFileSync('bash', ['-c', + 'if [[ -n ${MALT_TEST_BIN:-} ]]; then export PATH="${MALT_TEST_BIN}:${PATH}"; fi; exec bash "$@"', + '--', resolver, ...arguments_ + ], options) +} + function cleanGitEnvironment(extra = {}) { const environment = { ...process.env } @@ -71,7 +81,9 @@ function retryEnvironment(root, gitScript) { attempts, sleeps, environment: cleanGitEnvironment({ - PATH: `${bin}:${process.env.PATH}`, + MALT_TEST_BIN: process.platform === 'win32' + ? execFileSync('bash', ['-c', 'cygpath -u -- "$1"', '--', bin], { encoding: 'utf8' }).trim() + : bin, REAL_GIT: realGit, RETRY_ATTEMPTS_FILE: attempts }) @@ -112,7 +124,7 @@ it('ignores inherited Git command config that redirects the canonical remote', ( const redirected = createTaggedRepository(root, 'redirected', 'redirected') expect(redirected.commit).not.toBe(canonical.commit) - const output = execFileSync(resolver, [canonical.url, moduleVersion], { + const output = resolveTag([canonical.url, moduleVersion], { encoding: 'utf8', env: { ...process.env, @@ -136,7 +148,7 @@ it('retries transient canonical tag lookup failures with bounded backoff', () => try { const canonical = createTaggedRepository(root, 'canonical', 'canonical') const retry = retryEnvironment(root, retryingGit) - const output = execFileSync(resolver, [canonical.url, moduleVersion], { + const output = resolveTag([canonical.url, moduleVersion], { encoding: 'utf8', env: retry.environment }).trim() @@ -153,8 +165,7 @@ it('stops after three canonical tag lookup failures and preserves the error', () const root = mkdtempSync(path.join(tmpdir(), 'malt-ts-core-tag-failure-test.')) try { const retry = retryEnvironment(root, failingGit) - expect(() => execFileSync( - resolver, + expect(() => resolveTag( ['https://github.com/DeWebProtocol/malt-core.git', moduleVersion], { encoding: 'utf8', env: retry.environment, stdio: 'pipe' } )).toThrow(/simulated permanent TLS failure/) diff --git a/test/wasm-rebuild.test.mjs b/test/wasm-rebuild.test.mjs new file mode 100644 index 0000000..5f77b81 --- /dev/null +++ b/test/wasm-rebuild.test.mjs @@ -0,0 +1,71 @@ +import { createHash } from 'node:crypto' +import fs from 'node:fs' +import os from 'node:os' +import path from 'node:path' +import { afterEach, expect, it } from 'vitest' +import { validateWasmRebuild } from '../scripts/check-wasm-rebuild.mjs' + +const temporary = [] +afterEach(() => temporary.splice(0).forEach((directory) => fs.rmSync(directory, { recursive: true, force: true }))) + +function writeSet(directory, host, changes = {}) { + fs.mkdirSync(directory, { recursive: true }) + const provenance = { + go_version: 'go1.26.8', go_toolchain: `go version go1.26.8 ${host}`, + target: 'js/wasm', core: { module_version: 'v0.0.11-rc.4' }, ...changes + } + fs.writeFileSync(path.join(directory, 'PROVENANCE.json'), JSON.stringify(provenance)) + fs.writeFileSync(path.join(directory, 'module.wasm'), 'wasm fixture') + checksums(directory) +} + +function checksums(directory) { + const lines = fs.readdirSync(directory).filter((name) => name !== 'SHA256SUMS').map((name) => + createHash('sha256').update(fs.readFileSync(path.join(directory, name))).digest('hex') + ' ' + name + ) + fs.writeFileSync(path.join(directory, 'SHA256SUMS'), lines.join('\n') + '\n') +} + +function fixture() { + const root = fs.mkdtempSync(path.join(os.tmpdir(), 'wasm-rebuild-')) + temporary.push(root) + const roots = ['published', 'rebuilt'].map((name) => path.join(root, name)) + for (const kind of ['verifier', 'writer']) { + writeSet(path.join(roots[0], kind), 'windows/amd64') + writeSet(path.join(roots[1], kind), 'linux/amd64') + } + return roots +} + +it('accepts a different build host with identical payload and portable metadata', () => { + expect(() => validateWasmRebuild(...fixture())).not.toThrow() +}) + +it('rejects payload changes even with valid replacement checksums', () => { + const roots = fixture() + const directory = path.join(roots[1], 'writer') + fs.writeFileSync(path.join(directory, 'module.wasm'), 'different binary') + checksums(directory) + expect(() => validateWasmRebuild(...roots)).toThrow('module.wasm differs') +}) + +it('rejects stale checksums and incomplete checksum coverage', () => { + const roots = fixture() + const directory = path.join(roots[1], 'writer') + fs.writeFileSync(path.join(directory, 'module.wasm'), 'tampered binary') + expect(() => validateWasmRebuild(...roots)).toThrow('checksum mismatch') + checksums(directory) + fs.writeFileSync(path.join(directory, 'extra.wasm'), 'unlisted') + expect(() => validateWasmRebuild(...roots)).toThrow('incomplete checksum coverage') +}) + +it.each([ + { core: { module_version: 'v0.0.11-rc.2' } }, + { target: 'linux/amd64' }, + { go_version: 'go1.26.9', go_toolchain: 'go version go1.26.9 linux/amd64' }, + { go_toolchain: 'go version go1.26.9 linux/amd64' } +])('rejects changed or inconsistent provenance %j', (changes) => { + const roots = fixture() + writeSet(path.join(roots[1], 'verifier'), 'linux/amd64', changes) + expect(() => validateWasmRebuild(...roots)).toThrow() +}) diff --git a/types/release.d.ts b/types/release.d.ts index 70a56e8..5c93bc4 100644 --- a/types/release.d.ts +++ b/types/release.d.ts @@ -1,8 +1,8 @@ -export declare const maltTSVersion: '0.0.5' +export declare const maltTSVersion: '0.0.6' export interface MaltCoreRelease { - readonly version: 'v0.0.11-rc.2' - readonly commit: 'a8b0f9260ff025e834a803f87161685914604d11' + readonly version: 'v0.0.11-rc.4' + readonly commit: '595f1e05aa86b0339addaa0f0e2ac6672faa8e00' readonly moduleSum: string readonly goModSum: string }