Skip to content

Commit

Permalink
docs(log,crypto,depinject/appconfig): update docs (cosmos#19625)
Browse files Browse the repository at this point in the history
Co-authored-by: Julien Robert <[email protected]>
  • Loading branch information
0x2d3c and julienrbrt authored Mar 4, 2024
1 parent 84a1ee2 commit 83a7f0e
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 58 deletions.
8 changes: 4 additions & 4 deletions crypto/armor.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ var BcryptSecurityParameter uint32 = 12
//-----------------------------------------------------------------
// add armor

// Armor the InfoBytes
// ArmorInfoBytes armor the InfoBytes
func ArmorInfoBytes(bz []byte) string {
header := map[string]string{
headerType: "Info",
Expand All @@ -72,7 +72,7 @@ func ArmorInfoBytes(bz []byte) string {
return EncodeArmor(blockTypeKeyInfo, header, bz)
}

// Armor the PubKeyBytes
// ArmorPubKeyBytes armor the PubKeyBytes
func ArmorPubKeyBytes(bz []byte, algo string) string {
header := map[string]string{
headerVersion: "0.0.1",
Expand All @@ -87,7 +87,7 @@ func ArmorPubKeyBytes(bz []byte, algo string) string {
//-----------------------------------------------------------------
// remove armor

// Unarmor the InfoBytes
// UnarmorInfoBytes unarmor the InfoBytes
func UnarmorInfoBytes(armorStr string) ([]byte, error) {
bz, header, err := unarmorBytes(armorStr, blockTypeKeyInfo)
if err != nil {
Expand Down Expand Up @@ -142,7 +142,7 @@ func unarmorBytes(armorStr, blockType string) (bz []byte, header map[string]stri
//-----------------------------------------------------------------
// encrypt/decrypt with armor

// Encrypt and armor the private key.
// EncryptArmorPrivKey encrypt and armor the private key.
func EncryptArmorPrivKey(privKey cryptotypes.PrivKey, passphrase, algo string) string {
saltBytes, encBytes := encryptPrivKey(privKey, passphrase)
header := map[string]string{
Expand Down
6 changes: 3 additions & 3 deletions crypto/keyring/keyring.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ var (

// Keyring exposes operations over a backend supported by github.com/99designs/keyring.
type Keyring interface {
// Get the backend type used in the keyring config: "file", "os", "kwallet", "pass", "test", "memory".
// Backend get the backend type used in the keyring config: "file", "os", "kwallet", "pass", "test", "memory".
Backend() string
// List all keys.
List() ([]*Record, error)

// Supported signing algorithms for Keyring and Ledger respectively.
// SupportedAlgorithms supported signing algorithms for Keyring and Ledger respectively.
SupportedAlgorithms() (SigningAlgoList, SigningAlgoList)

// Key and KeyByAddress return keys by uid and address respectively.
Expand Down Expand Up @@ -130,7 +130,7 @@ type Migrator interface {

// Exporter is implemented by key stores that support export of public and private keys.
type Exporter interface {
// Export public key
// ExportPubKeyArmor export public key
ExportPubKeyArmor(uid string) (string, error)
ExportPubKeyArmorByAddress(address []byte) (string, error)

Expand Down
64 changes: 32 additions & 32 deletions crypto/keyring/legacy_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ import (

// Deprecated: LegacyInfo is the publicly exposed information about a keypair
type LegacyInfo interface {
// Human-readable type for key listing
// GetType human-readable type for key listing
GetType() KeyType
// Name of the key
// GetName name of the key
GetName() string
// Public key
// GetPubKey public key
GetPubKey() cryptotypes.PubKey
// Address
// GetAddress address
GetAddress() sdk.AccAddress
// Bip44 Path
// GetPath bip44 path
GetPath() (*hd.BIP44Params, error)
// Algo
// GetAlgo signing algorithm for the key
GetAlgo() hd.PubKeyType
}

Expand All @@ -45,37 +45,37 @@ type legacyLocalInfo struct {

func infoKey(name string) string { return fmt.Sprintf("%s.%s", name, infoSuffix) }

// GetType implements Info interface
// GetType returns human-readable type for key listing
func (i legacyLocalInfo) GetType() KeyType {
return TypeLocal
}

// GetType implements Info interface
// GetName returns name of the key
func (i legacyLocalInfo) GetName() string {
return i.Name
}

// GetType implements Info interface
// GetPubKey returns public key
func (i legacyLocalInfo) GetPubKey() cryptotypes.PubKey {
return i.PubKey
}

// GetType implements Info interface
// GetAddress returns address
func (i legacyLocalInfo) GetAddress() sdk.AccAddress {
return i.PubKey.Address().Bytes()
}

// GetPrivKeyArmor
// GetPrivKeyArmor returns privkey armor
func (i legacyLocalInfo) GetPrivKeyArmor() string {
return i.PrivKeyArmor
}

// GetType implements Info interface
// GetAlgo returns the signing algorithm for the key
func (i legacyLocalInfo) GetAlgo() hd.PubKeyType {
return i.Algo
}

// GetType implements Info interface
// GetPath returns bip44 path, but not available for this type
func (i legacyLocalInfo) GetPath() (*hd.BIP44Params, error) {
return nil, fmt.Errorf("BIP44 Paths are not available for this type")
}
Expand All @@ -89,32 +89,32 @@ type legacyLedgerInfo struct {
Algo hd.PubKeyType `json:"algo"`
}

// GetType implements Info interface
// GetType returns human-readable type for key listing
func (i legacyLedgerInfo) GetType() KeyType {
return TypeLedger
}

// GetName implements Info interface
// GetName returns name of the key
func (i legacyLedgerInfo) GetName() string {
return i.Name
}

// GetPubKey implements Info interface
// GetPubKey returns public key
func (i legacyLedgerInfo) GetPubKey() cryptotypes.PubKey {
return i.PubKey
}

// GetAddress implements Info interface
// GetAddress returns address
func (i legacyLedgerInfo) GetAddress() sdk.AccAddress {
return i.PubKey.Address().Bytes()
}

// GetPath implements Info interface
// GetAlgo returns the signing algorithm for the key
func (i legacyLedgerInfo) GetAlgo() hd.PubKeyType {
return i.Algo
}

// GetPath implements Info interface
// GetPath returns bip44 path
func (i legacyLedgerInfo) GetPath() (*hd.BIP44Params, error) {
tmp := i.Path
return &tmp, nil
Expand All @@ -128,17 +128,17 @@ type legacyOfflineInfo struct {
Algo hd.PubKeyType `json:"algo"`
}

// GetType implements Info interface
// GetType returns human-readable type for key listing
func (i legacyOfflineInfo) GetType() KeyType {
return TypeOffline
}

// GetName implements Info interface
// GetName returns name of the key
func (i legacyOfflineInfo) GetName() string {
return i.Name
}

// GetPubKey implements Info interface
// GetPubKey returns public key
func (i legacyOfflineInfo) GetPubKey() cryptotypes.PubKey {
return i.PubKey
}
Expand All @@ -148,12 +148,12 @@ func (i legacyOfflineInfo) GetAlgo() hd.PubKeyType {
return i.Algo
}

// GetAddress implements Info interface
// GetAddress returns address
func (i legacyOfflineInfo) GetAddress() sdk.AccAddress {
return i.PubKey.Address().Bytes()
}

// GetPath implements Info interface
// GetPath returns bip44 path, but not available for this type
func (i legacyOfflineInfo) GetPath() (*hd.BIP44Params, error) {
return nil, fmt.Errorf("BIP44 Paths are not available for this type")
}
Expand All @@ -167,7 +167,7 @@ type multisigPubKeyInfo struct {
Weight uint `json:"weight"`
}

// multiInfo is the public information about a multisig key
// LegacyMultiInfo multiInfo is the public information about a multisig key
type LegacyMultiInfo struct {
Name string `json:"name"`
PubKey cryptotypes.PubKey `json:"pubkey"`
Expand All @@ -186,32 +186,32 @@ func NewLegacyMultiInfo(name string, pub cryptotypes.PubKey) (LegacyInfo, error)
}, nil
}

// GetType implements Info interface
// GetType returns human-readable type for key listing
func (i LegacyMultiInfo) GetType() KeyType {
return TypeMulti
}

// GetName implements Info interface
// GetName returns name of the key
func (i LegacyMultiInfo) GetName() string {
return i.Name
}

// GetPubKey implements Info interface
// GetPubKey returns public key
func (i LegacyMultiInfo) GetPubKey() cryptotypes.PubKey {
return i.PubKey
}

// GetAddress implements Info interface
// GetAddress returns address
func (i LegacyMultiInfo) GetAddress() sdk.AccAddress {
return i.PubKey.Address().Bytes()
}

// GetPath implements Info interface
// GetAlgo returns the signing algorithm for the key
func (i LegacyMultiInfo) GetAlgo() hd.PubKeyType {
return hd.MultiType
}

// GetPath implements Info interface
// GetPath returns bip44 path, but not available for this type
func (i LegacyMultiInfo) GetPath() (*hd.BIP44Params, error) {
return nil, fmt.Errorf("BIP44 Paths are not available for this type")
}
Expand All @@ -223,7 +223,7 @@ func (i LegacyMultiInfo) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error
return codectypes.UnpackInterfaces(multiPK, unpacker)
}

// encoding info
// MarshalInfo encoding info
func MarshalInfo(i LegacyInfo) []byte {
return legacy.Cdc.MustMarshalLengthPrefixed(i)
}
Expand Down
6 changes: 3 additions & 3 deletions crypto/keys/bcrypt/bcrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ var ErrMismatchedHashAndPassword = errors.New("crypto/bcrypt: hashedPassword is
// be a bcrypt hash.
var ErrHashTooShort = errors.New("crypto/bcrypt: hashedSecret too short to be a bcrypted password")

// The error returned from CompareHashAndPassword when a hash was created with
// HashVersionTooNewError the error returned from CompareHashAndPassword when a hash was created with
// a bcrypt algorithm newer than this implementation.
type HashVersionTooNewError byte

func (hv HashVersionTooNewError) Error() string {
return fmt.Sprintf("crypto/bcrypt: bcrypt algorithm version '%c' requested is newer than current version '%c'", byte(hv), majorVersion)
}

// The error returned from CompareHashAndPassword when a hash starts with something other than '$'
// InvalidHashPrefixError the error returned from CompareHashAndPassword when a hash starts with something other than '$'
type InvalidHashPrefixError byte

func (ih InvalidHashPrefixError) Error() string {
Expand Down Expand Up @@ -266,7 +266,7 @@ func (p *hashed) decodeVersion(sbytes []byte) (int, error) {
return n, nil
}

// sbytes should begin where decodeVersion left off.
// decodeCost sbytes should begin where decodeVersion left off.
func (p *hashed) decodeCost(sbytes []byte) (int, error) {
cost, err := strconv.Atoi(string(sbytes[0:2]))
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions crypto/keys/ed25519/ed25519.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import (
const (
PrivKeyName = "tendermint/PrivKeyEd25519"
PubKeyName = "tendermint/PubKeyEd25519"
// PubKeySize is is the size, in bytes, of public keys as used in this package.
// PubKeySize is the size, in bytes, of public keys as used in this package.
PubKeySize = 32
// PrivKeySize is the size, in bytes, of private keys as used in this package.
PrivKeySize = 64
// Size of an Edwards25519 signature. Namely the size of a compressed
// SignatureSize the size of an Edwards25519 signature. Namely the size of a compressed
// Edwards25519 point, and a field element. Both of which are 32 bytes.
SignatureSize = 64
// SeedSize is the size, in bytes, of private key seeds. These are the
Expand Down
2 changes: 1 addition & 1 deletion crypto/keys/secp256k1/secp256k1_nocgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (privKey *PrivKey) Sign(msg []byte) ([]byte, error) {
return sig[1:], nil
}

// VerifyBytes verifies a signature of the form R || S.
// VerifySignature verifies a signature of the form R || S.
// It rejects signatures which are not in lower-S form.
func (pubKey *PubKey) VerifySignature(msg, sigStr []byte) bool {
if len(sigStr) != 64 {
Expand Down
14 changes: 7 additions & 7 deletions crypto/ledger/ledger_secp256k1.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ type (
// SECP256K1 reflects an interface a Ledger API must implement for SECP256K1
SECP256K1 interface {
Close() error
// Returns an uncompressed pubkey
// GetPublicKeySECP256K1 returns an uncompressed pubkey
GetPublicKeySECP256K1([]uint32) ([]byte, error)
// Returns a compressed pubkey and bech32 address (requires user confirmation)
// GetAddressPubKeySECP256K1 returns a compressed pubkey and bech32 address (requires user confirmation)
GetAddressPubKeySECP256K1([]uint32, string) ([]byte, string, error)
// Signs a message (requires user confirmation)
// SignSECP256K1 signs a message (requires user confirmation)
// The last byte denotes the SIGN_MODE to be used by Ledger: 0 for
// LEGACY_AMINO_JSON, 1 for TEXTUAL. It corresponds to the P2 value
// in https://github.com/cosmos/ledger-cosmos/blob/main/docs/APDUSPEC.md
Expand Down Expand Up @@ -71,22 +71,22 @@ func initOptionsDefault() {
options.skipDERConversion = false
}

// Set the discoverLedger function to use a different Ledger derivation
// SetDiscoverLedger set the discoverLedger function to use a different Ledger derivation
func SetDiscoverLedger(fn discoverLedgerFn) {
options.discoverLedger = fn
}

// Set the createPubkey function to use a different public key
// SetCreatePubkey set the createPubkey function to use a different public key
func SetCreatePubkey(fn createPubkeyFn) {
options.createPubkey = fn
}

// Set the Ledger app name to use a different app name
// SetAppName set the Ledger app name to use a different app name
func SetAppName(appName string) {
options.appName = appName
}

// Set the DER Conversion requirement to true (false by default)
// SetSkipDERConversion set the DER Conversion requirement to true (false by default)
func SetSkipDERConversion() {
options.skipDERConversion = true
}
Expand Down
4 changes: 2 additions & 2 deletions crypto/xsalsa20symmetric/symmetric.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const (

var ErrCiphertextDecrypt = errors.New("ciphertext decryption failed")

// secret must be 32 bytes long. Use something like Sha256(Bcrypt(passphrase))
// EncryptSymmetric secret must be 32 bytes long. Use something like Sha256(Bcrypt(passphrase))
// The ciphertext is (secretbox.Overhead + 24) bytes longer than the plaintext.
func EncryptSymmetric(plaintext, secret []byte) (ciphertext []byte) {
if len(secret) != secretLen {
Expand All @@ -34,7 +34,7 @@ func EncryptSymmetric(plaintext, secret []byte) (ciphertext []byte) {
return ciphertext
}

// secret must be 32 bytes long. Use something like Sha256(Bcrypt(passphrase))
// DecryptSymmetric secret must be 32 bytes long. Use something like Sha256(Bcrypt(passphrase))
// The ciphertext is (secretbox.Overhead + 24) bytes longer than the plaintext.
func DecryptSymmetric(ciphertext, secret []byte) (plaintext []byte, err error) {
if len(secret) != secretLen {
Expand Down
2 changes: 1 addition & 1 deletion depinject/appconfig/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

var Register = RegisterModule

// Register registers a module with the global module registry. The provided
// RegisterModule registers a module with the global module registry. The provided
// protobuf message is used only to uniquely identify the protobuf module config
// type. The instance of the protobuf message used in the actual configuration
// will be injected into the container and can be requested by a provider
Expand Down
Loading

0 comments on commit 83a7f0e

Please sign in to comment.