Skip to content

feat(argon2): vendor hash-wasm v4.12.0 as @bitgo/argon2#8482

Merged
pranavjain97 merged 3 commits intomasterfrom
WCN-29-vendor-hash-wasm
Apr 14, 2026
Merged

feat(argon2): vendor hash-wasm v4.12.0 as @bitgo/argon2#8482
pranavjain97 merged 3 commits intomasterfrom
WCN-29-vendor-hash-wasm

Conversation

@pranavjain97
Copy link
Copy Markdown
Contributor

Vendor the argon2 subset of hash-wasm as a new @bitgo/argon2 module, following the same pattern as @bitgo/sjcl. The pre-built UMD bundle (~29KB) contains argon2 and blake2b WASM binaries embedded as base64 with zero runtime dependencies.

Exports: argon2id, argon2i, argon2d, argon2Verify with full TypeScript type definitions. Includes verify-vendor.sh script for reproducible re-vendoring from npm.

This module is a prerequisite for migrating BitGoJS encryption from SJCL (PBKDF2-SHA256 @ 10k iterations, ~1ms per guess on modern hardware) to Argon2id, which is memory-hard and GPU-resistant.

TICKET: WCN-29

@linear
Copy link
Copy Markdown

linear bot commented Apr 10, 2026

@pranavjain97 pranavjain97 force-pushed the WCN-29-vendor-hash-wasm branch from f1d0990 to 221ebac Compare April 10, 2026 16:42
Vendor the argon2 subset of hash-wasm as a new @bitgo/argon2 module,
following the same pattern as @bitgo/sjcl. The pre-built UMD bundle
(~29KB) contains argon2 and blake2b WASM binaries embedded as base64
with zero runtime dependencies.

Exports: argon2id, argon2i, argon2d, argon2Verify with full TypeScript
type definitions. Includes verify-vendor.sh script for reproducible
re-vendoring from npm.

WCN-29

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

TICKET: WCN-29
@pranavjain97 pranavjain97 force-pushed the WCN-29-vendor-hash-wasm branch from 221ebac to 671b89c Compare April 10, 2026 17:13
@sachushaji
Copy link
Copy Markdown
Contributor

@claude

Copy link
Copy Markdown
Contributor

@zahin-mohammad zahin-mohammad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: Supply Chain, Auditability & Release Risks

The vendoring approach (following @bitgo/sjcl precedent) is sound in principle, and the motivation — migrating from PBKDF2-SHA256 to Argon2id — is the right move. However, there are gaps that should be addressed before merging, given this is cryptographic code in a financial SDK.

Supply Chain Risk (HIGH)

  • The vendored bundle contains opaque base64-encoded WASM binaries that cannot be reviewed from the diff. Trust is anchored entirely to an npm tarball from a single maintainer.
  • verify-vendor.sh verifies against npm, not against a reproducible source build. A compromised npm publish would pass verification. Pin the expected SHA256 and trace provenance to a specific git commit.

Auditability (HIGH)

  • No RFC 9106 known-answer test vectors. The test suite verifies behavioral properties but never asserts exact output against published reference vectors. A subtly broken or backdoored WASM implementation would pass all current tests. This is the single most important gap to close.
  • Hand-written index.d.ts with "include": [] in tsconfig means types are never validated against the JS exports.

Release Integration (MEDIUM)

  • "private": true will block npm publish if downstream packages depend on this.
  • Missing standard monorepo scripts (build, test, lint, clean), no ESM support, not added to root workspaces.
  • Buffer type in index.d.ts without @types/node dependency breaks browser-only TS consumers.

See inline comments for specifics on each file.

Comment thread modules/argon2/argon2.umd.min.js
Comment thread modules/argon2/scripts/verify-vendor.sh
Comment thread modules/argon2/test/argon2.test.ts
Comment thread modules/argon2/package.json Outdated
Comment thread modules/argon2/package.json
Comment thread modules/argon2/index.d.ts Outdated
Comment thread modules/argon2/tsconfig.json Outdated
- Add known-answer tests pinning exact hex outputs for argon2id/i/d,
  cross-validated against argon2-cffi (C reference implementation)
- Add PROVENANCE.md with SHA256 hash and git commit for audit trail
- Update verify-vendor.sh to check pinned hash before npm comparison
- Remove Buffer from IDataType (Node-only, breaks browser TS projects)
- Add type-check smoke test to catch index.d.ts drift from JS exports
- Add test/verify scripts to package.json
- Include PROVENANCE.md in npm package files

WCN-29

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

TICKET: WCN-29
Adds a CI job that checks the vendored argon2.umd.min.js against
the pinned SHA256 hash and the upstream npm tarball.

WCN-29

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

TICKET: WCN-29
@pranavjain97 pranavjain97 merged commit 61a2d82 into master Apr 14, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants