Skip to content

fixes issues with v - #613

Merged
netbonus merged 6 commits into
devfrom
nb/fix-v-2
Sep 16, 2025
Merged

netbonus merged 6 commits into
devfrom
nb/fix-v-2

Conversation

@netbonus

Copy link
Copy Markdown
Contributor

No description provided.

@pkg-pr-new

pkg-pr-new Bot commented Aug 28, 2025 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/GridPlus/gridplus-sdk@613

commit: dc606c2

Comment thread src/genericSigning.ts
req.hashType === Constants.SIGNING.HASHES.KECCAK256
) {
const vBn = getV(req.origPayloadBuf, parsed);
parsed.sig.v = BigInt(vBn.toString());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I see the viem/Signature implementation and also the legacy eth transactions have the type of v as bigint ✅
Should we make it optional and update other places to bigint like

v: number; // Recovery parameter
?

And also where do we have the following definition, that the Kalo mentioned in his issue?

  sig?: {
    v: Buffer;
    r: Buffer;
    s: Buffer;
  };
  ...
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

WDYT about this one @netbonus ?

@yilmazbahadir

yilmazbahadir commented Sep 1, 2025 •

Copy link
Copy Markdown
Collaborator

@netbonus please see Kalo's test result below:

lib sign method fails (throws):

Error: Could not recover V. Bad transaction data.
at getV (util.ts:749:1)
at parseGenericSigningResponse (genericSigning.ts:250:1)
at decodeSignResponse (sign.ts:300:1)
at sign (sign.ts:86:1)
This happens right after I approve the plain text message on the device (all visualized correctly).

My req is:

{
"signerPath": [2147483692, 2147483708, 2147483648, 0, 0],
"payload": "0x5465737421",
"curveType": 0,
"hashType": 1
}
(Attempting to sign a plain text message using general signing).

@superKalo

superKalo commented Sep 1, 2025 •

Copy link
Copy Markdown

@netbonus additional details: I'm on the latest firmware. Also when I trigger sign with the req that @yilmazbahadir shared, the plain message appears on the Lattice device (all visualized correctly), I approve it and then - it throws.

- Add comprehensive transaction schema validation using Zod
- Fix v parameter calculation for different transaction types
- Consolidate signature recovery logic into unified functions
- Add transaction parsing utilities for better error handling
- Improve test coverage for signature utils and validators
- Fix data field encoding in test builders
- Update encoder test snapshots to reflect corrected behavior

This addresses issues with v parameter calculation across different
transaction types (legacy, EIP-155, EIP-1559, EIP-2930, EIP-7702)
and improves the overall robustness of transaction handling.
Comment thread src/__test__/unit/parseGenericSigningResponse.test.ts Outdated
Comment thread src/__test__/unit/parseGenericSigningResponse.test.ts
Comment thread src/__test__/unit/signatureUtils.test.ts Outdated
Comment thread src/__test__/unit/signatureUtils.test.ts
Comment thread src/util.ts Outdated
Comment thread src/__test__/unit/parseGenericSigningResponse.test.ts Outdated
@netbonus
netbonus merged commit f67c98a into dev Sep 16, 2025
4 checks passed
@yilmazbahadir yilmazbahadir mentioned this pull request Dec 2, 2025
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