-
Notifications
You must be signed in to change notification settings - Fork 33
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
[Client Tooling] Keybase (issue #455) #459
Conversation
… function for KeyPair struct and update comments
Thanks to @jessicadaugherty for giving me a hint to what might be the issue - HEX ENCODING!. V0's Import/Export JSON is fully interoperable between V0 and V1 now: When encrypting the private key now convert the hex encoded private key string to This is instead of directly getting the result of Now when decrypting we must do another conversion/decoding step: And the private key is then created from |
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.
This is really impressive work, in terms of quality, speed and impact.
Regarding your comment that fixes the V0 <-> V1 conversion. Tbh, I'm not a fan of all the data transformations, and I'm sure there's some redundancy since we ported some of the crypto library logic in v0.
If you see opportunities to clean it up in the future, just go for it.
I will follow up in #455 regarding some next steps on this & other tickets.
@Olshansk I have left a reply to the |
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.
@h5law Almost over the finish line.
Left a couple small comments but also took the liberty to make some updates to the README while reading through it.
Take a look and fill free to update anything I missed or misrepresented.
Should be good to go afterwards.
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.
One small comment but otherwise LGTM 🔥
## Description Following the merge of #459 the `app/client/cli/doc` directory has moved to `app/client/doc` this PR fixes the links in the README ## Issue Fixes N/A ## Type of change Please mark the relevant option(s): - [ ] New feature, functionality or library - [ ] Bug fix - [ ] Code health or cleanup - [ ] Major breaking change - [x] Documentation - [ ] Other <!-- add details here if it a different type of change --> ## List of changes - Fix links to app documentation - Change CLI to APP in links ## 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` ## 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 - [x] 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)
Description
This is an implementation of a Keybase for the pocket V1 client.
It uses
BadgerDB
as the local database for the persistent storage of keys. The currentKeybase
interface has the following methodsThese are covered with the following tests
The tests use an in-memory database created with
NewKeybaseInMemory()
whereas when exposed to the user the CLI should callNewKeybase()
instead with a default path/user-supplied path. The CLI integration has not been implemented as part of this PR however.How it works
The keybase heavily relies upon
shared/crypto/ed25519.go
and thePublicKey
andPrivateKey
interfaces it exposes.The keys are created using the methods from this library. Keys are then encrypted and armoured in the same fashion as in V0 and stored in the DB as a
KeyPair
struct (encoded to a[]byte
).This struct contains the public key and the encrypted JSON encoded private key string. This struct has the following methods:
GetAddressBytes() []byte
-> returns[]byte
of the public key addressGetAddressString() string
-> returns the hexstring
of the public key addressUnarmour(passphrase string) (crypto.PrivateKey, error)
-> returns the unencrypted unarmoured private key if passphrase is correctExportString(passphrase string) (string, error)
-> returns raw private key string is passphrase is correctExportJSON(passphrase string) (string, error)
-> returns json armoured private key string if the passphrase is correctKeys are stored in the database in the following manner:
[]byte
value returned byKeyPair.GetAddressBytes()
aka the[]byte
address of the public key[]byte
encodedKeyPair
structs of the keyKey encryption/decryption works with or without a passphrase (when no passphrase is given
""
must still be passed to the function as the passphrase argument)For ease of use the hex
string
returned byKeyPair.GetAddressString()
is used to access the keys in storage.Importing and exporting keys in either JSON string format or the private key hex string is fully interoperable between V1 and V0
Signing and Verification of messages works - and is covered with a Tx in the tests. I would need to look into the use cases for this more (for example multisig) as the current implementation is very rudimentary and in theory should work for producing a signature on any
[]byte
message but I would like to look into this more.Issue
Fixes #455
Type of change
Please mark the relevant option(s):
List of changes
make test_app
entry point in MakefileTesting
make develop_test
README
Required Checklist
If Applicable Checklist
shared/docs/*
if I updatedshared/*
README(s)