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

Updates FLIP 200 with new proposal updates #727

Merged
merged 11 commits into from
Dec 22, 2021

Conversation

JeffreyDoyle
Copy link
Member

Description

Updates FLIP 200 with new proposal updates

@vercel
Copy link

vercel bot commented Dec 11, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/onflow/flow-docs/D3nhtoUALfKt9CT397r8A95X9awj
✅ Preview: https://flow-docs-git-hd-accounts-updates-dec-2021-onflow.vercel.app

Copy link
Contributor

@psiemens psiemens left a comment

Choose a reason for hiding this comment

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

flips/20201125-bip-44-multi-account.md Outdated Show resolved Hide resolved
flips/20201125-bip-44-multi-account.md Outdated Show resolved Hide resolved
Comment on lines 114 to 115
There exist Flow accounts with keys on them which have been generated using the
Legacy Path.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can be explicit here and mention that, up until now, the Ledger application created Flow accounts using a different interpretation of BIP 44 that we now refer to as the legacy path. And to our knowledge, this is the only application that created accounts in this way.

Great idea to mention the legacy path here!

flips/20201125-bip-44-multi-account.md Show resolved Hide resolved
Copy link
Contributor

@tarakby tarakby left a comment

Choose a reason for hiding this comment

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

Nicely written update 👏🏼

The prescribed account discovery procedure is as follows:

1. Derive the key pair using the legacy path, checking it's use with the
public key registry. If an address is found, query the Flow network to fetch
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the first mention of "public key registry" in the document, maybe we should define what it is first and assume it is available for the account discovery algorithm

The legacy path is:

```
m / 44' / 1' / 769 / 0 / 0
Copy link
Contributor

Choose a reason for hiding this comment

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

The key derived from a path depends on the curve used. The derivation process gives different raw keys (not talking about account public keys) when used with a different curve. We can see the function as

derive_key(path, curve)  (raw_private_key, raw_public_key)

In the case of the legacy path, we will need to precise that the curve used was NIST P-256. Of course, any wallet can try looking for keys from the 2 curves, but I think it's helpful to precise what curve the legacy path has been using.

We might need 2 lines to remind that keys on Flow are ECDSA keys on 2 different curves.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with Tarak's suggestion. All keys created to date have been on the P-256 curve, so let's specify that alongside the legacy path.

Copy link
Member Author

Choose a reason for hiding this comment

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

@tarakby Do we need to be concerned with BLS keys? Or just ECDSA_P256 and ECDSA_secp256k1 ?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, BLS is not supported by Flow accounts (BLS is just supported by Cadence, that's why you might see it in Cadence docs).

public key registry. If an address is found, query the Flow network to fetch
the account's details. If an account is found, remember the relationship between the
path used to generate this key, and the account's details.
2. Derive a key pair (starting with account index = 0 and key index =
Copy link
Contributor

Choose a reason for hiding this comment

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

In step 2, the algorithm needs to iterate over the supported elliptic curves (2 for now), before incrementing the index. As mentioned above, the raw key itself is different for each curve.
Only if both keys were not found, the algorithm can assume the path is not used.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated to include iterating over both the supported curves, and hashing algorithms as well

Comment on lines 147 to 150
3.1. If no address is found in the registry
3.1.1 If the key index gap limit has been reached without finding any
addressed in the registry, then go to step 2, incrementing the account index
by one and starting with key index = 0 again.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think there is no mention of the account index gap yet.

Suggested change
3.1. If no address is found in the registry
3.1.1 If the key index gap limit has been reached without finding any
addressed in the registry, then go to step 2, incrementing the account index
by one and starting with key index = 0 again.
3.1. If no address is found in the registry
3.1.1 If the key index gap limit has been reached without finding any
addressed in the registry, then go to step 2, incrementing the account index
by one and starting with key index = 0 again. If the account index gap limit
has been reached, the discovery is over.

Copy link
Member Author

Choose a reason for hiding this comment

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

We introduce the account index gap limit before the discovery algorithm. I want to keep the termination step for the algorithm in step 3, because the terminal state for the algorithm is when both the account index gap limit, and the key index gap limit have been reached

Copy link
Contributor

Choose a reason for hiding this comment

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

You're right, the account gap is already defined earlier 👌🏼
What I meant is that the algorithm (steps 1. 2. 3.) does not describe what to do with the account gap (while it describes how to deal with the key gap).

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yes, the account gap limit is increased when the algorithm hits step 3.1.1

Comment on lines +184 to +189
- If adding a key to an existing account:
- The largest account index that account discovery determines has been
previously used to generate existing keys set on the account, which has also
not been used incorrectly to generate keys set on another account.
- Otherwise, the smallest account index which has not yet been used to
generate keys set on any account.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I see what this sentence means 👌🏼 but I'm sure examples will make it clearer 😅 I'm not saying the examples need to be added to this document.

Comment on lines +193 to +195
When generating additional keys for an account, the correct key index to
use in the path to generate the new key should be the smallest unused key index
available which has not yet been used to generate a key on the account.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is great, and should be enough.
To avoid confusion we could also add that a path used with at least one curve is considered "used". This would prevent wallets saying "the path has been used with curve_1, but it hasn't been used with key_2 yet, so I'm gonna use it again".

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a new conflict resolution section for this purpose 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

The new section is great 👌🏼

Comment on lines 160 to 162
<sup>1</sup>Flow supports account deletion, meaning that an address found in the
registry may refer to a nonexistent account. In this case the account should be
skipped but discovery should continue.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is great! Should we also add a similar note for revoked keys? I mean we could precise if we consider a path leading to a revoked key, as a "used" path or a "free" path.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it might depend on how the Public Key registry / Hardware Wallet API will have to work. If it returns back addresses for keys that are on the account but are also revoked, i'm less worried about confusion here than if it doesn't return addresses for such keys.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep good point, I think this could be precised on the key registry side.

Comment on lines +38 to +39
BIP 44 defines an implementation of [Bitcoin Improvement Proposal
32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) (BIP 32)
Copy link
Contributor

Choose a reason for hiding this comment

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

The issue with BIP44 and BIP32 is that they only define the derivation on curve secp256k1.
Referencing BIP32 shouldn't be enough to apply the derivation to another curve, unless we define how we want to generalize the BIP32 technique to other curves.

There is a SLIP that did something similar "SLIP-0010 describes how to derive private and public key pairs for curve types different from secp256k1." but I'm having minor concerns with it.
I'll reach out to Vacuum Labs and maybe Ledger to see if there is a known generalization we can reference, otherwise we might need to describe the generalization ourselves (not long). I'll follow up on this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Update: I reached out to Ledger, but I looks like the answer will come after the holidays. Their answer should help us update FLIP200 (the current doc cannot be complete without specifying this curve derivation point unfortunately)

cc @JeffreyDoyle

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @tarakby. Let's move this discussion to #200 so it doesn't get lost

The legacy path is:

```
m / 44' / 1' / 769 / 0 / 0
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with Tarak's suggestion. All keys created to date have been on the P-256 curve, so let's specify that alongside the legacy path.

flips/20201125-bip-44-multi-account.md Outdated Show resolved Hide resolved
flips/20201125-bip-44-multi-account.md Outdated Show resolved Hide resolved
flips/20201125-bip-44-multi-account.md Outdated Show resolved Hide resolved
Copy link
Contributor

@psiemens psiemens left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@JeffreyDoyle JeffreyDoyle merged commit 6444dbd into hd-accounts Dec 22, 2021
@psiemens psiemens deleted the hd-accounts-updates-dec-2021 branch December 22, 2021 04:49
pgebheim pushed a commit that referenced this pull request Jul 11, 2022
* First draft of FLIP: "Application of BIP 44 in Flow Wallets"

* Update 20201125-bip-44-multi-account.md

* Update FLIP 200 based on discussion feedback

* Update account discovery to cover deleted accounts

* Update 20201125-bip-44-multi-account.md

* Update 20201125-bip-44-multi-account.md

* Update prior art

* Update flips/20201125-bip-44-multi-account.md

Co-authored-by: Rob Myers <rob@robmyers.org>

* Updates FLIP 200 with new proposal updates (#727)

* Updates FLIP 200 with new proposal updates

* Updates FLIP 200 with new proposal updates

* Updates FLIP 200 with new proposal updates

* Updates FLIP 200 with new proposal updates

* Updates FLIP 200 with new proposal updates

* Updates FLIP 200 with new proposal updates

* Updates FLIP 200 with new proposal updates

* Updates FLIP 200 with new proposal updates

* Updates FLIP 200 with new proposal updates

* Updates FLIP 200 with new proposal updates

* Updates FLIP 200 with new proposal updates

* Update 20201125-bip-44-multi-account.md

* mention SLIP-10

* Specify that Key & Account index gap limits are flexible (#832)

* Update 20201125-bip-44-multi-account.md

Co-authored-by: Rob Myers <rob@robmyers.org>
Co-authored-by: Jeff Doyle <jeffrey.doyle@dapperlabs.com>
Co-authored-by: Tarak Ben Youssef <50252200+tarakby@users.noreply.github.com>
Co-authored-by: Tarak Ben Youssef <tarak.benyoussef@dapperlabs.com>
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.

4 participants