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

[Feature] Generate Wallet from secret numbers #1799

Merged
merged 35 commits into from
Aug 15, 2023

Conversation

nixer89
Copy link
Collaborator

@nixer89 nixer89 commented Nov 15, 2021

Generate Wallet from Secret Numbers

  • added "fromSecretNumbers" method to Wallet instance
  • added tests for new "fromSercretNumbers method

Context of Change

This PR introduces a new feature. Many people are using XUMM. XUMM offers the recovery key for the user as Secret Numbers
To make it easy for developers to use their XUMM managed account for their development work, a new Method, "Wallet.fromSercretNumbers" is introduces. This method generates a new Wallet instance by the given Secret Numbers.

Alternatively, the developer had to first derive the family seed / secret key from the Secret Numbers and use the seed to initiate the Wallet instance.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (non-breaking change that only restructures code)
  • Tests (You added tests for code that already exists, or your new feature included in this PR)
  • Documentation Updates
  • Release

Test Plan

Tests can be found in the index.ts of the /test/Wallet directory

Future Tasks

The documentation has to be updated / generated. I did not run the "npm run docgen" target because it did not just added my method but changed lots of other things in the docs as well. So maybe someone else can run it.

@@ -27,7 +27,8 @@
"ripple-address-codec": "^4.1.1",
"ripple-binary-codec": "^1.1.3",
"ripple-keypairs": "^1.0.3",
"ws": "^8.2.2"
"ws": "^8.2.2",
"xrpl-secret-numbers": "^0.3.3"
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this be included in the monorepo?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe wait to bring it up to the top level until another package needs it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

no i mean, should xrpl-secret-numbers's source be in this monorepo. not sure where else it's used or how big it is, but that might make sense

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am sure the XRPL-Labs team uses this lib in their XUMM app. I think @WietseWind is the maintainer?
For now I would leave it as "external" import and would not add it to the monorepo. but maybe Wietse thinks this would be a good idea :)

Copy link
Member

Choose a reason for hiding this comment

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

@ledhed2222 It's a fairly small package, and the (non dev) dependencies overlap with ripple-keypairs (brorand, ripple-keypairs)

Copy link
Collaborator

Choose a reason for hiding this comment

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

that would be a good reason to maintain it within the monorepo :)

IMO, the criteria for whether it should be part of the monorepo:

  1. is the purpose/scope of the package overlapping with the monorepo's? in this case i think it might be
  2. does it depend on other packages w/in this monorepo, potentially requiring work on it and ripple-keypairs simultaneously.

package-lock.json Outdated Show resolved Hide resolved
@intelliot intelliot changed the title Ds/wallet from secret numbers [Feature] Generate Wallet from secret numbers Nov 25, 2021
Comment on lines +348 to +357
// TODO: Uncomment this test when the `deriveKeypair` fix is merged
// it('derives a wallet using algorithm ed25519', function () {
// const algorithm = ECDSA.ed25519
// const wallet = Wallet.fromSecretNumbers(secretNumbersString, {
// algorithm,
// })

// assert.equal(wallet.publicKey, publicKeyED25519)
// assert.equal(wallet.privateKey, privateKeyED25519)
// })
Copy link
Contributor

Choose a reason for hiding this comment

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

This test fails because of this issue: #2376

Commented with a TODO to re-add the test once that PR is resolved. (Open to other ideas about what's the best way to handle this :) )

@JST5000 JST5000 requested review from mvadari, ckniffen, jonathanlei and khancode and removed request for khancode July 13, 2023 03:18
@JST5000 JST5000 force-pushed the ds/wallet-from-secret-numbers branch from 9d06e03 to a8d3a93 Compare July 18, 2023 23:31
@ckniffen
Copy link
Collaborator

Ideally I would like to see this as a function separate from Wallet class. Putting so much on the Wallet makes it impossible to tree shake.

@JST5000
Copy link
Contributor

JST5000 commented Jul 29, 2023

Ideally I would like to see this as a function separate from Wallet class. Putting so much on the Wallet makes it impossible to tree shake.

@ckniffen I think changing this to not be part of Wallet should be part of a bigger set of breaking changes to refactor how we handle Wallet generation as a whole. With our current setup, I think it makes sense to add this to the Wallet class because that's where all generators are currently.

Do you think it's worth having this be off the Wallet class before a more sweeping change?

@ckniffen
Copy link
Collaborator

One option is to deprecate the static methods in 3.0 besides fromMnemonic which is already deprecate and have those static methods call the functions.

This would allow tree shaking of fromMnemonic and fromSecretNumbers while the others are backward compatible.

Copy link
Collaborator

@ckniffen ckniffen left a comment

Choose a reason for hiding this comment

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

As long as the other PR gets merged first and the tests are corrected I am good This can be merged into 2.x since the bug fix will be in 3.x

@JST5000 JST5000 merged commit aa75806 into main Aug 15, 2023
17 checks passed
@JST5000 JST5000 deleted the ds/wallet-from-secret-numbers branch August 15, 2023 00:39
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.

9 participants