Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NayNay] Signing Fix: Message too long error #412

Merged
merged 4 commits into from
Aug 26, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/signing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,14 @@ export default class SignatureRequestManager {
// define keygroups see issue#380 https://github.com/entropyxyz/sdk/issues/380
this.#keyGroups[i] = keyGroup
// omg polkadot type gen is a head ache
//
// If the Message being signed is too long the sigRequestHash is then converted to a number
// so large that the resulting parsed value of parseInt(sigRequest, 16) would return Infinity.
// Using BigInt instead solves the Infinity issue, and now allows messages of any length to be
// signed.
//
// @ts-ignore: next line
const index = parseInt(sigRequest, 16) % keyGroup.unwrap().length
const index = Number(BigInt(`0x${sigRequest}`) % BigInt(keyGroup.unwrap().length))
rh0delta marked this conversation as resolved.
Show resolved Hide resolved
if (isNaN(index)) {
throw new Error(`when calculating the index for choosing a validator got: NaN`)
}
Expand Down
Loading