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

Adding Ledger Signer support #1168

Closed
amanusk opened this issue Jul 2, 2024 · 9 comments
Closed

Adding Ledger Signer support #1168

amanusk opened this issue Jul 2, 2024 · 9 comments
Assignees
Labels
Type: feature New feature or request

Comments

@amanusk
Copy link
Contributor

amanusk commented Jul 2, 2024

Is your feature request related to a problem? Please describe.
Ledger now has a Starknet App, supporting singing transactions with Stark Curve on Ledger. Any existing Starknet account can now be used with Ledger as a signer.

Describe the solution you'd like
Add a custom LedgerSigner to starknet.js

This can be part of a broader generic signer implementation, but provided as part of the SDK for simpler integration

Additional context
Reference implementation on starknet-rs:

https://github.com/xJonathanLEI/starknet-rs/blob/db1fa598232f0698d942cc974f481b5d888ac080/starknet-signers/src/ledger.rs

@amanusk amanusk added the Type: feature New feature or request label Jul 2, 2024
@ivpavici
Copy link
Collaborator

ivpavici commented Jul 2, 2024

relevant:
#748

@PhilippeR26
Copy link
Collaborator

PhilippeR26 commented Jul 2, 2024

@amanusk Is it a JS/TS equivalence to the rust library coins-ledger?
Any documentation from ledger to have an understanding of how it works?

@PhilippeR26
Copy link
Collaborator

My (very) old Nano S is not compatible with the Starknet ledger APP.
So, I ordered a new Nano X, to test it.
ledgerNanoX
Nice!

@PhilippeR26
Copy link
Collaborator

PhilippeR26 commented Jul 8, 2024

I can communicate with it :

TransportNodeHid {
  exchangeTimeout: 30000,
  unresponsiveTimeout: 15000,
  deviceModel: {
    id: 'nanoX',
    productName: 'Ledger Nano X',
    productIdMM: 64,
    legacyUsbProductId: 4,
    usbOnly: false,
    memorySize: 2097152,
    masks: [ 855638016 ],
    getBlockSize: [Function: getBlockSize],
    bluetoothSpec: [ [Object] ]
  },

I have now to dig, to

  • recover the pubkey
  • sign a hash (as the ledger APP is not able to build a transaction)

@PhilippeR26
Copy link
Collaborator

The job to perform is mainly to create code for these 2 red parts :
LedgerArchitecture
for 3 methods :

  • getVersion
  • getPubKey
  • sign

@PhilippeR26 PhilippeR26 self-assigned this Jul 8, 2024
@PhilippeR26
Copy link
Collaborator

It was difficult, but it works.
The documentation is full of errors or missing data : https://github.com/LedgerHQ/app-starknet/blob/develop/docs/apdu.md
The current code works only in Node for a Ledger connected with USB. I have to see how to handle Web USB & Web Bluethooth...

@PhilippeR26
Copy link
Collaborator

Made with a Starknet.js Signer :
Capture d’écran du 2024-07-16 19-43-16

@PhilippeR26
Copy link
Collaborator

Ledger Nano X is not accepted with a Bluetooth connection, in my Linux Mint (Chrome, Brave, FireFox).
I have no knowledge about React native; so I didn't tested in mobile.
So, it works in my config in Node script & in Web DAPP (both connected with USB).

@PhilippeR26
Copy link
Collaborator

@ivpavici
I will propose a PR for the corresponding Signer.

@PhilippeR26 PhilippeR26 mentioned this issue Jul 24, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: feature New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants