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

Ledger signer 211 #1246

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

PhilippeR26
Copy link
Collaborator

@PhilippeR26 PhilippeR26 commented Oct 11, 2024

Motivation and Resolution

Ledger has released a new version 2.1.1 of the Starknet APP.
It includes improvements, including a comprehensive display of the details of V1 & V3 transactions.
20241011_100145

Starknet.js is now able to use APP v1.1.1 & v2.1.1.

Usage related changes

Important

No breaking changes for code using Ledger APP v1.1.1 (just no comprehensive display, only blind signatures)

  • For users still using v1.1.1 :
    No change of the code :
const myLedgerSigner = new LedgerSigner(myLedgerTransport, 0);

LedgerSigner and LedgerSigner111 classes are equivalent.

  • For new users, using v2.1.1 to create a new account :
const myLedgerSigner = new LedgerSigner211(myLedgerTransport, 0);

They can also use the v1.1.1 signer ; they will only not have access to the display of transaction details.

  • For new users, using v1.1.1 to create a new account that will be natively compatible with v2.1.1 :
const myLedgerSigner = new LedgerSigner111(myLedgerTransport, 0, undefined, getLedgerPathBuffer211);
  • For users that have created an account with V1.1.1, and are now using v2.1.1 :
const myLedgerSigner = new LedgerSigner211(myLedgerTransport, 0, getLedgerPathBuffer111);

Development related changes

LedgerSigner and getLedgerPathBuffer are still there, and are related to v1.1.1 APP.
They are now also named LedgerSigner111 and getLedgerPathBuffer111.

LedgerSigner211 and getLedgerPathBuffer211 have been created to handle v2.1.1.

As several functions are common for both signers, the LedgerSigner211 is an extension of the LedgerSigner111.

Some maths included in hashFeeField (utils/hash/transactionHash/v3.ts) are necessary, and have been isolated in exportable functions.

The new signer has been tested successfully in Node ( https://github.com/PhilippeR26/starknet.js-workshop-typescript/blob/main/src/scripts/ledgerNano/6.testLedgerAccount211.ts ) and in a demo DAPP ( https://github.com/PhilippeR26/Starknet-Ledger-Wallet )

Checklist:

  • Performed a self-review of the code
  • Rebased to the last commit of the target branch (or merged it into my branch)
  • Documented the changes in code (API docs will be generated automatically)
  • Updated the tests
  • All tests are passing

@PhilippeR26 PhilippeR26 marked this pull request as ready for review October 11, 2024 10:24
txDetails: V2InvocationsSignerDetails,
calls: Call[]
): Promise<{ hash: bigint; signature: Signature }> {
// APDU 0 for path
Copy link
Collaborator

Choose a reason for hiding this comment

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

what is APDU ? :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's a Ledger wording, about a batch of bytes exchanged with a Nano.

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.

2 participants