diff --git a/crypto/armor.go b/crypto/armor.go index 13f24c4e082d..47eba69d8a63 100644 --- a/crypto/armor.go +++ b/crypto/armor.go @@ -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", @@ -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", @@ -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 { @@ -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{ diff --git a/crypto/keyring/keyring.go b/crypto/keyring/keyring.go index 8d0bc2018c08..22673e06fa09 100644 --- a/crypto/keyring/keyring.go +++ b/crypto/keyring/keyring.go @@ -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. @@ -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) diff --git a/crypto/keyring/legacy_info.go b/crypto/keyring/legacy_info.go index 8de45feb1be2..7bdaad0e5b00 100644 --- a/crypto/keyring/legacy_info.go +++ b/crypto/keyring/legacy_info.go @@ -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 } @@ -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") } @@ -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 @@ -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 } @@ -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") } @@ -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"` @@ -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") } @@ -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) } diff --git a/crypto/keys/bcrypt/bcrypt.go b/crypto/keys/bcrypt/bcrypt.go index f4f62d500cf7..6441ebce2896 100644 --- a/crypto/keys/bcrypt/bcrypt.go +++ b/crypto/keys/bcrypt/bcrypt.go @@ -32,7 +32,7 @@ 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 @@ -40,7 +40,7 @@ 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 { @@ -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 { diff --git a/crypto/keys/ed25519/ed25519.go b/crypto/keys/ed25519/ed25519.go index 122be97cb254..b0c28052a8cf 100644 --- a/crypto/keys/ed25519/ed25519.go +++ b/crypto/keys/ed25519/ed25519.go @@ -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 diff --git a/crypto/keys/secp256k1/secp256k1_nocgo.go b/crypto/keys/secp256k1/secp256k1_nocgo.go index fff3ba5e0544..bad10212b63c 100644 --- a/crypto/keys/secp256k1/secp256k1_nocgo.go +++ b/crypto/keys/secp256k1/secp256k1_nocgo.go @@ -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 { diff --git a/crypto/ledger/ledger_secp256k1.go b/crypto/ledger/ledger_secp256k1.go index 174fbfb091c0..67dcc73981ab 100644 --- a/crypto/ledger/ledger_secp256k1.go +++ b/crypto/ledger/ledger_secp256k1.go @@ -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 @@ -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 } diff --git a/crypto/xsalsa20symmetric/symmetric.go b/crypto/xsalsa20symmetric/symmetric.go index e2ead2e2f58f..2fb58d1ea4fc 100644 --- a/crypto/xsalsa20symmetric/symmetric.go +++ b/crypto/xsalsa20symmetric/symmetric.go @@ -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 { @@ -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 { diff --git a/depinject/appconfig/module.go b/depinject/appconfig/module.go index fc4f62cbd525..7fc03957d1b5 100644 --- a/depinject/appconfig/module.go +++ b/depinject/appconfig/module.go @@ -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 diff --git a/log/logger.go b/log/logger.go index 457905fd784e..f17c82eb059a 100644 --- a/log/logger.go +++ b/log/logger.go @@ -141,19 +141,19 @@ func (l zeroLogWrapper) Info(msg string, keyVals ...interface{}) { l.Logger.Info().Fields(keyVals).Msg(msg) } -// Info takes a message and a set of key/value pairs and logs with level INFO. +// Warn takes a message and a set of key/value pairs and logs with level WARN. // The key of the tuple must be a string. func (l zeroLogWrapper) Warn(msg string, keyVals ...interface{}) { l.Logger.Warn().Fields(keyVals).Msg(msg) } -// Error takes a message and a set of key/value pairs and logs with level DEBUG. +// Error takes a message and a set of key/value pairs and logs with level ERROR. // The key of the tuple must be a string. func (l zeroLogWrapper) Error(msg string, keyVals ...interface{}) { l.Logger.Error().Fields(keyVals).Msg(msg) } -// Debug takes a message and a set of key/value pairs and logs with level ERR. +// Debug takes a message and a set of key/value pairs and logs with level DEBUG. // The key of the tuple must be a string. func (l zeroLogWrapper) Debug(msg string, keyVals ...interface{}) { l.Logger.Debug().Fields(keyVals).Msg(msg)