Skip to content

fix(types): bigint amounts + manual JSON signing payload (audit H1+H2+H4)#12

Merged
github-actions[bot] merged 1 commit intomainfrom
fix/audit-h1-h2-bigint-amounts
May 7, 2026
Merged

fix(types): bigint amounts + manual JSON signing payload (audit H1+H2+H4)#12
github-actions[bot] merged 1 commit intomainfrom
fix/audit-h1-h2-bigint-amounts

Conversation

@satyakwok
Copy link
Copy Markdown
Contributor

Audit 2026-05-07 fixes (HIGH × 3):

H1: amount/fee/nonce/etc fields → bigint (was number, overflows ~90M SRX safe-int).
H2: SentrixWallet.signingPayload now builds JSON manually with bigint integer literals (was JSON.stringify, threw on bigint and silently rounded > 2^53).
H4: 3-test fixture including > 2^53 amount case verifies sha256(payload) parity with Rust chain.

Helpers added:

  • stringifyWithBigInt(value) — JSON.stringify replacement
  • bigintFromJsonText(text, [keys]) — for high-value REST response fields

Breaking change: version bumped 0.2.0-rc.0 → 0.3.0-rc.0. Consumers must migrate amount: 100amount: 100n.

…+H4)

Audit 2026-05-07 findings:

H1 (HIGH): all amount/fee/nonce/chain_id/timestamp/total_minted/etc.
fields typed as JS `number` overflowed safe-int (~90.07M SRX) below
the 315M supply target. Now `bigint` everywhere they appear.

H2 (HIGH): SentrixWallet.signingPayload used JSON.stringify which (a)
threw on bigint and (b) silently rounded numbers > 2^53 in the
pre-bigint era. Now builds the JSON string manually so bigint amounts
are emitted as bare integer literals — matching Rust serde_json u64
output byte-for-byte.

H4: CI ran 'pnpm test --passWithNoTests' with zero test files, so
signing-payload Rust parity was never gated. Added
src/wallet/signing-payload.test.ts with 3 fixtures including a
> 2^53 amount case. CI workflow updated to drop --passWithNoTests.

Helpers added:
- stringifyWithBigInt(value) — JSON.stringify replacement that emits
  bigints as integer literals
- bigintFromJsonText(text, [keys]) — for deserializing high-value
  numeric fields from the chain's REST responses without rounding

Submit-tx POST now uses stringifyWithBigInt internally so callers can
pass bigint-typed NativeTx without serialize errors.

Version bumped 0.2.0-rc.0 → 0.3.0-rc.0 (breaking API change: amount/
fee/etc consumers must migrate from number to bigint).
@github-actions github-actions Bot enabled auto-merge (squash) May 7, 2026 14:26
@github-actions github-actions Bot merged commit 22511d7 into main May 7, 2026
3 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.

1 participant