Skip to content

Reject odd-length Solana hex private keys#111

Open
samsamtrum wants to merge 1 commit into
openfort-xyz:mainfrom
samsamtrum:fix-solana-hex-private-key-validation
Open

Reject odd-length Solana hex private keys#111
samsamtrum wants to merge 1 commit into
openfort-xyz:mainfrom
samsamtrum:fix-solana-hex-private-key-validation

Conversation

@samsamtrum

Copy link
Copy Markdown

Rejects odd-length hex strings in Solana private-key import before decoding them with Buffer.from(..., "hex").

Node truncates a trailing half-byte when decoding odd-length hex, so a malformed key could be decoded into a different byte array and then fail later with a misleading key-length error. This makes the validation explicit for both 0x-prefixed and plain hex input.

Checked with:

  • pnpm install --ignore-scripts --frozen-lockfile
  • pnpm test src/wallets/solana/solanaClient.test.ts
  • pnpm check:types
  • pnpm lint
  • pnpm build
  • git diff --check

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