Skip to content

Commit

Permalink
add eth secp256k1 support
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-1 committed Dec 1, 2023
1 parent c82131d commit 455664f
Show file tree
Hide file tree
Showing 11 changed files with 838 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/cosmos/cosmos-sdk/std"

"github.com/initia-labs/initia/app/params"
cryptocodec "github.com/initia-labs/initia/crypto/codec"
)

var legacyCodecRegistered = false
Expand All @@ -14,6 +15,8 @@ func MakeEncodingConfig() params.EncodingConfig {
encodingConfig := params.MakeEncodingConfig()
std.RegisterLegacyAminoCodec(encodingConfig.Amino)
std.RegisterInterfaces(encodingConfig.InterfaceRegistry)
cryptocodec.RegisterCrypto(encodingConfig.Amino)
cryptocodec.RegisterInterfaces(encodingConfig.InterfaceRegistry)
ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino)
ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry)

Expand Down
13 changes: 13 additions & 0 deletions crypto/codec/amino.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package codec

import (
"github.com/cosmos/cosmos-sdk/codec"

ethsecp256k1 "github.com/initia-labs/initia/crypto/keys/eth/secp256k1"
)

// RegisterCrypto registers all crypto dependency types with the provided Amino
// codec.
func RegisterCrypto(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&ethsecp256k1.PubKey{}, ethsecp256k1.PubKeyName, nil)
}
13 changes: 13 additions & 0 deletions crypto/codec/proto.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package codec

import (
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"

ethsecp256k1 "github.com/initia-labs/initia/crypto/keys/eth/secp256k1"
)

// RegisterInterfaces registers the sdk.Tx interface.
func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
registry.RegisterImplementations((*cryptotypes.PubKey)(nil), &ethsecp256k1.PubKey{})
}
329 changes: 329 additions & 0 deletions crypto/keys/eth/secp256k1/pubkey.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 455664f

Please sign in to comment.