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

crypto/keys: improve documentation #5833

Merged
merged 3 commits into from
Mar 19, 2020
Merged

Conversation

alessio
Copy link
Contributor

@alessio alessio commented Mar 19, 2020

Replace out of date crypto/keys README.md file
with crypto/keys package documentation.

Populate client keys commands help screen with
more information regarding keyring backends.

Forked from: #5822


For contributor use:

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer

For admin use:

  • Added appropriate labels to PR (ex. WIP, R4R, docs, etc)
  • Reviewers assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@alessio alessio added the R4R label Mar 19, 2020
@alessio alessio mentioned this pull request Mar 19, 2020
11 tasks
@alessio alessio added the T:Docs Changes and features related to documentation. label Mar 19, 2020
@@ -0,0 +1,47 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

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

package comment should not have leading space (from golint)

Copy link
Contributor

@alexanderbez alexanderbez Mar 19, 2020

Choose a reason for hiding this comment

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

Have you viewed the rendered godoc locally for this? This shouldn't be indented like this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alessio alessio requested a review from gamarin2 March 19, 2020 11:50
@codecov
Copy link

codecov bot commented Mar 19, 2020

Codecov Report

Merging #5833 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5833      +/-   ##
==========================================
+ Coverage    32.3%   32.33%   +0.02%     
==========================================
  Files         353      353              
  Lines       39461    39475      +14     
==========================================
+ Hits        12749    12763      +14     
  Misses      25439    25439              
  Partials     1273     1273
Impacted Files Coverage Δ
crypto/keys/keyring.go 51.91% <ø> (ø) ⬆️
client/keys/root.go 100% <100%> (ø) ⬆️

Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

Minor formatting nits, other LGTM.

@@ -0,0 +1,47 @@
/*
Copy link
Contributor

@alexanderbez alexanderbez Mar 19, 2020

Choose a reason for hiding this comment

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

Have you viewed the rendered godoc locally for this? This shouldn't be indented like this.

as well as operating system-agnostic encrypted file-based backends.

The backends:
os The instance returned by this constructor uses the operating system's default
Copy link
Contributor

Choose a reason for hiding this comment

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

Formatting seems off here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tested with go doc

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, but it seems off. The os doesn't line up with the other entries.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh I see why. I used tabs for formatting (same as https://golang.org/src/fmt/doc.go). Rendered result seems correctly aligned though (see below)

client/keys/root.go Outdated Show resolved Hide resolved
client/keys/root.go Outdated Show resolved Hide resolved
client/keys/root.go Outdated Show resolved Hide resolved
client/keys/root.go Outdated Show resolved Hide resolved
client/keys/root.go Outdated Show resolved Hide resolved
client/keys/root.go Outdated Show resolved Hide resolved
@alessio
Copy link
Contributor Author

alessio commented Mar 19, 2020

This is how go doc renders the doc @alexanderbez - I'll test it with -html too shortly:

alessio@bangalter:~/work/cosmos-sdk$ go doc ./crypto/keys/
package keys // import "github.com/cosmos/cosmos-sdk/crypto/keys"

Package keys provides common key management API.


The Keybase interface

The Keybase interface defines the methods that a type needs to implement to
be used as key storage backend. This package provides few implementations
out-of-the-box.


New

The New constructor returns an on-disk implementation backed by LevelDB
storage that has been the default implementation used by the SDK until
v0.38.0. Due to security concerns, it is recommended to drop it in favor of
the NewKeyring or NewKeyringFile constructors as it will be removed in
future releases.


NewInMemory

The NewInMemory constructor returns an implementation backed by an
in-memory, goroutine-safe map that has historically been used for testing
purposes or on-the-fly key generation as the generated keys are discarded
when the process terminates or the type instance is garbage collected.


NewKeyring

The NewKeyring constructor returns an implementation backed by a keyring
library (https://github.com/99designs/keyring), whose aim is to provide a
common abstraction and uniform interface between secret stores available for
Windows, macOS, and most GNU/Linux distributions as well as operating
system-agnostic encrypted file-based backends.

The backends:

    os		The instance returned by this constructor uses the operating system's default
    		credentials store to handle keys storage operations securely. It should be noted
    		that the keyring keyring may be kept unlocked for the whole duration of the user
    		session.
    file	This backend more closely resembles the previous keyring storage used prior to
    		v0.38.1. It stores the keyring encrypted within the apps configuration directory.
    		This keyring will request a password each time it is accessed, which may occur
    		multiple times in a single command resulting in repeated password prompts.
    kwallet	This backend uses KDE Wallet Manager as a credentials management application:
    		https://github.com/KDE/kwallet
    pass	This backend uses the pass command line utility to store and retrieve keys:
    		https://www.passwordstore.org/
    test	This backend stores keys insecurely to disk. It does not prompt for a password to
    		be unlocked and it should be use only for testing purposes.

Remove out of date crypto/keys README.md file.

Populate client keys commands help screen with
more information regarding keyring backends.
Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

ACK -- pending CI lint fix 🍊

@alessio alessio added the A:automerge Automatically merge PR once all prerequisites pass. label Mar 19, 2020
@mergify mergify bot merged commit 230a1e8 into master Mar 19, 2020
@mergify mergify bot deleted the alessio/refactor-keys-docs branch March 19, 2020 16:58
rootulp added a commit to rootulp/cosmos-sdk that referenced this pull request Nov 10, 2022
This doc comment was written when the package was previously called keys: cosmos#5833
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass. T:Docs Changes and features related to documentation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants