From 868f486eac0ce5198a75bc9ed2fac0cc9b3e4802 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Andr=C3=B3il?= Date: Mon, 4 Aug 2025 21:49:40 +0200 Subject: [PATCH] fix(crypto): Correct typos and minor issues in crypto packages (#25083) Co-authored-by: Alex | Interchain Labs --- crypto/codec/amino.go | 2 +- crypto/codec/proto.go | 2 +- crypto/hd/algo_test.go | 1 + crypto/hd/hdpath.go | 2 +- crypto/keyring/errors.go | 4 ++-- crypto/keyring/keyring.go | 4 ++-- crypto/keyring/keyring_test.go | 2 +- crypto/keyring/migration_test.go | 16 ++++++++-------- crypto/keyring/signing_algorithms.go | 2 +- crypto/keyring/signing_algorithms_test.go | 2 +- 10 files changed, 19 insertions(+), 18 deletions(-) diff --git a/crypto/codec/amino.go b/crypto/codec/amino.go index 515062f165..069fecf8ce 100644 --- a/crypto/codec/amino.go +++ b/crypto/codec/amino.go @@ -21,12 +21,12 @@ func RegisterCrypto(cdc *codec.LegacyAmino) { secp256k1.PubKeyName, nil) cdc.RegisterConcrete(&kmultisig.LegacyAminoPubKey{}, kmultisig.PubKeyAminoRoute, nil) + cdc.RegisterConcrete(&bls12_381.PubKey{}, bls12381.PubKeyName, nil) cdc.RegisterInterface((*cryptotypes.PrivKey)(nil), nil) cdc.RegisterConcrete(&ed25519.PrivKey{}, ed25519.PrivKeyName, nil) cdc.RegisterConcrete(&secp256k1.PrivKey{}, secp256k1.PrivKeyName, nil) - cdc.RegisterConcrete(&bls12_381.PubKey{}, bls12381.PubKeyName, nil) cdc.RegisterConcrete(&bls12_381.PrivKey{}, bls12381.PrivKeyName, nil) } diff --git a/crypto/codec/proto.go b/crypto/codec/proto.go index e93377e38f..a43749d243 100644 --- a/crypto/codec/proto.go +++ b/crypto/codec/proto.go @@ -10,7 +10,7 @@ import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" ) -// RegisterInterfaces registers the sdk.Tx interface. +// RegisterInterfaces registers the crypto key interfaces. func RegisterInterfaces(registry codectypes.InterfaceRegistry) { var pk *cryptotypes.PubKey registry.RegisterInterface("cosmos.crypto.PubKey", pk) diff --git a/crypto/hd/algo_test.go b/crypto/hd/algo_test.go index 71cf24ba7a..a01288da9d 100644 --- a/crypto/hd/algo_test.go +++ b/crypto/hd/algo_test.go @@ -12,4 +12,5 @@ func TestDefaults(t *testing.T) { require.Equal(t, hd.PubKeyType("multi"), hd.MultiType) require.Equal(t, hd.PubKeyType("secp256k1"), hd.Secp256k1Type) require.Equal(t, hd.PubKeyType("ed25519"), hd.Ed25519Type) + require.Equal(t, hd.PubKeyType("bls12_381"), hd.Bls12_381Type) } diff --git a/crypto/hd/hdpath.go b/crypto/hd/hdpath.go index a1a896f981..0faa3e405b 100644 --- a/crypto/hd/hdpath.go +++ b/crypto/hd/hdpath.go @@ -155,7 +155,7 @@ func (p BIP44Params) String() string { p.AddressIndex) } -// ComputeMastersFromSeed returns the master secret key's, and chain code. +// ComputeMastersFromSeed returns the master secret key, and chain code. func ComputeMastersFromSeed(seed []byte) (secret, chainCode [32]byte) { curveIdentifier := []byte("Bitcoin seed") secret, chainCode = i64(curveIdentifier, seed) diff --git a/crypto/keyring/errors.go b/crypto/keyring/errors.go index cf1613ac8e..7fa5202c53 100644 --- a/crypto/keyring/errors.go +++ b/crypto/keyring/errors.go @@ -9,8 +9,8 @@ var ( // ErrUnsupportedLanguage is raised when the caller tries to use a // different language than english for creating a mnemonic sentence. ErrUnsupportedLanguage = errors.New("unsupported language: only english is supported") - // ErrUnknownBacked is raised when the keyring backend is unknown - ErrUnknownBacked = errors.New("unknown keyring backend") + // ErrUnknownBackend is raised when the keyring backend is unknown + ErrUnknownBackend = errors.New("unknown keyring backend") // ErrOverwriteKey is raised when a key cannot be overwritten ErrOverwriteKey = errors.New("cannot overwrite key") // ErrKeyAlreadyExists is raised when creating a key that already exists diff --git a/crypto/keyring/keyring.go b/crypto/keyring/keyring.go index d5fad0887d..3eca102f55 100644 --- a/crypto/keyring/keyring.go +++ b/crypto/keyring/keyring.go @@ -189,7 +189,7 @@ func newKeyringGeneric( case BackendPass: db, err = keyring.Open(newPassBackendKeyringConfig(appName, rootDir, userInput)) default: - return nil, errorsmod.Wrap(ErrUnknownBacked, backend) + return nil, errorsmod.Wrap(ErrUnknownBackend, backend) } if err != nil { @@ -890,7 +890,7 @@ func (ks keystore) writeOfflineKey(name string, pk types.PubKey) (*Record, error return k, ks.writeRecord(k) } -// writeMultisigKey investigate where thisf function is called maybe remove it +// writeMultisigKey investigate where this function is called maybe remove it func (ks keystore) writeMultisigKey(name string, pk types.PubKey) (*Record, error) { k, err := NewMultiRecord(name, pk) if err != nil { diff --git a/crypto/keyring/keyring_test.go b/crypto/keyring/keyring_test.go index 0919cbd2c4..c23384c2a2 100644 --- a/crypto/keyring/keyring_test.go +++ b/crypto/keyring/keyring_test.go @@ -75,7 +75,7 @@ func TestNewKeyring(t *testing.T) { dir: t.TempDir(), userInput: strings.NewReader(""), cdc: cdc, - expectedErr: ErrUnknownBacked, + expectedErr: ErrUnknownBackend, }, } for _, tt := range tests { diff --git a/crypto/keyring/migration_test.go b/crypto/keyring/migration_test.go index 1f85a2d11a..fdd0cf974d 100644 --- a/crypto/keyring/migration_test.go +++ b/crypto/keyring/migration_test.go @@ -87,7 +87,7 @@ func (s *MigrationTestSuite) TestMigrateLegacyOfflineKey() { item := keyring.Item{ Key: n1, Data: serializedLegacyOfflineInfo, - Description: "SDK kerying version", + Description: "SDK keyring version", } s.Require().NoError(s.ks.SetItem(item)) @@ -110,7 +110,7 @@ func (s *MigrationTestSuite) TestMigrateLegacyMultiKey() { item := keyring.Item{ Key: n1, Data: serializedLegacyMultiInfo, - Description: "SDK kerying version", + Description: "SDK keyring version", } s.Require().NoError(s.ks.SetItem(item)) @@ -129,7 +129,7 @@ func (s *MigrationTestSuite) TestMigrateLocalRecord() { item := keyring.Item{ Key: n1, Data: serializedRecord, - Description: "SDK kerying version", + Description: "SDK keyring version", } s.Require().NoError(s.ks.SetItem(item)) @@ -154,7 +154,7 @@ func (s *MigrationTestSuite) TestMigrateOneRandomItemError() { errItem := keyring.Item{ Key: n1, Data: randomBytes, - Description: "SDK kerying version", + Description: "SDK keyring version", } s.Require().NoError(s.ks.SetItem(errItem)) @@ -177,7 +177,7 @@ func (s *MigrationTestSuite) TestMigrateAllLegacyMultiOffline() { item := keyring.Item{ Key: n1, Data: serializedLegacyMultiInfo, - Description: "SDK kerying version", + Description: "SDK keyring version", } s.Require().NoError(s.ks.SetItem(item)) @@ -188,7 +188,7 @@ func (s *MigrationTestSuite) TestMigrateAllLegacyMultiOffline() { item = keyring.Item{ Key: n1, Data: serializedLegacyOfflineInfo, - Description: "SDK kerying version", + Description: "SDK keyring version", } s.Require().NoError(s.ks.SetItem(item)) @@ -209,7 +209,7 @@ func (s *MigrationTestSuite) TestMigrateErrUnknownItemKey() { item := keyring.Item{ Key: n1, Data: serializedLegacyOfflineInfo, - Description: "SDK kerying version", + Description: "SDK keyring version", } s.Require().NoError(s.ks.SetItem(item)) @@ -223,7 +223,7 @@ func (s *MigrationTestSuite) TestMigrateErrEmptyItemData() { item := keyring.Item{ Key: n1, Data: []byte{}, - Description: "SDK kerying version", + Description: "SDK keyring version", } s.Require().NoError(s.ks.SetItem(item)) diff --git a/crypto/keyring/signing_algorithms.go b/crypto/keyring/signing_algorithms.go index 4a22a98a8e..92dc1639fe 100644 --- a/crypto/keyring/signing_algorithms.go +++ b/crypto/keyring/signing_algorithms.go @@ -28,7 +28,7 @@ func NewSigningAlgoFromString(str string, algoList SigningAlgoList) (SignatureAl // SigningAlgoList is a slice of signature algorithms type SigningAlgoList []SignatureAlgo -// Contains returns true if the SigningAlgoList the given SignatureAlgo. +// Contains returns true if the SigningAlgoList contains the given SignatureAlgo. func (sal SigningAlgoList) Contains(algo SignatureAlgo) bool { for _, cAlgo := range sal { if cAlgo.Name() == algo.Name() { diff --git a/crypto/keyring/signing_algorithms_test.go b/crypto/keyring/signing_algorithms_test.go index 1ac7d9cc35..39b3754e0d 100644 --- a/crypto/keyring/signing_algorithms_test.go +++ b/crypto/keyring/signing_algorithms_test.go @@ -10,7 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/hd" ) -func TestNewSigningAlgoByString(t *testing.T) { +func TestNewSigningAlgoFromString(t *testing.T) { tests := []struct { name string algoStr string