-
Notifications
You must be signed in to change notification settings - Fork 20
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
feat: add cookbook recipe how to generate keys #223
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Some small things... Could you explain what happens in the the code?
- how are the keys generated?
- why are some using derivation paths?
- why use the base mnemonic for the authentication key?
Could you also add links to the places where this might be interesting? e.g. DID creation?
code_examples/sdk_examples/src/core_features/did/00_generate_did_keys.ts
Outdated
Show resolved
Hide resolved
@weichweich I addressed all of your comments, PTAL :) |
10553b9
to
89dba2e
Compare
This pull request is automatically being deployed by Amplify Hosting (learn more). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still would like to see something that explains the derivation paths.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you add a mention to Sporran, explaining that the derivation path shown is the same Sporran uses, it's good to go!
// This allows us to restore all keys related to this DID from a single mnemonic seed phrase. | ||
// The chosen derivation pathes can be anything, but here we use the purpuse of the keys to be generated. | ||
const authenticationKey = baseSignerKey.derive( | ||
'//authentication' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we follow the way Sporran does it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I was about to update this. This would mean that our current accounts and DIDs used in the testing would break but hopefully fix itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though we already have this in the utils
folder in the core_features
. Therefore, I would take over this PR and sort it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it is good to make it consistent with the workshop, that is already using the derivation paths from sporran.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I was going to basically copy pasta it in.
Creating a DID (like in [Light DID Creation](./01_light_did_creation.md) or [Full DID Creation](./02_full_did_creation.md)) requires the generation of some keying material for keys that are to be used for authentication and encryption. | ||
|
||
The following is an example of how to create a a set of keypairs suitable for generating a KILT DID from it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe something like this:
Creating a DID (like in [Light DID Creation](./01_light_did_creation.md) or [Full DID Creation](./02_full_did_creation.md)) requires the generation of some keying material for keys that are to be used for authentication and encryption. | |
The following is an example of how to create a a set of keypairs suitable for generating a KILT DID from it. | |
Creating a Decentralized Identifier (DID) in the KILT network involves generating keying material for authentication and encryption. In this guide, we'll demonstrate how to create a set of key pairs suitable for generating a KILT DID. | |
Before we proceed, it's important to note that this example assumes the usage of the @kiltprotocol/sdk-js library along with the @polkadot/util-crypto library for cryptographic operations. Additionally, we want to emphasize the significance of securely storing keys and the mnemonic seed phrase. For production use, ensure that private keys are encrypted and stored safely, while also creating a backup of the mnemonic seed phrase. | |
Below is an example code snippet illustrating the key pair generation for a KILT DID: |
Also please explain the reason for the derivation paths
Maybe like that:
In the example provided, we derive different types of keys from a single account using derivation paths. This approach allows us to generate various key pairs for authentication, key agreement, assertion methods, and capability delegation from one mnemonic seed phrase. Using derivation paths simplifies key management, ensuring that a single mnemonic seed serves as the basis for multiple keys associated with a DID. This method improves efficiency while maintaining security. However, it's essential to handle and store private keys securely to prevent unauthorized access and ensure the overall integrity and privacy of the decentralized identity system.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤖
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
soooo much 🤖
e02e592
to
a9895e8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Co-authored-by: Albrecht <[email protected]>
* feat: add cookbook recipe how to generate keys (taken from the workshop section) * fix broken test * run prettier * try to fix test * prettier * try to fix test * prettier * add more explanations about derivation pathes * feat: updating to match sporran and updating naming throughout to match * lint: updating the linting * feat: removal of the mention of light did * feat: adding remarks and suggestions for better text * Update docs/develop/01_sdk/02_cookbook/01_dids/00_generate_keys.md Co-authored-by: Albrecht <[email protected]> --------- Co-authored-by: dudleyneedham <[email protected]> Co-authored-by: Skedley <[email protected]> Co-authored-by: Albrecht <[email protected]>
* feat: add cookbook recipe how to generate keys (taken from the workshop section) * fix broken test * run prettier * try to fix test * prettier * try to fix test * prettier * add more explanations about derivation pathes * feat: updating to match sporran and updating naming throughout to match * lint: updating the linting * feat: removal of the mention of light did * feat: adding remarks and suggestions for better text * Update docs/develop/01_sdk/02_cookbook/01_dids/00_generate_keys.md Co-authored-by: Albrecht <[email protected]> --------- Co-authored-by: dudleyneedham <[email protected]> Co-authored-by: Skedley <[email protected]> Co-authored-by: Albrecht <[email protected]>
This adds a cookbook recipe how to generate all keys necessary for the following recipes, so a user can start at zero.
fixes KILTProtocol/ticket#2373
How to test:
Build the docs and go to the DID section of the cookbook. The very first item is new and explains how to generate keys.
Checklist: