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

[Keybase] Miniature Keybase Implementation to Enable M1 - Create and Delete #150

Closed
10 tasks
Tracked by #455
andrewnguyen22 opened this issue Aug 5, 2022 · 12 comments
Closed
10 tasks
Tracked by #455
Assignees
Labels
client work needed to interface with the node (rpc, cli, etc..) community Open to or owned by a non-core team member tooling tooling to support development, testing et al

Comments

@andrewnguyen22
Copy link
Contributor

andrewnguyen22 commented Aug 5, 2022

Objective

Create a miniature Keybase that can create, store, and delete keys

Origin Document

In order to achieve the M1 milestone a mini-keybase implementation is needed to enable dynamic accounts and actors.

This keybase may be used for the following tasks:

  • Signing blocks
  • Signing transactions
  • Signing arbitrary messages
  • Signing multi-sig messages

Goals / Deliverables

Mini ED-25519 Keybase:

  • Code complete implementation of:
    • CREATE and store keys
    • DELETE keys
  • Document the key architecture

Non-Goals / Deliverables

  • Integrating Keybase with the CLI or other parts of the codebase
  • Implementing multisig

General issue checklist

  • Update the appropriate CHANGELOG
  • Update the README
  • If applicable, update the source code tree explanation
  • If applicable, add or update a state, sequence or flowchart diagram using mermaid
  • Update any relevant global documentation & references
  • Document small issues / TODOs along the way

Creator: @andrewnguyen22

@andrewnguyen22
Copy link
Contributor Author

NOTE: Please use the /shared/crypto/ed25519 as the P/K library

@andrewnguyen22
Copy link
Contributor Author

Recommend to use a filesystem db for the implementation

Currently we are between Badger.db and Level.db

Please use one of these two options

@Olshansk Olshansk added community Open to or owned by a non-core team member tooling tooling to support development, testing et al labels Aug 5, 2022
@Olshansk Olshansk moved this to Todo in V1 Dashboard Aug 5, 2022
@Olshansk
Copy link
Member

tl;dr @adshmh Could you or someone on your team take this on?

@andrewnguyen22 did a detailed job at explaining what we need from a basic keybase solution. This is a precursor that can be worked on in parallel with the CLI being built by @deblasis: https://github.com/pokt-network/pocket/pull/169/files

The keybase doesn't need to be anything fancy, and I think it can actually be copy-pastad or extracted from V0, tendermint or ignite CLI? For example, just using main/client/keys and taking out the pieces we need.

@Olshansk Olshansk added priority:high client work needed to interface with the node (rpc, cli, etc..) and removed priority:medium labels Aug 27, 2022
@Olshansk Olshansk moved this from TODO to Up Next in V1 Dashboard Sep 4, 2022
@jessicadaugherty jessicadaugherty moved this from Up Next to Rescope / decompose in V1 Dashboard Sep 6, 2022
@jessicadaugherty jessicadaugherty changed the title [Keybase] Miniature Keybase Implementation to Enable M1 [Keybase] Miniature Keybase Implementation to Enable M1 - Create and Delete Sep 12, 2022
@jessicadaugherty jessicadaugherty moved this from Rescope / decompose to Up Next in V1 Dashboard Sep 12, 2022
@jessicadaugherty jessicadaugherty moved this from Up Next to Backlog in V1 Dashboard Oct 3, 2022
@Olshansk
Copy link
Member

@Jasonyou1995 When you have time to tackle things, one thing I would suggest is doing a bit of research & learning about what a keybase is and how it works. For example, see the summary of the research @deblasis did on the state of RPC in the crypto industry here: #213

As someone who has never built one myself, here is how I would go about it:

  1. Get some high level context googling / researching and reading through, for example, this: https://keybase.io/docs/api/1.0
  2. Seeing what their API / specs are like: https://keybase.io/docs/api/1.0/call/key/add
  3. Installing the Pocket V0 CLI and seeing the tools available there as a reference
    Screen Shot 2022-10-28 at 10 29 01 AM
  4. I would then look at the "latest and greatest" tools in the market when it comes to node interaction (e.g. https://ignite.com/)
  5. After diving into the code, I found this: https://github.com/ignite/cli/blob/7996b0a3ea0ea528e9558542defcd47c4cd6f1b5/ignite/pkg/cosmoscmd/root.go#L246
    Screen Shot 2022-10-28 at 10 31 13 AM
  6. It looks like (based on the import), that they use cosmos, which led me here: https://github.com/cosmos/cosmos-sdk/tree/main/client/keys
  7. Since the keybase isn't something very unique to Pocket, but something we 100% need, and because v0 is a fork of cosmos, I think that using this as a reference is the way to go.
  8. I would personally copy-pasta only the parts we need (e.g. create in this PR), make w/e improvements I find, and customize it to Pocket's utility.

Lmk if that's enough context to get you going.

@Jasonyou1995
Copy link
Contributor

I'm working on this issue now! Thank you so much for the detailed guide. It's very helpful for me to get started.

@jessicadaugherty jessicadaugherty moved this from Backlog to In Progress in V1 Dashboard Oct 31, 2022
@jessicadaugherty jessicadaugherty changed the title [Keybase] Miniature Keybase Implementation to Enable M1 - Create and Delete [Keybase] Miniature Keybase Implementation to Enable M1 - Entry Point +Create and Delete Nov 2, 2022
@jessicadaugherty jessicadaugherty changed the title [Keybase] Miniature Keybase Implementation to Enable M1 - Entry Point +Create and Delete [Keybase] Miniature Keybase Implementation to Enable M1 - Entry Point + Create and Delete Nov 2, 2022
@Olshansk Olshansk changed the title [Keybase] Miniature Keybase Implementation to Enable M1 - Entry Point + Create and Delete [Keybase] Miniature Keybase Implementation to Enable M1 - Create and Delete Nov 3, 2022
@Olshansk
Copy link
Member

Olshansk commented Nov 3, 2022

@Jasonyou1995 I've removed entrypoint from this PR.

Check out the demo @deblasis documented in #169


In v0, here are the entrypoints for create and delete

Screen Shot 2022-11-03 at 10 09 40 AM


In V1, @deblasis set us up for something equally as simple:

199353588-46f3987f-49e0-445d-b229-39682d4af881

Also, now that we merged in #177, you can search for TODO(#150) in the codebase and find places that need to be updated. https://github.com/pokt-network/pocket/search?q=%22TODO%28%23150%29%22

Screen Shot 2022-11-03 at 10 12 20 AM

@Jasonyou1995
Copy link
Contributor

Thanks for the clarification @Olshansk! Here are some questions I have:

  1. I assume I'm implementing the miniature Keybase in the utility package to update the [Keybase] Miniature Keybase Implementation to Enable M1 - Create and Delete #150 marked functions with Keybase functions (create and delete).
  2. My local Client is V0, and I couldn't see how the V1 entry point change will change how I implement Keybase. Could you please explain a little? Thanks!

@Olshansk
Copy link
Member

Olshansk commented Nov 3, 2022

  1. It'll be part of the + some local (host) state you need to maintain. The utility module will simply get the private key.
  2. Same idea but in a different codebase & with a different binary.

@Jasonyou1995
Copy link
Contributor

Jasonyou1995 commented Nov 7, 2022

Notes

  • Discuss with Alessandro for integration and general requirements.
  • Security requirements: documenting security tasks for future issues.
  • Current stage: V0 entry point integration is expected. (potentially V1 integration)

@Jasonyou1995 Jasonyou1995 linked a pull request Nov 7, 2022 that will close this issue
19 tasks
@Olshansk
Copy link
Member

Olshansk commented Nov 8, 2022

  • Discuss with Alessandro for integration and general requirements.

Per my comment above, I also believe the demo @deblasis put together is a great starting point too: #150 (comment)

  • Security requirements: documenting security tasks for future issues.

This is VERY optional if you find / learn something interesting along the way.

For example, see the discussion related to ASCII armored JSON files here: https://docs.pokt.network/node/setup/

  • Current stage: V0 entry point integration is expected. (potentially V1 integration)

We only expect an integration with V1 (i.e. this repo). The entrypoint is the CLI @deblasis is working on. The approach will be similar (though not identical) to that of V0.

@Jasonyou1995 Jasonyou1995 moved this from In Progress to In Review in V1 Dashboard Nov 15, 2022
@jessicadaugherty jessicadaugherty moved this from In Review to Rescope in V1 Dashboard Nov 29, 2022
@Olshansk
Copy link
Member

Came by this while scowering other repos: https://github.com/celestiaorg/celestia-node/blob/main/libs/keystore/keystore.go

Could be an additional good reference for our keybase/keystore

@Olshansk
Copy link
Member

See #338 as a reference for future iterations of this work.

@jessicadaugherty jessicadaugherty moved this from Rescope to Backlog in V1 Dashboard Jan 9, 2023
@jessicadaugherty jessicadaugherty moved this from Backlog to In Progress in V1 Dashboard Jan 24, 2023
h5law added a commit that referenced this issue Feb 14, 2023
## Description

This PR addresses the `#150` comments throughout the `app/client/cli`
directory and integrates the keybase to be used in place of reading keys
from files locally.

The new method has been added to the `debug/keystore.go` file
`InitialiseDebugKeybase()` which reads the 999 validator private keys
from the `build/localnet/manifests/private-keys.yaml` file and stores
them in the keybase. This is only run when there are less than 999 keys
in the keybase. To speed this up `BadgerDB`'s `WriteBatch()` function is
being used - however due to the encryption/JSON encoding and then Gob
encoding steps of adding private keys to the keybase this takes a few
seconds when ran for the first time.

This PR does not add any endpoints to interact with the keybase from the
CLI this is instead tracked in the issue #489

## Issue

Fixes #484 

## Type of change

Please mark the relevant option(s):

- [x] New feature, functionality or library
- [ ] Bug fix
- [x] Code health or cleanup
- [ ] Major breaking change
- [ ] Documentation
- [ ] Other <!-- add details here if it a different type of change -->

## List of changes

- Add logic to initialise keybase with 999 validator keys
- Update `app/client/cli` to use the keybase


## Testing

- [x] `make develop_test`
- [x]
[LocalNet](https://github.com/pokt-network/pocket/blob/main/docs/development/README.md)
w/ all of the steps outlined in the `README`


[localnet_with_integration.webm](https://user-images.githubusercontent.com/53987565/217543043-21c35c3e-8389-44a5-968a-d3afb6cb8dd9.webm)

## Required Checklist

- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have tested my changes using the available tooling
- [x] I have updated the corresponding CHANGELOG

### If Applicable Checklist

- [ ] I have updated the corresponding README(s); local and/or global
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] I have added, or updated,
[mermaid.js](https://mermaid-js.github.io) diagrams in the corresponding
README(s)
- [ ] I have added, or updated, documentation and
[mermaid.js](https://mermaid-js.github.io) diagrams in `shared/docs/*`
if I updated `shared/*`README(s)
@jessicadaugherty jessicadaugherty moved this from In Progress to Done in V1 Dashboard Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client work needed to interface with the node (rpc, cli, etc..) community Open to or owned by a non-core team member tooling tooling to support development, testing et al
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

6 participants