Summary
Make fromHex in packages/tlock/src/commitment.ts reject malformed hexadecimal input instead of silently converting invalid byte pairs to zero.
Why this matters
parseInt("zz", 16) returns NaN, and assigning that value to a Uint8Array produces 0. Today an invalid value such as "zz" can therefore be accepted as a different byte sequence, which is risky in commitment and nonce tooling.
Scope
- Validate the full input after removing an optional
0x prefix.
- Preserve support for uppercase and lowercase hex.
- Keep the existing odd-length rejection.
- Add focused tests in
packages/tlock/src/commitment.test.ts.
- Do not change seal or commitment encoding.
Acceptance criteria
Summary
Make
fromHexinpackages/tlock/src/commitment.tsreject malformed hexadecimal input instead of silently converting invalid byte pairs to zero.Why this matters
parseInt("zz", 16)returnsNaN, and assigning that value to aUint8Arrayproduces0. Today an invalid value such as"zz"can therefore be accepted as a different byte sequence, which is risky in commitment and nonce tooling.Scope
0xprefix.packages/tlock/src/commitment.test.ts.Acceptance criteria
0x-prefixed values decode correctly.pnpm --filter @sub-rosa/tlock testand typecheck pass.