diff --git a/.github/workflows/bsr-push.yml b/.github/workflows/bsr-push.yml index 2606a4b..a76381a 100644 --- a/.github/workflows/bsr-push.yml +++ b/.github/workflows/bsr-push.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: bufbuild/buf-setup-action@v1.35.1 - # Push Evmos protos to the Buf Schema Registry + # Push evmOS protos to the Buf Schema Registry - uses: bufbuild/buf-push-action@v1.2.0 with: input: ./proto diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d9a7e9f..8d1b8de 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,5 +1,5 @@ name: Lint -# Lint runs golangci-lint over the entire Evmos repository This workflow is +# Lint runs golangci-lint over the entire evmOS repository This workflow is # run on every pull request and push to main The `golangci` will pass without # running if no *.{go, mod, sum} files have been changed. on: diff --git a/CHANGELOG.md b/CHANGELOG.md index ad9c428..4d5730a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ This changelog was created using the `clu` binary ### Improvements +- (types) [#20](https://github.com/evmos/os/pull/20) Add crypto and encoding packages. - (types) [#19](https://github.com/evmos/os/pull/19) Add required wallet types for integration. - (all) [#15](https://github.com/evmos/os/pull/15) Add general types and utils. - (proto) [#14](https://github.com/evmos/os/pull/14) Add Protobufs and adjust scripts. diff --git a/Makefile b/Makefile index adbcc4b..0cc9d06 100644 --- a/Makefile +++ b/Makefile @@ -186,7 +186,7 @@ release: ############################################################################### # Install the necessary dependencies, compile the solidity contracts found in the -# Evmos repository and then clean up the contracts data. +# evmOS repository and then clean up the contracts data. contracts-all: contracts-compile contracts-clean # Clean smart contract compilation artifacts, dependencies and cache files @@ -194,7 +194,7 @@ contracts-clean: @echo "Cleaning up the contracts directory..." @python3 ./scripts/compile_smart_contracts/compile_smart_contracts.py --clean -# Compile the solidity contracts found in the Evmos repository. +# Compile the solidity contracts found in the evmOS repository. contracts-compile: @echo "Compiling smart contracts..." @python3 ./scripts/compile_smart_contracts/compile_smart_contracts.py --compile diff --git a/crypto/codec/amino.go b/crypto/codec/amino.go new file mode 100644 index 0000000..e65885d --- /dev/null +++ b/crypto/codec/amino.go @@ -0,0 +1,28 @@ +// Copyright Tharsis Labs Ltd.(Evmos) +// SPDX-License-Identifier:ENCL-1.0(https://github.com/evmos/evmos/blob/main/LICENSE) +package codec + +import ( + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/legacy" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + + "github.com/evmos/os/crypto/ethsecp256k1" +) + +// RegisterCrypto registers all crypto dependency types with the provided Amino +// codec. +func RegisterCrypto(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(ðsecp256k1.PubKey{}, + ethsecp256k1.PubKeyName, nil) + cdc.RegisterConcrete(ðsecp256k1.PrivKey{}, + ethsecp256k1.PrivKeyName, nil) + + keyring.RegisterLegacyAminoCodec(cdc) + cryptocodec.RegisterCrypto(cdc) + + // NOTE: update SDK's amino codec to include the ethsecp256k1 keys. + // DO NOT REMOVE unless deprecated on the SDK. + legacy.Cdc = cdc +} diff --git a/crypto/codec/codec.go b/crypto/codec/codec.go new file mode 100644 index 0000000..015d2e7 --- /dev/null +++ b/crypto/codec/codec.go @@ -0,0 +1,16 @@ +// Copyright Tharsis Labs Ltd.(Evmos) +// SPDX-License-Identifier:ENCL-1.0(https://github.com/evmos/evmos/blob/main/LICENSE) +package codec + +import ( + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + + "github.com/evmos/os/crypto/ethsecp256k1" +) + +// RegisterInterfaces register the evmOS key concrete types. +func RegisterInterfaces(registry codectypes.InterfaceRegistry) { + registry.RegisterImplementations((*cryptotypes.PubKey)(nil), ðsecp256k1.PubKey{}) + registry.RegisterImplementations((*cryptotypes.PrivKey)(nil), ðsecp256k1.PrivKey{}) +} diff --git a/crypto/ethsecp256k1/benchmark_test.go b/crypto/ethsecp256k1/benchmark_test.go new file mode 100644 index 0000000..815cc58 --- /dev/null +++ b/crypto/ethsecp256k1/benchmark_test.go @@ -0,0 +1,34 @@ +package ethsecp256k1 + +import ( + "fmt" + "testing" +) + +func BenchmarkGenerateKey(b *testing.B) { + b.ReportAllocs() + for i := 0; i < b.N; i++ { + if _, err := GenerateKey(); err != nil { + b.Fatal(err) + } + } +} + +func BenchmarkPubKey_VerifySignature(b *testing.B) { + privKey, err := GenerateKey() + if err != nil { + b.Fatal(err) + } + pubKey := privKey.PubKey() + + b.ResetTimer() + b.ReportAllocs() + for i := 0; i < b.N; i++ { + msg := []byte(fmt.Sprintf("%10d", i)) + sig, err := privKey.Sign(msg) + if err != nil { + b.Fatal(err) + } + pubKey.VerifySignature(msg, sig) + } +} diff --git a/crypto/ethsecp256k1/ethsecp256k1.go b/crypto/ethsecp256k1/ethsecp256k1.go new file mode 100644 index 0000000..74a0b8d --- /dev/null +++ b/crypto/ethsecp256k1/ethsecp256k1.go @@ -0,0 +1,249 @@ +// Copyright Tharsis Labs Ltd.(Evmos) +// SPDX-License-Identifier:ENCL-1.0(https://github.com/evmos/evmos/blob/main/LICENSE) + +package ethsecp256k1 + +import ( + "bytes" + "crypto/ecdsa" + "crypto/subtle" + "fmt" + + errorsmod "cosmossdk.io/errors" + tmcrypto "github.com/cometbft/cometbft/crypto" + "github.com/cosmos/cosmos-sdk/codec" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + errortypes "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/ethereum/go-ethereum/crypto" + "github.com/evmos/os/ethereum/eip712" +) + +const ( + // PrivKeySize defines the size of the PrivKey bytes + PrivKeySize = 32 + // PubKeySize defines the size of the PubKey bytes + PubKeySize = 33 + // KeyType is the string constant for the Secp256k1 algorithm + KeyType = "eth_secp256k1" +) + +// Amino encoding names +const ( + // PrivKeyName defines the amino encoding name for the EthSecp256k1 private key + PrivKeyName = "os/PrivKeyEthSecp256k1" + // PubKeyName defines the amino encoding name for the EthSecp256k1 public key + PubKeyName = "os/PubKeyEthSecp256k1" +) + +// ---------------------------------------------------------------------------- +// secp256k1 Private Key + +var ( + _ cryptotypes.PrivKey = &PrivKey{} + _ codec.AminoMarshaler = &PrivKey{} +) + +// GenerateKey generates a new random private key. It returns an error upon +// failure. +func GenerateKey() (*PrivKey, error) { + priv, err := crypto.GenerateKey() + if err != nil { + return nil, err + } + + return &PrivKey{ + Key: crypto.FromECDSA(priv), + }, nil +} + +// Bytes returns the byte representation of the ECDSA Private Key. +func (privKey PrivKey) Bytes() []byte { + bz := make([]byte, len(privKey.Key)) + copy(bz, privKey.Key) + + return bz +} + +// PubKey returns the ECDSA private key's public key. If the privkey is not valid +// it returns a nil value. +func (privKey PrivKey) PubKey() cryptotypes.PubKey { + ecdsaPrivKey, err := privKey.ToECDSA() + if err != nil { + return nil + } + + return &PubKey{ + Key: crypto.CompressPubkey(&ecdsaPrivKey.PublicKey), + } +} + +// Equals returns true if two ECDSA private keys are equal and false otherwise. +func (privKey PrivKey) Equals(other cryptotypes.LedgerPrivKey) bool { + return privKey.Type() == other.Type() && subtle.ConstantTimeCompare(privKey.Bytes(), other.Bytes()) == 1 +} + +// Type returns eth_secp256k1 +func (privKey PrivKey) Type() string { + return KeyType +} + +// MarshalAmino overrides Amino binary marshaling. +func (privKey PrivKey) MarshalAmino() ([]byte, error) { + return privKey.Key, nil +} + +// UnmarshalAmino overrides Amino binary marshaling. +func (privKey *PrivKey) UnmarshalAmino(bz []byte) error { + if len(bz) != PrivKeySize { + return fmt.Errorf("invalid privkey size, expected %d got %d", PrivKeySize, len(bz)) + } + privKey.Key = bz + + return nil +} + +// MarshalAminoJSON overrides Amino JSON marshaling. +func (privKey PrivKey) MarshalAminoJSON() ([]byte, error) { + // When we marshal to Amino JSON, we don't marshal the "key" field itself, + // just its contents (i.e. the key bytes). + return privKey.MarshalAmino() +} + +// UnmarshalAminoJSON overrides Amino JSON marshaling. +func (privKey *PrivKey) UnmarshalAminoJSON(bz []byte) error { + return privKey.UnmarshalAmino(bz) +} + +// Sign creates a recoverable ECDSA signature on the secp256k1 curve over the +// provided hash of the message. The produced signature is 65 bytes +// where the last byte contains the recovery ID. +func (privKey PrivKey) Sign(digestBz []byte) ([]byte, error) { + // TODO: remove + if len(digestBz) != crypto.DigestLength { + digestBz = crypto.Keccak256Hash(digestBz).Bytes() + } + + key, err := privKey.ToECDSA() + if err != nil { + return nil, err + } + + return crypto.Sign(digestBz, key) +} + +// ToECDSA returns the ECDSA private key as a reference to ecdsa.PrivateKey type. +func (privKey PrivKey) ToECDSA() (*ecdsa.PrivateKey, error) { + return crypto.ToECDSA(privKey.Bytes()) +} + +// ---------------------------------------------------------------------------- +// secp256k1 Public Key + +var ( + _ cryptotypes.PubKey = &PubKey{} + _ codec.AminoMarshaler = &PubKey{} +) + +// Address returns the address of the ECDSA public key. +// The function will return an empty address if the public key is invalid. +func (pubKey PubKey) Address() tmcrypto.Address { + pubk, err := crypto.DecompressPubkey(pubKey.Key) + if err != nil { + return nil + } + + return tmcrypto.Address(crypto.PubkeyToAddress(*pubk).Bytes()) +} + +// Bytes returns the raw bytes of the ECDSA public key. +func (pubKey PubKey) Bytes() []byte { + bz := make([]byte, len(pubKey.Key)) + copy(bz, pubKey.Key) + + return bz +} + +// String implements the fmt.Stringer interface. +func (pubKey PubKey) String() string { + return fmt.Sprintf("EthPubKeySecp256k1{%X}", pubKey.Key) +} + +// Type returns eth_secp256k1 +func (pubKey PubKey) Type() string { + return KeyType +} + +// Equals returns true if the pubkey type is the same and their bytes are deeply equal. +func (pubKey PubKey) Equals(other cryptotypes.PubKey) bool { + return pubKey.Type() == other.Type() && bytes.Equal(pubKey.Bytes(), other.Bytes()) +} + +// MarshalAmino overrides Amino binary marshaling. +func (pubKey PubKey) MarshalAmino() ([]byte, error) { + return pubKey.Key, nil +} + +// UnmarshalAmino overrides Amino binary marshaling. +func (pubKey *PubKey) UnmarshalAmino(bz []byte) error { + if len(bz) != PubKeySize { + return errorsmod.Wrapf(errortypes.ErrInvalidPubKey, "invalid pubkey size, expected %d, got %d", PubKeySize, len(bz)) + } + pubKey.Key = bz + + return nil +} + +// MarshalAminoJSON overrides Amino JSON marshaling. +func (pubKey PubKey) MarshalAminoJSON() ([]byte, error) { + // When we marshal to Amino JSON, we don't marshal the "key" field itself, + // just its contents (i.e. the key bytes). + return pubKey.MarshalAmino() +} + +// UnmarshalAminoJSON overrides Amino JSON marshaling. +func (pubKey *PubKey) UnmarshalAminoJSON(bz []byte) error { + return pubKey.UnmarshalAmino(bz) +} + +// VerifySignature verifies that the ECDSA public key created a given signature over +// the provided message. It will calculate the Keccak256 hash of the message +// prior to verification and approve verification if the signature can be verified +// from either the original message or its EIP-712 representation. +// +// CONTRACT: The signature should be in [R || S] format. +func (pubKey PubKey) VerifySignature(msg, sig []byte) bool { + return pubKey.verifySignatureECDSA(msg, sig) || pubKey.verifySignatureAsEIP712(msg, sig) +} + +// Verifies the signature as an EIP-712 signature by first converting the message payload +// to EIP-712 object bytes, then performing ECDSA verification on the hash. This is to support +// signing a Cosmos payload using EIP-712. +func (pubKey PubKey) verifySignatureAsEIP712(msg, sig []byte) bool { + eip712Bytes, err := eip712.GetEIP712BytesForMsg(msg) + if err != nil { + return false + } + + if pubKey.verifySignatureECDSA(eip712Bytes, sig) { + return true + } + + // Try verifying the signature using the legacy EIP-712 encoding + legacyEIP712Bytes, err := eip712.LegacyGetEIP712BytesForMsg(msg) + if err != nil { + return false + } + + return pubKey.verifySignatureECDSA(legacyEIP712Bytes, sig) +} + +// Perform standard ECDSA signature verification for the given raw bytes and signature. +func (pubKey PubKey) verifySignatureECDSA(msg, sig []byte) bool { + if len(sig) == crypto.SignatureLength { + // remove recovery ID (V) if contained in the signature + sig = sig[:len(sig)-1] + } + + // the signature needs to be in [R || S] format when provided to VerifySignature + return crypto.VerifySignature(pubKey.Key, crypto.Keccak256Hash(msg).Bytes(), sig) +} diff --git a/crypto/ethsecp256k1/ethsecp256k1_test.go b/crypto/ethsecp256k1/ethsecp256k1_test.go new file mode 100644 index 0000000..044f1c2 --- /dev/null +++ b/crypto/ethsecp256k1/ethsecp256k1_test.go @@ -0,0 +1,124 @@ +package ethsecp256k1 + +import ( + "encoding/base64" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/codec" + + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/crypto/secp256k1" + + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" +) + +func TestPrivKey(t *testing.T) { + // validate type and equality + privKey, err := GenerateKey() + require.NoError(t, err) + require.Implements(t, (*cryptotypes.PrivKey)(nil), privKey) + + // validate inequality + privKey2, err := GenerateKey() + require.NoError(t, err) + require.False(t, privKey.Equals(privKey2)) + + // validate Ethereum address equality + addr := privKey.PubKey().Address() + key, err := privKey.ToECDSA() + require.NoError(t, err) + expectedAddr := crypto.PubkeyToAddress(key.PublicKey) + require.Equal(t, expectedAddr.Bytes(), addr.Bytes()) + + // validate we can sign some bytes + msg := []byte("hello world") + sigHash := crypto.Keccak256Hash(msg) + expectedSig, err := secp256k1.Sign(sigHash.Bytes(), privKey.Bytes()) + require.NoError(t, err) + + sig, err := privKey.Sign(sigHash.Bytes()) + require.NoError(t, err) + require.Equal(t, expectedSig, sig) +} + +func TestPrivKey_PubKey(t *testing.T) { + privKey, err := GenerateKey() + require.NoError(t, err) + + // validate type and equality + pubKey := &PubKey{ + Key: privKey.PubKey().Bytes(), + } + require.Implements(t, (*cryptotypes.PubKey)(nil), pubKey) + + // validate inequality + privKey2, err := GenerateKey() + require.NoError(t, err) + require.False(t, pubKey.Equals(privKey2.PubKey())) + + // validate signature + msg := []byte("hello world") + sigHash := crypto.Keccak256Hash(msg) + sig, err := privKey.Sign(sigHash.Bytes()) + require.NoError(t, err) + + res := pubKey.VerifySignature(msg, sig) + require.True(t, res) +} + +func TestMarshalAmino(t *testing.T) { + aminoCdc := codec.NewLegacyAmino() + privKey, err := GenerateKey() + require.NoError(t, err) + + pubKey := privKey.PubKey().(*PubKey) + + testCases := []struct { + desc string + msg codec.AminoMarshaler + typ interface{} + expBinary []byte + expJSON string + }{ + { + "ethsecp256k1 private key", + privKey, + &PrivKey{}, + append([]byte{32}, privKey.Bytes()...), // Length-prefixed. + "\"" + base64.StdEncoding.EncodeToString(privKey.Bytes()) + "\"", + }, + { + "ethsecp256k1 public key", + pubKey, + &PubKey{}, + append([]byte{33}, pubKey.Bytes()...), // Length-prefixed. + "\"" + base64.StdEncoding.EncodeToString(pubKey.Bytes()) + "\"", + }, + } + + for _, tc := range testCases { + t.Run(tc.desc, func(t *testing.T) { + // Do a round trip of encoding/decoding binary. + bz, err := aminoCdc.Marshal(tc.msg) + require.NoError(t, err) + require.Equal(t, tc.expBinary, bz) + + err = aminoCdc.Unmarshal(bz, tc.typ) + require.NoError(t, err) + + require.Equal(t, tc.msg, tc.typ) + + // Do a round trip of encoding/decoding JSON. + bz, err = aminoCdc.MarshalJSON(tc.msg) + require.NoError(t, err) + require.Equal(t, tc.expJSON, string(bz)) + + err = aminoCdc.UnmarshalJSON(bz, tc.typ) + require.NoError(t, err) + + require.Equal(t, tc.msg, tc.typ) + }) + } +} diff --git a/crypto/ethsecp256k1/keys.pb.go b/crypto/ethsecp256k1/keys.pb.go new file mode 100644 index 0000000..857dc85 --- /dev/null +++ b/crypto/ethsecp256k1/keys.pb.go @@ -0,0 +1,499 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: os/crypto/v1/ethsecp256k1/keys.proto + +package ethsecp256k1 + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// PubKey defines a type alias for an ecdsa.PublicKey that implements +// Tendermint's PubKey interface. It represents the 33-byte compressed public +// key format. +type PubKey struct { + // key is the public key in byte form + Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (m *PubKey) Reset() { *m = PubKey{} } +func (*PubKey) ProtoMessage() {} +func (*PubKey) Descriptor() ([]byte, []int) { + return fileDescriptor_ed584e6356c1fa1b, []int{0} +} +func (m *PubKey) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PubKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PubKey.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PubKey) XXX_Merge(src proto.Message) { + xxx_messageInfo_PubKey.Merge(m, src) +} +func (m *PubKey) XXX_Size() int { + return m.Size() +} +func (m *PubKey) XXX_DiscardUnknown() { + xxx_messageInfo_PubKey.DiscardUnknown(m) +} + +var xxx_messageInfo_PubKey proto.InternalMessageInfo + +func (m *PubKey) GetKey() []byte { + if m != nil { + return m.Key + } + return nil +} + +// PrivKey defines a type alias for an ecdsa.PrivateKey that implements +// Tendermint's PrivateKey interface. +type PrivKey struct { + // key is the private key in byte form + Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (m *PrivKey) Reset() { *m = PrivKey{} } +func (m *PrivKey) String() string { return proto.CompactTextString(m) } +func (*PrivKey) ProtoMessage() {} +func (*PrivKey) Descriptor() ([]byte, []int) { + return fileDescriptor_ed584e6356c1fa1b, []int{1} +} +func (m *PrivKey) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PrivKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PrivKey.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PrivKey) XXX_Merge(src proto.Message) { + xxx_messageInfo_PrivKey.Merge(m, src) +} +func (m *PrivKey) XXX_Size() int { + return m.Size() +} +func (m *PrivKey) XXX_DiscardUnknown() { + xxx_messageInfo_PrivKey.DiscardUnknown(m) +} + +var xxx_messageInfo_PrivKey proto.InternalMessageInfo + +func (m *PrivKey) GetKey() []byte { + if m != nil { + return m.Key + } + return nil +} + +func init() { + proto.RegisterType((*PubKey)(nil), "os.crypto.v1.ethsecp256k1.PubKey") + proto.RegisterType((*PrivKey)(nil), "os.crypto.v1.ethsecp256k1.PrivKey") +} + +func init() { + proto.RegisterFile("os/crypto/v1/ethsecp256k1/keys.proto", fileDescriptor_ed584e6356c1fa1b) +} + +var fileDescriptor_ed584e6356c1fa1b = []byte{ + // 187 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xc9, 0x2f, 0xd6, 0x4f, + 0x2e, 0xaa, 0x2c, 0x28, 0xc9, 0xd7, 0x2f, 0x33, 0xd4, 0x4f, 0x2d, 0xc9, 0x28, 0x4e, 0x4d, 0x2e, + 0x30, 0x32, 0x35, 0xcb, 0x36, 0xd4, 0xcf, 0x4e, 0xad, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, + 0x17, 0x92, 0xcc, 0x2f, 0xd6, 0x83, 0xa8, 0xd2, 0x2b, 0x33, 0xd4, 0x43, 0x56, 0x25, 0x25, 0x92, + 0x9e, 0x9f, 0x9e, 0x0f, 0x56, 0xa5, 0x0f, 0x62, 0x41, 0x34, 0x28, 0x29, 0x70, 0xb1, 0x05, 0x94, + 0x26, 0x79, 0xa7, 0x56, 0x0a, 0x09, 0x70, 0x31, 0x67, 0xa7, 0x56, 0x4a, 0x30, 0x2a, 0x30, 0x6a, + 0xf0, 0x04, 0x81, 0x98, 0x56, 0x2c, 0x33, 0x16, 0xc8, 0x33, 0x28, 0x49, 0x73, 0xb1, 0x07, 0x14, + 0x65, 0x96, 0x61, 0x55, 0xe2, 0xe4, 0x78, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, + 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, + 0x51, 0xea, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0xa9, 0x65, 0xb9, + 0xf9, 0xc5, 0xfa, 0x08, 0x0f, 0x20, 0xbb, 0x2b, 0x89, 0x0d, 0xec, 0x10, 0x63, 0x40, 0x00, 0x00, + 0x00, 0xff, 0xff, 0xca, 0xcd, 0x5c, 0x75, 0xe1, 0x00, 0x00, 0x00, +} + +func (m *PubKey) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PubKey) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PubKey) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintKeys(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *PrivKey) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PrivKey) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PrivKey) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintKeys(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintKeys(dAtA []byte, offset int, v uint64) int { + offset -= sovKeys(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *PubKey) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovKeys(uint64(l)) + } + return n +} + +func (m *PrivKey) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovKeys(uint64(l)) + } + return n +} + +func sovKeys(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozKeys(x uint64) (n int) { + return sovKeys(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *PubKey) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowKeys + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PubKey: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PubKey: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowKeys + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthKeys + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthKeys + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) + if m.Key == nil { + m.Key = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipKeys(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthKeys + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PrivKey) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowKeys + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PrivKey: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PrivKey: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowKeys + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthKeys + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthKeys + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) + if m.Key == nil { + m.Key = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipKeys(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthKeys + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipKeys(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowKeys + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowKeys + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowKeys + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthKeys + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupKeys + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthKeys + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthKeys = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowKeys = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupKeys = fmt.Errorf("proto: unexpected end of group") +) diff --git a/crypto/hd/algorithm.go b/crypto/hd/algorithm.go new file mode 100644 index 0000000..f995f2b --- /dev/null +++ b/crypto/hd/algorithm.go @@ -0,0 +1,113 @@ +// Copyright Tharsis Labs Ltd.(Evmos) +// SPDX-License-Identifier:ENCL-1.0(https://github.com/evmos/evmos/blob/main/LICENSE) +package hd + +import ( + "github.com/btcsuite/btcd/btcutil/hdkeychain" + "github.com/btcsuite/btcd/chaincfg" + bip39 "github.com/tyler-smith/go-bip39" + + "github.com/ethereum/go-ethereum/accounts" + "github.com/ethereum/go-ethereum/crypto" + + "github.com/cosmos/cosmos-sdk/crypto/hd" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + + "github.com/evmos/os/crypto/ethsecp256k1" +) + +const ( + // EthSecp256k1Type defines the ECDSA secp256k1 used on Ethereum + EthSecp256k1Type = hd.PubKeyType(ethsecp256k1.KeyType) +) + +var ( + // SupportedAlgorithms defines the list of signing algorithms used on evmOS: + // - eth_secp256k1 (Ethereum) + // - secp256k1 (Tendermint) + SupportedAlgorithms = keyring.SigningAlgoList{EthSecp256k1, hd.Secp256k1} + // SupportedAlgorithmsLedger defines the list of signing algorithms used on evmOS for the Ledger device: + // - eth_secp256k1 (Ethereum) + // - secp256k1 (Tendermint) + SupportedAlgorithmsLedger = keyring.SigningAlgoList{EthSecp256k1, hd.Secp256k1} +) + +// EthSecp256k1Option defines a function keys options for the ethereum Secp256k1 curve. +// It supports eth_secp256k1 and secp256k1 keys for accounts. +func EthSecp256k1Option() keyring.Option { + return func(options *keyring.Options) { + options.SupportedAlgos = SupportedAlgorithms + options.SupportedAlgosLedger = SupportedAlgorithmsLedger + } +} + +var ( + _ keyring.SignatureAlgo = EthSecp256k1 + + // EthSecp256k1 uses the Bitcoin secp256k1 ECDSA parameters. + EthSecp256k1 = ethSecp256k1Algo{} +) + +type ethSecp256k1Algo struct{} + +// Name returns eth_secp256k1 +func (s ethSecp256k1Algo) Name() hd.PubKeyType { + return EthSecp256k1Type +} + +// Derive derives and returns the eth_secp256k1 private key for the given mnemonic and HD path. +func (s ethSecp256k1Algo) Derive() hd.DeriveFn { + return func(mnemonic, bip39Passphrase, path string) ([]byte, error) { + hdpath, err := accounts.ParseDerivationPath(path) + if err != nil { + return nil, err + } + + seed, err := bip39.NewSeedWithErrorChecking(mnemonic, bip39Passphrase) + if err != nil { + return nil, err + } + + // create a BTC-utils hd-derivation key chain + masterKey, err := hdkeychain.NewMaster(seed, &chaincfg.MainNetParams) + if err != nil { + return nil, err + } + + key := masterKey + for _, n := range hdpath { + key, err = key.Derive(n) + if err != nil { + return nil, err + } + } + + // btc-utils representation of a secp256k1 private key + privateKey, err := key.ECPrivKey() + if err != nil { + return nil, err + } + + // cast private key to a convertible form (single scalar field element of secp256k1) + // and then load into ethcrypto private key format. + // TODO: add links to godocs of the two methods or implementations of them, to compare equivalency + privateKeyECDSA := privateKey.ToECDSA() + derivedKey := crypto.FromECDSA(privateKeyECDSA) + + return derivedKey, nil + } +} + +// Generate generates a eth_secp256k1 private key from the given bytes. +func (s ethSecp256k1Algo) Generate() hd.GenerateFn { + return func(bz []byte) cryptotypes.PrivKey { + bzArr := make([]byte, ethsecp256k1.PrivKeySize) + copy(bzArr, bz) + + // TODO: modulo P + return ðsecp256k1.PrivKey{ + Key: bzArr, + } + } +} diff --git a/crypto/hd/algorithm_test.go b/crypto/hd/algorithm_test.go new file mode 100644 index 0000000..3c88c95 --- /dev/null +++ b/crypto/hd/algorithm_test.go @@ -0,0 +1,130 @@ +package hd + +import ( + "os" + "strings" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/ethereum/go-ethereum/common" + + amino "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + + cryptocodec "github.com/evmos/os/crypto/codec" + enccodec "github.com/evmos/os/encoding/codec" + evmostypes "github.com/evmos/os/types" +) + +var TestCodec amino.Codec + +func init() { + cdc := amino.NewLegacyAmino() + cryptocodec.RegisterCrypto(cdc) + + interfaceRegistry := types.NewInterfaceRegistry() + TestCodec = amino.NewProtoCodec(interfaceRegistry) + enccodec.RegisterInterfaces(interfaceRegistry) +} + +const ( + mnemonic = "picnic rent average infant boat squirrel federal assault mercy purity very motor fossil wheel verify upset box fresh horse vivid copy predict square regret" + + // hdWalletFixEnv defines whether the standard (correct) bip39 + // derivation path was used, or if derivation was affected by + // https://github.com/btcsuite/btcutil/issues/179 + hdWalletFixEnv = "GO_ETHEREUM_HDWALLET_FIX_ISSUE_179" +) + +func TestKeyring(t *testing.T) { + dir := t.TempDir() + mockIn := strings.NewReader("") + kr, err := keyring.New("evmos", keyring.BackendTest, dir, mockIn, TestCodec, EthSecp256k1Option()) + require.NoError(t, err) + + // fail in retrieving key + info, err := kr.Key("foo") + require.Error(t, err) + require.Nil(t, info) + + mockIn.Reset("password\npassword\n") + info, mnemonic, err := kr.NewMnemonic("foo", keyring.English, evmostypes.BIP44HDPath, keyring.DefaultBIP39Passphrase, EthSecp256k1) + require.NoError(t, err) + require.NotEmpty(t, mnemonic) + require.Equal(t, "foo", info.Name) + require.Equal(t, "local", info.GetType().String()) + pubKey, err := info.GetPubKey() + require.NoError(t, err) + require.Equal(t, string(EthSecp256k1Type), pubKey.Type()) + + hdPath := evmostypes.BIP44HDPath + + bz, err := EthSecp256k1.Derive()(mnemonic, keyring.DefaultBIP39Passphrase, hdPath) + require.NoError(t, err) + require.NotEmpty(t, bz) + + wrongBz, err := EthSecp256k1.Derive()(mnemonic, keyring.DefaultBIP39Passphrase, "/wrong/hdPath") + require.Error(t, err) + require.Empty(t, wrongBz) + + privkey := EthSecp256k1.Generate()(bz) + addr := common.BytesToAddress(privkey.PubKey().Address().Bytes()) + + os.Setenv(hdWalletFixEnv, "true") + wallet, err := NewFromMnemonic(mnemonic) + os.Setenv(hdWalletFixEnv, "") + require.NoError(t, err) + + path := MustParseDerivationPath(hdPath) + + account, err := wallet.Derive(path, false) + require.NoError(t, err) + require.Equal(t, addr.String(), account.Address.String()) +} + +func TestDerivation(t *testing.T) { + bz, err := EthSecp256k1.Derive()(mnemonic, keyring.DefaultBIP39Passphrase, evmostypes.BIP44HDPath) + require.NoError(t, err) + require.NotEmpty(t, bz) + + badBz, err := EthSecp256k1.Derive()(mnemonic, keyring.DefaultBIP39Passphrase, "44'/60'/0'/0/0") + require.NoError(t, err) + require.NotEmpty(t, badBz) + + require.NotEqual(t, bz, badBz) + + privkey := EthSecp256k1.Generate()(bz) + badPrivKey := EthSecp256k1.Generate()(badBz) + + require.False(t, privkey.Equals(badPrivKey)) + + wallet, err := NewFromMnemonic(mnemonic) + require.NoError(t, err) + + path := MustParseDerivationPath(evmostypes.BIP44HDPath) + account, err := wallet.Derive(path, false) + require.NoError(t, err) + + badPath := MustParseDerivationPath("44'/60'/0'/0/0") + badAccount, err := wallet.Derive(badPath, false) + require.NoError(t, err) + + // Equality of Address BIP44 + require.Equal(t, account.Address.String(), "0xA588C66983a81e800Db4dF74564F09f91c026351") + require.Equal(t, badAccount.Address.String(), "0xF8D6FDf2B8b488ea37e54903750dcd13F67E71cb") + // Inequality of wrong derivation path address + require.NotEqual(t, account.Address.String(), badAccount.Address.String()) + // Equality of evmOS implementation + require.Equal(t, common.BytesToAddress(privkey.PubKey().Address().Bytes()).String(), "0xA588C66983a81e800Db4dF74564F09f91c026351") + require.Equal(t, common.BytesToAddress(badPrivKey.PubKey().Address().Bytes()).String(), "0xF8D6FDf2B8b488ea37e54903750dcd13F67E71cb") + + // Equality of Eth and evmOS implementation + require.Equal(t, common.BytesToAddress(privkey.PubKey().Address()).String(), account.Address.String()) + require.Equal(t, common.BytesToAddress(badPrivKey.PubKey().Address()).String(), badAccount.Address.String()) + + // Inequality of wrong derivation path of Eth and evmOS implementation + require.NotEqual(t, common.BytesToAddress(privkey.PubKey().Address()).String(), badAccount.Address.String()) + require.NotEqual(t, common.BytesToAddress(badPrivKey.PubKey().Address()).String(), account.Address.Hex()) +} diff --git a/crypto/hd/benchmark_test.go b/crypto/hd/benchmark_test.go new file mode 100644 index 0000000..c2f4349 --- /dev/null +++ b/crypto/hd/benchmark_test.go @@ -0,0 +1,31 @@ +package hd + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/crypto/keyring" + "github.com/evmos/os/types" +) + +func BenchmarkEthSecp256k1Algo_Derive(b *testing.B) { + b.ReportAllocs() + for i := 0; i < b.N; i++ { + deriveFn := EthSecp256k1.Derive() + if _, err := deriveFn(mnemonic, keyring.DefaultBIP39Passphrase, types.BIP44HDPath); err != nil { + b.Fatal(err) + } + } +} + +func BenchmarkEthSecp256k1Algo_Generate(b *testing.B) { + bz, err := EthSecp256k1.Derive()(mnemonic, keyring.DefaultBIP39Passphrase, types.BIP44HDPath) + if err != nil { + b.Fatal(err) + } + + b.ResetTimer() + b.ReportAllocs() + for i := 0; i < b.N; i++ { + (ðSecp256k1Algo{}).Generate()(bz) + } +} diff --git a/crypto/hd/utils_test.go b/crypto/hd/utils_test.go new file mode 100644 index 0000000..2082368 --- /dev/null +++ b/crypto/hd/utils_test.go @@ -0,0 +1,181 @@ +// NOTE: This code is being used as test helper functions. +package hd + +import ( + "crypto/ecdsa" + "errors" + "os" + "sync" + + "github.com/ethereum/go-ethereum/accounts" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" + + "github.com/btcsuite/btcd/btcutil/hdkeychain" + "github.com/btcsuite/btcd/chaincfg" + bip39 "github.com/tyler-smith/go-bip39" +) + +const issue179FixEnvar = "GO_ETHEREUM_HDWALLET_FIX_ISSUE_179" + +// Wallet is the underlying wallet struct. +type Wallet struct { + mnemonic string + masterKey *hdkeychain.ExtendedKey + seed []byte + paths map[common.Address]accounts.DerivationPath + accounts []accounts.Account + stateLock sync.RWMutex + fixIssue172 bool +} + +// NewFromMnemonic returns a new wallet from a BIP-39 mnemonic. +func NewFromMnemonic(mnemonic string) (*Wallet, error) { + if mnemonic == "" { + return nil, errors.New("mnemonic is required") + } + + if !bip39.IsMnemonicValid(mnemonic) { + return nil, errors.New("mnemonic is invalid") + } + + seed, err := NewSeedFromMnemonic(mnemonic) + if err != nil { + return nil, err + } + + wallet, err := newWallet(seed) + if err != nil { + return nil, err + } + wallet.mnemonic = mnemonic + + return wallet, nil +} + +// NewSeedFromMnemonic returns a BIP-39 seed based on a BIP-39 mnemonic. +func NewSeedFromMnemonic(mnemonic string) ([]byte, error) { + if mnemonic == "" { + return nil, errors.New("mnemonic is required") + } + + return bip39.NewSeedWithErrorChecking(mnemonic, "") +} + +func newWallet(seed []byte) (*Wallet, error) { + masterKey, err := hdkeychain.NewMaster(seed, &chaincfg.MainNetParams) + if err != nil { + return nil, err + } + + return &Wallet{ + masterKey: masterKey, + seed: seed, + accounts: []accounts.Account{}, + paths: map[common.Address]accounts.DerivationPath{}, + fixIssue172: false || len(os.Getenv(issue179FixEnvar)) > 0, + }, nil +} + +// Derive implements accounts.Wallet, deriving a new account at the specific +// derivation path. If pin is set to true, the account will be added to the list +// of tracked accounts. +func (w *Wallet) Derive(path accounts.DerivationPath, pin bool) (accounts.Account, error) { + // Try to derive the actual account and update its URL if successful + w.stateLock.RLock() // Avoid device disappearing during derivation + + address, err := w.deriveAddress(path) + + w.stateLock.RUnlock() + + // If an error occurred or no pinning was requested, return + if err != nil { + return accounts.Account{}, err + } + + account := accounts.Account{ + Address: address, + URL: accounts.URL{ + Scheme: "", + Path: path.String(), + }, + } + + if !pin { + return account, nil + } + + // Pinning needs to modify the state + w.stateLock.Lock() + defer w.stateLock.Unlock() + + if _, ok := w.paths[address]; !ok { + w.accounts = append(w.accounts, account) + w.paths[address] = path + } + + return account, nil +} + +// MustParseDerivationPath parses the derivation path in string format into +// []uint32 but will panic if it can't parse it. +func MustParseDerivationPath(path string) accounts.DerivationPath { + parsed, err := accounts.ParseDerivationPath(path) + if err != nil { + panic(err) + } + + return parsed +} + +// DerivePrivateKey derives the private key of the derivation path. +func (w *Wallet) derivePrivateKey(path accounts.DerivationPath) (*ecdsa.PrivateKey, error) { + var err error + key := w.masterKey + for _, n := range path { + if w.fixIssue172 && key.IsAffectedByIssue172() { + key, err = key.Derive(n) + } else { + //lint:ignore SA1019 this is used for testing only + key, err = key.DeriveNonStandard(n) //nolint:staticcheck + } + if err != nil { + return nil, err + } + } + + privateKey, err := key.ECPrivKey() + privateKeyECDSA := privateKey.ToECDSA() + if err != nil { + return nil, err + } + + return privateKeyECDSA, nil +} + +// derivePublicKey derives the public key of the derivation path. +func (w *Wallet) derivePublicKey(path accounts.DerivationPath) (*ecdsa.PublicKey, error) { + privateKeyECDSA, err := w.derivePrivateKey(path) + if err != nil { + return nil, err + } + + publicKey := privateKeyECDSA.Public() + publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey) + if !ok { + return nil, errors.New("failed to get public key") + } + + return publicKeyECDSA, nil +} + +// DeriveAddress derives the account address of the derivation path. +func (w *Wallet) deriveAddress(path accounts.DerivationPath) (common.Address, error) { + publicKeyECDSA, err := w.derivePublicKey(path) + if err != nil { + return common.Address{}, err + } + + address := crypto.PubkeyToAddress(*publicKeyECDSA) + return address, nil +} diff --git a/crypto/keyring/options.go b/crypto/keyring/options.go new file mode 100644 index 0000000..3b78dee --- /dev/null +++ b/crypto/keyring/options.go @@ -0,0 +1,47 @@ +// Copyright Tharsis Labs Ltd.(Evmos) +// SPDX-License-Identifier:ENCL-1.0(https://github.com/evmos/evmos/blob/main/LICENSE) + +package keyring + +import ( + "github.com/cosmos/cosmos-sdk/crypto/keyring" + cosmosLedger "github.com/cosmos/cosmos-sdk/crypto/ledger" + "github.com/cosmos/cosmos-sdk/crypto/types" + + "github.com/evmos/os/crypto/ethsecp256k1" + "github.com/evmos/os/crypto/hd" + "github.com/evmos/os/wallets/ledger" +) + +// AppName defines the Ledger app used for signing. evmOS uses the Ethereum app +const AppName = "Ethereum" + +var ( + // SupportedAlgorithms defines the list of signing algorithms used on evmOS: + // - eth_secp256k1 (Ethereum) + SupportedAlgorithms = keyring.SigningAlgoList{hd.EthSecp256k1} + // SupportedAlgorithmsLedger defines the list of signing algorithms used by evmOS for the Ledger device: + // - secp256k1 (in order to comply with Cosmos SDK) + // The Ledger derivation function is responsible for all signing and address generation. + SupportedAlgorithmsLedger = keyring.SigningAlgoList{hd.EthSecp256k1} + // LedgerDerivation defines the evmOS Ledger Go derivation (Ethereum app with EIP-712 signing) + LedgerDerivation = ledger.EvmosLedgerDerivation() + // CreatePubkey uses the ethsecp256k1 pubkey with Ethereum address generation and keccak hashing + CreatePubkey = func(key []byte) types.PubKey { return ðsecp256k1.PubKey{Key: key} } + // SkipDERConversion represents whether the signed Ledger output should skip conversion from DER to BER. + // This is set to true for signing performed by the Ledger Ethereum app. + SkipDERConversion = true +) + +// EthSecp256k1Option defines a function keys options for the ethereum Secp256k1 curve. +// It supports eth_secp256k1 keys for accounts. +func Option() keyring.Option { + return func(options *keyring.Options) { + options.SupportedAlgos = SupportedAlgorithms + options.SupportedAlgosLedger = SupportedAlgorithmsLedger + options.LedgerDerivation = func() (cosmosLedger.SECP256K1, error) { return LedgerDerivation() } + options.LedgerCreateKey = CreatePubkey + options.LedgerAppName = AppName + options.LedgerSigSkipDERConv = SkipDERConversion + } +} diff --git a/crypto/secp256r1/verify.go b/crypto/secp256r1/verify.go new file mode 100644 index 0000000..9b4ba86 --- /dev/null +++ b/crypto/secp256r1/verify.go @@ -0,0 +1,52 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +package secp256r1 + +import ( + "crypto/ecdsa" + "crypto/elliptic" + "math/big" +) + +// Verifies the given signature (r, s) for the given hash and public key (x, y). +func Verify(hash []byte, r, s, x, y *big.Int) bool { + // Create the public key format + publicKey := newECDSAPublicKey(x, y) + + // Check if they are invalid public key coordinates + if publicKey == nil { + return false + } + + // Verify the signature with the public key, + // then return true if it's valid, false otherwise + return ecdsa.Verify(publicKey, hash, r, s) +} + +// newECDSAPublicKey creates an ECDSA P256 public key from the given coordinates +func newECDSAPublicKey(x, y *big.Int) *ecdsa.PublicKey { + // Check if the given coordinates are valid and in the reference point (infinity) + if x == nil || y == nil || x.Sign() == 0 && y.Sign() == 0 || !elliptic.P256().IsOnCurve(x, y) { + return nil + } + + return &ecdsa.PublicKey{ + Curve: elliptic.P256(), + X: x, + Y: y, + } +} diff --git a/encoding/codec/codec.go b/encoding/codec/codec.go new file mode 100644 index 0000000..c40946b --- /dev/null +++ b/encoding/codec/codec.go @@ -0,0 +1,27 @@ +// Copyright Tharsis Labs Ltd.(Evmos) +// SPDX-License-Identifier:ENCL-1.0(https://github.com/evmos/evmos/blob/main/LICENSE) +package codec + +import ( + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/std" + sdk "github.com/cosmos/cosmos-sdk/types" + + cryptocodec "github.com/evmos/os/crypto/codec" + "github.com/evmos/os/types" +) + +// RegisterLegacyAminoCodec registers Interfaces from types, crypto, and SDK std. +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + sdk.RegisterLegacyAminoCodec(cdc) + cryptocodec.RegisterCrypto(cdc) + codec.RegisterEvidences(cdc) +} + +// RegisterInterfaces registers Interfaces from types, crypto, and SDK std. +func RegisterInterfaces(interfaceRegistry codectypes.InterfaceRegistry) { + std.RegisterInterfaces(interfaceRegistry) + cryptocodec.RegisterInterfaces(interfaceRegistry) + types.RegisterInterfaces(interfaceRegistry) +} diff --git a/encoding/config.go b/encoding/config.go new file mode 100644 index 0000000..4bf8ea4 --- /dev/null +++ b/encoding/config.go @@ -0,0 +1,33 @@ +// Copyright Tharsis Labs Ltd.(Evmos) +// SPDX-License-Identifier:ENCL-1.0(https://github.com/evmos/evmos/blob/main/LICENSE) +package encoding + +import ( + "cosmossdk.io/simapp/params" + amino "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/cosmos/cosmos-sdk/x/auth/tx" + + enccodec "github.com/evmos/os/encoding/codec" +) + +// MakeConfig creates an EncodingConfig for the given basic module manager. +func MakeConfig(mb module.BasicManager) params.EncodingConfig { + cdc := amino.NewLegacyAmino() + interfaceRegistry := types.NewInterfaceRegistry() + codec := amino.NewProtoCodec(interfaceRegistry) + + encodingConfig := params.EncodingConfig{ + InterfaceRegistry: interfaceRegistry, + Codec: codec, + TxConfig: tx.NewTxConfig(codec, tx.DefaultSignModes), + Amino: cdc, + } + + enccodec.RegisterLegacyAminoCodec(encodingConfig.Amino) + mb.RegisterLegacyAminoCodec(encodingConfig.Amino) + enccodec.RegisterInterfaces(encodingConfig.InterfaceRegistry) + mb.RegisterInterfaces(encodingConfig.InterfaceRegistry) + return encodingConfig +} diff --git a/encoding/config_test.go b/encoding/config_test.go new file mode 100644 index 0000000..855a65d --- /dev/null +++ b/encoding/config_test.go @@ -0,0 +1,48 @@ +package encoding_test + +import ( + "math/big" + "testing" + + "github.com/stretchr/testify/require" + + ethtypes "github.com/ethereum/go-ethereum/core/types" + + "github.com/evmos/evmos/v19/app" + utiltx "github.com/evmos/evmos/v19/testutil/tx" + evmtypes "github.com/evmos/evmos/v19/x/evm/types" + "github.com/evmos/os/encoding" +) + +func TestTxEncoding(t *testing.T) { + addr, key := utiltx.NewAddrKey() + signer := utiltx.NewSigner(key) + + ethTxParams := evmtypes.EvmTxArgs{ + ChainID: big.NewInt(1), + Nonce: 1, + Amount: big.NewInt(10), + GasLimit: 100000, + GasFeeCap: big.NewInt(1), + GasTipCap: big.NewInt(1), + Input: []byte{}, + } + msg := evmtypes.NewTx(ðTxParams) + msg.From = addr.Hex() + + ethSigner := ethtypes.LatestSignerForChainID(big.NewInt(1)) + err := msg.Sign(ethSigner, signer) + require.NoError(t, err) + + cfg := encoding.MakeConfig(app.ModuleBasics) + + _, err = cfg.TxConfig.TxEncoder()(msg) + require.Error(t, err, "encoding failed") + + // FIXME: transaction hashing is hardcoded on Tendermint: + // See https://github.com/cometbft/cometbft/issues/6539 for reference + // txHash := msg.AsTransaction().Hash() + // tmTx := tmtypes.Tx(bz) + + // require.Equal(t, txHash.Bytes(), tmTx.Hash()) +} diff --git a/ethereum/eip712/eip712_test.go b/ethereum/eip712/eip712_test.go index 8d83f13..cbedc7c 100644 --- a/ethereum/eip712/eip712_test.go +++ b/ethereum/eip712/eip712_test.go @@ -25,8 +25,8 @@ import ( "github.com/ethereum/go-ethereum/signer/core/apitypes" "github.com/evmos/evmos/v19/app" "github.com/evmos/evmos/v19/cmd/config" - "github.com/evmos/evmos/v19/crypto/ethsecp256k1" - "github.com/evmos/evmos/v19/encoding" + "github.com/evmos/os/crypto/ethsecp256k1" + "github.com/evmos/os/encoding" "github.com/evmos/os/ethereum/eip712" "github.com/evmos/os/testutil" "github.com/stretchr/testify/suite" diff --git a/ethereum/eip712/preprocess.go b/ethereum/eip712/preprocess.go index 5ed4e7e..b2bf6d6 100644 --- a/ethereum/eip712/preprocess.go +++ b/ethereum/eip712/preprocess.go @@ -13,7 +13,7 @@ import ( "github.com/evmos/os/types" ) -// PreprocessLedgerTx reformats Ledger-signed Cosmos transactions to match the fork expected by Ethermint +// PreprocessLedgerTx reformats Ledger-signed Cosmos transactions to match the fork expected by evmOS // by including the signature in a Web3Tx extension and sending a blank signature in the body. func PreprocessLedgerTx(chainID string, keyType cosmoskr.KeyType, txBuilder client.TxBuilder) error { // Only process Ledger transactions @@ -65,7 +65,7 @@ func PreprocessLedgerTx(chainID string, keyType cosmoskr.KeyType, txBuilder clie extensionBuilder.SetExtensionOptions(option) // Set blank signature with Amino Sign Type - // (Regardless of input signMode, Evmos requires Amino signature type for Ledger) + // (Regardless of input signMode, evmOS requires Amino signature type for Ledger) blankSig := signing.SingleSignatureData{ SignMode: signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, Signature: nil, diff --git a/ethereum/eip712/preprocess_test.go b/ethereum/eip712/preprocess_test.go index 42a1aef..b8d3f56 100644 --- a/ethereum/eip712/preprocess_test.go +++ b/ethereum/eip712/preprocess_test.go @@ -16,8 +16,8 @@ import ( "github.com/evmos/evmos/v19/app" "github.com/evmos/evmos/v19/cmd/config" - "github.com/evmos/evmos/v19/encoding" utiltx "github.com/evmos/evmos/v19/testutil/tx" + "github.com/evmos/os/encoding" "github.com/evmos/os/ethereum/eip712" "github.com/evmos/os/testutil" "github.com/evmos/os/types" diff --git a/go.mod b/go.mod index 80abbf6..4288df9 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,8 @@ require ( cosmossdk.io/errors v1.0.1 cosmossdk.io/math v1.3.0 cosmossdk.io/simapp v0.0.0-20230608160436-666c345ad23d + github.com/btcsuite/btcd v0.24.2 + github.com/btcsuite/btcd/btcutil v1.1.5 github.com/cometbft/cometbft v0.37.9 github.com/cosmos/cosmos-sdk v0.47.12 github.com/cosmos/gogoproto v1.4.10 @@ -15,6 +17,7 @@ require ( github.com/stretchr/testify v1.9.0 github.com/tidwall/gjson v1.17.3 github.com/tidwall/sjson v1.2.5 + github.com/tyler-smith/go-bip39 v1.1.0 github.com/zondax/hid v0.9.2 golang.org/x/exp v0.0.0-20230905200255-921286631fa9 golang.org/x/text v0.16.0 @@ -44,6 +47,7 @@ require ( github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect + github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect github.com/cenkalti/backoff/v4 v4.1.3 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/chzyer/readline v1.5.1 // indirect diff --git a/go.sum b/go.sum index a4a9fc8..2afa97c 100644 --- a/go.sum +++ b/go.sum @@ -226,6 +226,7 @@ github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrd github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= github.com/adlio/schema v1.3.3 h1:oBJn8I02PyTB466pZO1UZEn1TV5XLlifBSyMrmHl/1I= github.com/adlio/schema v1.3.3/go.mod h1:1EsRssiv9/Ce2CMzq5DoL7RiMshhuigQxrR4DMV9fHg= +github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= @@ -261,13 +262,32 @@ github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 h1:41iFGWnSlI2gVpmOtVTJZNodLdLQLn/KsJqFvXwnd/s= github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= +github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M= +github.com/btcsuite/btcd v0.23.5-0.20231215221805-96c9fd8078fd/go.mod h1:nm3Bko6zh6bWP60UxwoT5LzdGJsQJaPo6HjduXq9p6A= github.com/btcsuite/btcd v0.24.2 h1:aLmxPguqxza+4ag8R1I2nnJjSu2iFn/kqtHTIImswcY= +github.com/btcsuite/btcd v0.24.2/go.mod h1:5C8ChTkl5ejr3WHj8tkQSCmydiMEPB0ZhQhehpq7Dgg= +github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA= +github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE= github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= +github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A= +github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE= github.com/btcsuite/btcd/btcutil v1.1.5 h1:+wER79R5670vs/ZusMTF1yTcRYE5GUsFbdjdisflzM8= github.com/btcsuite/btcd/btcutil v1.1.5/go.mod h1:PSZZ4UitpLBWzxGd5VGOrLnmOjtPP/a6HaFo12zMs00= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 h1:59Kx4K6lzOW5w6nFlA0v5+lk/6sjybR934QNHSJZPTQ= github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= +github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= +github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= +github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= +github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= +github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I= +github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= +github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= +github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= +github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8= github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= @@ -378,16 +398,20 @@ github.com/crypto-org-chain/cronos/versiondb v0.0.0-20240129013154-12efd9b7643f github.com/crypto-org-chain/cronos/versiondb v0.0.0-20240129013154-12efd9b7643f/go.mod h1:8L1WprpzpqIz6erpQjd/qOvMNpYDG4qzR5vWgAqv6Jw= github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0= github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0= +github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= +github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= +github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f h1:U5y3Y5UE0w7amNe7Z5G/twsBW0KEalRQXZzf8ufSh9I= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f/go.mod h1:xH/i4TFMt8koVQZ6WFms69WAsDWr2XsYL3Hkl7jkoLE= github.com/dgraph-io/badger/v4 v4.2.0 h1:kJrlajbXXL9DFTNuhhu9yCx7JJa4qpYWxtE8BzuWsEs= @@ -650,6 +674,7 @@ github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= @@ -727,6 +752,8 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= +github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c= github.com/jhump/protoreflect v1.15.1/go.mod h1:jD/2GMKKE6OqX8qTjhADU1e6DShO+gavG9e0Q693nKo= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= @@ -738,6 +765,7 @@ github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= +github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= @@ -754,6 +782,7 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= @@ -861,6 +890,7 @@ github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= github.com/onsi/ginkgo/v2 v2.19.1 h1:QXgq3Z8Crl5EL1WBAC98A5sEBHARrAJNzAmMxzLcRF0= github.com/onsi/ginkgo/v2 v2.19.1/go.mod h1:O3DtEWQkPa/F7fBMgmZQKKsluAy8pd3rEQdrjkPb9zA= +github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= @@ -1052,6 +1082,8 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1 github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= +github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= +github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= @@ -1117,6 +1149,7 @@ go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= +golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -1160,6 +1193,7 @@ golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= diff --git a/types/dynamic_fee.pb.go b/types/dynamic_fee.pb.go index 6b564c7..5e64776 100644 --- a/types/dynamic_fee.pb.go +++ b/types/dynamic_fee.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: ethermint/types/v1/dynamic_fee.proto +// source: os/types/v1/dynamic_fee.proto package types @@ -24,9 +24,11 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// ExtensionOptionDynamicFeeTx is an extension option that specifies the maxPrioPrice for cosmos tx +// ExtensionOptionDynamicFeeTx is an extension option that specifies the +// maxPrioPrice for cosmos tx type ExtensionOptionDynamicFeeTx struct { - // max_priority_price is the same as `max_priority_fee_per_gas` in eip-1559 spec + // max_priority_price is the same as `max_priority_fee_per_gas` in eip-1559 + // spec MaxPriorityPrice cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=max_priority_price,json=maxPriorityPrice,proto3,customtype=cosmossdk.io/math.Int" json:"max_priority_price"` } @@ -34,7 +36,7 @@ func (m *ExtensionOptionDynamicFeeTx) Reset() { *m = ExtensionOptionDyna func (m *ExtensionOptionDynamicFeeTx) String() string { return proto.CompactTextString(m) } func (*ExtensionOptionDynamicFeeTx) ProtoMessage() {} func (*ExtensionOptionDynamicFeeTx) Descriptor() ([]byte, []int) { - return fileDescriptor_9d7cf05c9992c480, []int{0} + return fileDescriptor_a9afa21b8d75b43a, []int{0} } func (m *ExtensionOptionDynamicFeeTx) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -64,30 +66,28 @@ func (m *ExtensionOptionDynamicFeeTx) XXX_DiscardUnknown() { var xxx_messageInfo_ExtensionOptionDynamicFeeTx proto.InternalMessageInfo func init() { - proto.RegisterType((*ExtensionOptionDynamicFeeTx)(nil), "ethermint.types.v1.ExtensionOptionDynamicFeeTx") + proto.RegisterType((*ExtensionOptionDynamicFeeTx)(nil), "os.types.v1.ExtensionOptionDynamicFeeTx") } -func init() { - proto.RegisterFile("ethermint/types/v1/dynamic_fee.proto", fileDescriptor_9d7cf05c9992c480) -} +func init() { proto.RegisterFile("os/types/v1/dynamic_fee.proto", fileDescriptor_a9afa21b8d75b43a) } -var fileDescriptor_9d7cf05c9992c480 = []byte{ - // 238 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x49, 0x2d, 0xc9, 0x48, - 0x2d, 0xca, 0xcd, 0xcc, 0x2b, 0xd1, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x2f, 0x33, 0xd4, 0x4f, - 0xa9, 0xcc, 0x4b, 0xcc, 0xcd, 0x4c, 0x8e, 0x4f, 0x4b, 0x4d, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, - 0x17, 0x12, 0x82, 0xab, 0xd2, 0x03, 0xab, 0xd2, 0x2b, 0x33, 0x94, 0x12, 0x49, 0xcf, 0x4f, 0xcf, - 0x07, 0x4b, 0xeb, 0x83, 0x58, 0x10, 0x95, 0x4a, 0x59, 0x5c, 0xd2, 0xae, 0x15, 0x25, 0xa9, 0x79, - 0xc5, 0x99, 0xf9, 0x79, 0xfe, 0x05, 0x25, 0x99, 0xf9, 0x79, 0x2e, 0x10, 0xd3, 0xdc, 0x52, 0x53, - 0x43, 0x2a, 0x84, 0xbc, 0xb9, 0x84, 0x72, 0x13, 0x2b, 0xe2, 0x0b, 0x8a, 0x32, 0xf3, 0x8b, 0x32, - 0x4b, 0x2a, 0x41, 0x8c, 0xe4, 0x54, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x4e, 0x27, 0xd9, 0x13, 0xf7, - 0xe4, 0x19, 0x6e, 0xdd, 0x93, 0x17, 0x4d, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0x2e, 0x4e, 0xc9, 0xd6, - 0xcb, 0xcc, 0xd7, 0xcf, 0x4d, 0x2c, 0xc9, 0xd0, 0xf3, 0xcc, 0x2b, 0x09, 0x12, 0xc8, 0x4d, 0xac, - 0x08, 0x80, 0xea, 0x0b, 0x00, 0x69, 0x73, 0xb2, 0x3a, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, - 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, - 0x39, 0x86, 0x28, 0x85, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0xfd, 0xd4, - 0xb2, 0xdc, 0xfc, 0x62, 0x28, 0x59, 0x66, 0x68, 0x01, 0xf1, 0x66, 0x12, 0x1b, 0xd8, 0xb9, 0xc6, - 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc3, 0x94, 0x96, 0xc5, 0x00, 0x01, 0x00, 0x00, +var fileDescriptor_a9afa21b8d75b43a = []byte{ + // 227 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcd, 0x2f, 0xd6, 0x2f, + 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x2f, 0x33, 0xd4, 0x4f, 0xa9, 0xcc, 0x4b, 0xcc, 0xcd, 0x4c, 0x8e, + 0x4f, 0x4b, 0x4d, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0xce, 0x2f, 0xd6, 0x03, 0x4b, + 0xeb, 0x95, 0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0xc5, 0xf5, 0x41, 0x2c, 0x88, 0x12, + 0xa5, 0x2c, 0x2e, 0x69, 0xd7, 0x8a, 0x92, 0xd4, 0xbc, 0xe2, 0xcc, 0xfc, 0x3c, 0xff, 0x82, 0x92, + 0xcc, 0xfc, 0x3c, 0x17, 0x88, 0x31, 0x6e, 0xa9, 0xa9, 0x21, 0x15, 0x42, 0xde, 0x5c, 0x42, 0xb9, + 0x89, 0x15, 0xf1, 0x05, 0x45, 0x99, 0xf9, 0x45, 0x99, 0x25, 0x95, 0x20, 0x46, 0x72, 0xaa, 0x04, + 0xa3, 0x02, 0xa3, 0x06, 0xa7, 0x93, 0xec, 0x89, 0x7b, 0xf2, 0x0c, 0xb7, 0xee, 0xc9, 0x8b, 0x26, + 0xe7, 0x17, 0xe7, 0xe6, 0x17, 0x17, 0xa7, 0x64, 0xeb, 0x65, 0xe6, 0xeb, 0xe7, 0x26, 0x96, 0x64, + 0xe8, 0x79, 0xe6, 0x95, 0x04, 0x09, 0xe4, 0x26, 0x56, 0x04, 0x40, 0xf5, 0x05, 0x80, 0xb4, 0x39, + 0x19, 0x9f, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, + 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x64, 0x7a, 0x66, 0x49, + 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x7e, 0x6a, 0x59, 0x6e, 0x7e, 0xb1, 0x3e, 0xcc, 0x63, + 0x49, 0x6c, 0x60, 0x77, 0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x4d, 0xf3, 0xbb, 0x1c, 0xeb, + 0x00, 0x00, 0x00, } func (m *ExtensionOptionDynamicFeeTx) Marshal() (dAtA []byte, err error) { diff --git a/types/indexer.pb.go b/types/indexer.pb.go index e1d1005..c2e1426 100644 --- a/types/indexer.pb.go +++ b/types/indexer.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: ethermint/types/v1/indexer.proto +// source: os/types/v1/indexer.proto package types @@ -48,7 +48,7 @@ func (m *TxResult) Reset() { *m = TxResult{} } func (m *TxResult) String() string { return proto.CompactTextString(m) } func (*TxResult) ProtoMessage() {} func (*TxResult) Descriptor() ([]byte, []int) { - return fileDescriptor_1197e10a8be8ed28, []int{0} + return fileDescriptor_188b47a956fe6721, []int{0} } func (m *TxResult) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -78,32 +78,32 @@ func (m *TxResult) XXX_DiscardUnknown() { var xxx_messageInfo_TxResult proto.InternalMessageInfo func init() { - proto.RegisterType((*TxResult)(nil), "ethermint.types.v1.TxResult") + proto.RegisterType((*TxResult)(nil), "os.types.v1.TxResult") } -func init() { proto.RegisterFile("ethermint/types/v1/indexer.proto", fileDescriptor_1197e10a8be8ed28) } +func init() { proto.RegisterFile("os/types/v1/indexer.proto", fileDescriptor_188b47a956fe6721) } -var fileDescriptor_1197e10a8be8ed28 = []byte{ - // 298 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x44, 0x90, 0x31, 0x4b, 0xc3, 0x40, - 0x18, 0x86, 0x73, 0xb6, 0x4d, 0xe3, 0xa1, 0x83, 0x51, 0x4a, 0x54, 0x88, 0x87, 0x53, 0xa6, 0x84, - 0xe2, 0x22, 0x1d, 0x5d, 0xc4, 0xf5, 0xa8, 0x8b, 0x4b, 0x48, 0x9b, 0xcf, 0xbb, 0x83, 0x5e, 0xaf, - 0xf4, 0xbe, 0x84, 0xf8, 0x0f, 0x1c, 0xfd, 0x09, 0xfe, 0x1c, 0xc7, 0x8e, 0x8e, 0xd2, 0xe2, 0xff, - 0x90, 0x5e, 0x42, 0x5d, 0x8e, 0x7b, 0x79, 0x9e, 0x8f, 0x17, 0x5e, 0xca, 0x00, 0x25, 0xac, 0xb5, - 0x5a, 0x62, 0x86, 0x6f, 0x2b, 0xb0, 0x59, 0x3d, 0xce, 0xd4, 0xb2, 0x84, 0x06, 0xd6, 0xe9, 0x6a, - 0x6d, 0xd0, 0x84, 0xe1, 0xc1, 0x48, 0x9d, 0x91, 0xd6, 0xe3, 0xab, 0x0b, 0x61, 0x84, 0x71, 0x38, - 0xdb, 0xff, 0x5a, 0xf3, 0xf6, 0x97, 0xd0, 0x60, 0xda, 0x70, 0xb0, 0xd5, 0x02, 0xc3, 0x11, 0xf5, - 0x25, 0x28, 0x21, 0x31, 0x22, 0x8c, 0x24, 0x3d, 0xde, 0xa5, 0xf0, 0x92, 0x06, 0xd8, 0xe4, 0xae, - 0x22, 0x3a, 0x62, 0x24, 0x39, 0xe5, 0x43, 0x6c, 0x9e, 0xf6, 0x31, 0xbc, 0xa6, 0xc7, 0xda, 0x8a, - 0x8e, 0xf5, 0x1c, 0x0b, 0xb4, 0x15, 0x2d, 0x64, 0xf4, 0x04, 0x50, 0xe6, 0x87, 0xdb, 0x3e, 0x23, - 0xc9, 0x80, 0x53, 0x40, 0x39, 0xed, 0xce, 0x47, 0xd4, 0x7f, 0x2d, 0xd4, 0x02, 0xca, 0x68, 0xc0, - 0x48, 0x12, 0xf0, 0x2e, 0xed, 0x1b, 0x45, 0x61, 0xf3, 0xca, 0x42, 0x19, 0xf9, 0x8c, 0x24, 0x7d, - 0x3e, 0x14, 0x85, 0x7d, 0xb6, 0x50, 0x86, 0x29, 0x3d, 0x9f, 0x57, 0xba, 0x5a, 0x14, 0xa8, 0x6a, - 0xc8, 0x0f, 0xd6, 0xd0, 0x59, 0x67, 0xff, 0xe8, 0xb1, 0xf5, 0x27, 0xfd, 0xf7, 0xcf, 0x1b, 0xef, - 0x61, 0xf2, 0xb5, 0x8d, 0xc9, 0x66, 0x1b, 0x93, 0x9f, 0x6d, 0x4c, 0x3e, 0x76, 0xb1, 0xb7, 0xd9, - 0xc5, 0xde, 0xf7, 0x2e, 0xf6, 0x5e, 0x98, 0x50, 0x28, 0xab, 0x59, 0x3a, 0x37, 0x3a, 0x83, 0x5a, - 0x1b, 0xdb, 0xbd, 0xf5, 0xf8, 0xbe, 0x9d, 0x77, 0xe6, 0xbb, 0xa9, 0xee, 0xfe, 0x02, 0x00, 0x00, - 0xff, 0xff, 0x8e, 0x96, 0x1b, 0x8f, 0x78, 0x01, 0x00, 0x00, +var fileDescriptor_188b47a956fe6721 = []byte{ + // 290 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x44, 0x90, 0xb1, 0x4e, 0xeb, 0x30, + 0x18, 0x85, 0xe3, 0xdb, 0x36, 0xc9, 0x35, 0x30, 0x10, 0x50, 0x95, 0x80, 0x64, 0x2c, 0xa6, 0x4c, + 0xb1, 0xaa, 0x6e, 0x8c, 0x2c, 0x88, 0xd5, 0x2a, 0x0b, 0x4b, 0x94, 0x36, 0x3f, 0x4e, 0xa4, 0x04, + 0x57, 0xb5, 0x13, 0x85, 0x37, 0x60, 0xe4, 0x11, 0x78, 0x1c, 0xc6, 0x8e, 0x8c, 0x28, 0x11, 0xef, + 0x81, 0xe2, 0x84, 0xb2, 0xf9, 0xf8, 0xfb, 0x8e, 0x2d, 0x1d, 0x1c, 0x48, 0xc5, 0xf4, 0xcb, 0x16, + 0x14, 0xab, 0x17, 0x2c, 0x7f, 0x4e, 0xa1, 0x81, 0x5d, 0xb4, 0xdd, 0x49, 0x2d, 0xbd, 0x23, 0xa9, + 0x22, 0x83, 0xa2, 0x7a, 0x71, 0x71, 0x2e, 0xa4, 0x90, 0xe6, 0x9e, 0xf5, 0xa7, 0x41, 0xb9, 0xfe, + 0x46, 0xd8, 0x5d, 0x35, 0x1c, 0x54, 0x55, 0x68, 0x6f, 0x8e, 0xed, 0x0c, 0x72, 0x91, 0x69, 0x1f, + 0x51, 0x14, 0x4e, 0xf8, 0x98, 0xbc, 0x00, 0xbb, 0xba, 0x89, 0xcd, 0xdb, 0xfe, 0x3f, 0x8a, 0xc2, + 0x13, 0xee, 0xe8, 0xe6, 0xbe, 0x8f, 0xde, 0x25, 0xfe, 0x5f, 0x2a, 0x31, 0xb2, 0x89, 0x61, 0x6e, + 0xa9, 0xc4, 0x00, 0x29, 0x3e, 0x06, 0x9d, 0xc5, 0x87, 0xee, 0x94, 0xa2, 0x70, 0xc6, 0x31, 0xe8, + 0x6c, 0x35, 0xd6, 0xe7, 0xd8, 0x7e, 0x4a, 0xf2, 0x02, 0x52, 0x7f, 0x46, 0x51, 0xe8, 0xf2, 0x31, + 0xf5, 0x3f, 0x8a, 0x44, 0xc5, 0x95, 0x82, 0xd4, 0xb7, 0x29, 0x0a, 0xa7, 0xdc, 0x11, 0x89, 0x7a, + 0x50, 0x90, 0x7a, 0x11, 0x3e, 0xdb, 0x54, 0x65, 0x55, 0x24, 0x3a, 0xaf, 0x21, 0x3e, 0x58, 0x8e, + 0xb1, 0x4e, 0xff, 0xd0, 0xdd, 0xe0, 0xdf, 0x4c, 0x5f, 0xdf, 0xaf, 0xac, 0xdb, 0xe5, 0x47, 0x4b, + 0xd0, 0xbe, 0x25, 0xe8, 0xab, 0x25, 0xe8, 0xad, 0x23, 0xd6, 0xbe, 0x23, 0xd6, 0x67, 0x47, 0xac, + 0xc7, 0x40, 0xe4, 0x3a, 0xab, 0xd6, 0xd1, 0x46, 0x96, 0x0c, 0xea, 0x52, 0x2a, 0xf6, 0x3b, 0xe8, + 0xda, 0x36, 0x1b, 0x2d, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x34, 0xaa, 0x8e, 0x4b, 0x63, 0x01, + 0x00, 0x00, } func (m *TxResult) Marshal() (dAtA []byte, err error) { diff --git a/types/web3.pb.go b/types/web3.pb.go index f780bfa..7455ecc 100644 --- a/types/web3.pb.go +++ b/types/web3.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: ethermint/types/v1/web3.proto +// source: os/types/v1/web3.proto package types @@ -23,8 +23,8 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// ExtensionOptionsWeb3Tx is an extension option that specifies the typed chain id, -// the fee payer as well as its signature data. +// ExtensionOptionsWeb3Tx is an extension option that specifies the typed chain +// id, the fee payer as well as its signature data. type ExtensionOptionsWeb3Tx struct { // typed_data_chain_id is used only in EIP712 Domain and should match // Ethereum network ID in a Web3 provider (e.g. Metamask). @@ -41,7 +41,7 @@ func (m *ExtensionOptionsWeb3Tx) Reset() { *m = ExtensionOptionsWeb3Tx{} func (m *ExtensionOptionsWeb3Tx) String() string { return proto.CompactTextString(m) } func (*ExtensionOptionsWeb3Tx) ProtoMessage() {} func (*ExtensionOptionsWeb3Tx) Descriptor() ([]byte, []int) { - return fileDescriptor_9eb7cd56e3c92bc3, []int{0} + return fileDescriptor_36d81232614baf9d, []int{0} } func (m *ExtensionOptionsWeb3Tx) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -71,32 +71,32 @@ func (m *ExtensionOptionsWeb3Tx) XXX_DiscardUnknown() { var xxx_messageInfo_ExtensionOptionsWeb3Tx proto.InternalMessageInfo func init() { - proto.RegisterType((*ExtensionOptionsWeb3Tx)(nil), "ethermint.types.v1.ExtensionOptionsWeb3Tx") + proto.RegisterType((*ExtensionOptionsWeb3Tx)(nil), "os.types.v1.ExtensionOptionsWeb3Tx") } -func init() { proto.RegisterFile("ethermint/types/v1/web3.proto", fileDescriptor_9eb7cd56e3c92bc3) } +func init() { proto.RegisterFile("os/types/v1/web3.proto", fileDescriptor_36d81232614baf9d) } -var fileDescriptor_9eb7cd56e3c92bc3 = []byte{ - // 304 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4d, 0x2d, 0xc9, 0x48, - 0x2d, 0xca, 0xcd, 0xcc, 0x2b, 0xd1, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x2f, 0x33, 0xd4, 0x2f, - 0x4f, 0x4d, 0x32, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x82, 0x4b, 0xeb, 0x81, 0xa5, - 0xf5, 0xca, 0x0c, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0xd2, 0xfa, 0x20, 0x16, 0x44, 0xa5, - 0xd2, 0x57, 0x46, 0x2e, 0x31, 0xd7, 0x8a, 0x92, 0xd4, 0xbc, 0xe2, 0xcc, 0xfc, 0x3c, 0xff, 0x82, - 0x92, 0xcc, 0xfc, 0xbc, 0xe2, 0xf0, 0xd4, 0x24, 0xe3, 0x90, 0x0a, 0xa1, 0x44, 0x2e, 0x61, 0x90, - 0xe6, 0x94, 0xf8, 0x94, 0xc4, 0x92, 0xc4, 0xf8, 0xe4, 0x8c, 0xc4, 0xcc, 0xbc, 0xf8, 0xcc, 0x14, - 0x09, 0x46, 0x05, 0x46, 0x0d, 0x16, 0x27, 0xa3, 0x47, 0xf7, 0xe4, 0x05, 0x42, 0x40, 0xd2, 0x2e, - 0x89, 0x25, 0x89, 0xce, 0x20, 0x49, 0x4f, 0x97, 0x57, 0xf7, 0xe4, 0xa5, 0x4a, 0xd0, 0xc4, 0x74, - 0xf2, 0x73, 0x33, 0x4b, 0x52, 0x73, 0x0b, 0x4a, 0x2a, 0x83, 0x04, 0xd0, 0xe4, 0x52, 0x84, 0x8c, - 0xb9, 0x38, 0xd3, 0x52, 0x53, 0xe3, 0x0b, 0x12, 0x2b, 0x53, 0x8b, 0x24, 0x98, 0x14, 0x18, 0x35, - 0x38, 0x9d, 0xc4, 0x5e, 0xdd, 0x93, 0x17, 0x4a, 0x4b, 0x4d, 0x0d, 0x00, 0x89, 0x21, 0x69, 0xe6, - 0x80, 0x89, 0x09, 0xd9, 0x72, 0xf1, 0xc2, 0x35, 0xc5, 0x17, 0x67, 0xa6, 0x4b, 0x30, 0x2b, 0x30, - 0x6a, 0xf0, 0x38, 0x49, 0xbe, 0xba, 0x27, 0x2f, 0x0a, 0x53, 0x14, 0x9c, 0x99, 0x8e, 0xa4, 0x97, - 0x1b, 0x49, 0xd8, 0x8a, 0xa5, 0x63, 0x81, 0x3c, 0x83, 0x93, 0xd5, 0x89, 0x47, 0x72, 0x8c, 0x17, - 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, - 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x29, 0xa4, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, - 0xea, 0xa7, 0x96, 0xe5, 0xe6, 0x17, 0x43, 0xc9, 0x32, 0x43, 0x0b, 0x48, 0x58, 0x27, 0xb1, 0x81, - 0x83, 0xce, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x1d, 0xbb, 0x93, 0xf7, 0x85, 0x01, 0x00, 0x00, +var fileDescriptor_36d81232614baf9d = []byte{ + // 294 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xcb, 0x2f, 0xd6, 0x2f, + 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x2f, 0x33, 0xd4, 0x2f, 0x4f, 0x4d, 0x32, 0xd6, 0x2b, 0x28, 0xca, + 0x2f, 0xc9, 0x17, 0xe2, 0xce, 0x2f, 0xd6, 0x03, 0x8b, 0xeb, 0x95, 0x19, 0x4a, 0x89, 0xa4, 0xe7, + 0xa7, 0xe7, 0x83, 0xc5, 0xf5, 0x41, 0x2c, 0x88, 0x12, 0xa5, 0xaf, 0x8c, 0x5c, 0x62, 0xae, 0x15, + 0x25, 0xa9, 0x79, 0xc5, 0x99, 0xf9, 0x79, 0xfe, 0x05, 0x25, 0x99, 0xf9, 0x79, 0xc5, 0xe1, 0xa9, + 0x49, 0xc6, 0x21, 0x15, 0x42, 0x89, 0x5c, 0xc2, 0x20, 0xcd, 0x29, 0xf1, 0x29, 0x89, 0x25, 0x89, + 0xf1, 0xc9, 0x19, 0x89, 0x99, 0x79, 0xf1, 0x99, 0x29, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x2c, 0x4e, + 0x46, 0x8f, 0xee, 0xc9, 0x0b, 0x84, 0x80, 0xa4, 0x5d, 0x12, 0x4b, 0x12, 0x9d, 0x41, 0x92, 0x9e, + 0x2e, 0xaf, 0xee, 0xc9, 0x4b, 0x95, 0xa0, 0x89, 0xe9, 0xe4, 0xe7, 0x66, 0x96, 0xa4, 0xe6, 0x16, + 0x94, 0x54, 0x06, 0x09, 0xa0, 0xc9, 0xa5, 0x08, 0x19, 0x73, 0x71, 0xa6, 0xa5, 0xa6, 0xc6, 0x17, + 0x24, 0x56, 0xa6, 0x16, 0x49, 0x30, 0x29, 0x30, 0x6a, 0x70, 0x3a, 0x89, 0xbd, 0xba, 0x27, 0x2f, + 0x94, 0x96, 0x9a, 0x1a, 0x00, 0x12, 0x43, 0xd2, 0xcc, 0x01, 0x13, 0x13, 0xb2, 0xe5, 0xe2, 0x85, + 0x6b, 0x8a, 0x2f, 0xce, 0x4c, 0x97, 0x60, 0x56, 0x60, 0xd4, 0xe0, 0x71, 0x92, 0x7c, 0x75, 0x4f, + 0x5e, 0x14, 0xa6, 0x28, 0x38, 0x33, 0x1d, 0x49, 0x2f, 0x37, 0x92, 0xb0, 0x15, 0x4b, 0xc7, 0x02, + 0x79, 0x06, 0x27, 0xe3, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, + 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x92, 0x4c, + 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0x2d, 0xcb, 0xcd, 0x2f, 0xd6, + 0x87, 0x85, 0x6e, 0x12, 0x1b, 0x38, 0xcc, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x0b, 0x36, + 0x49, 0x21, 0x70, 0x01, 0x00, 0x00, } func (m *ExtensionOptionsWeb3Tx) Marshal() (dAtA []byte, err error) { diff --git a/utils/utils.go b/utils/utils.go index 07ac672..0af3ddb 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -16,7 +16,7 @@ import ( errortypes "github.com/cosmos/cosmos-sdk/types/errors" ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" "github.com/ethereum/go-ethereum/common" - "github.com/evmos/evmos/v19/crypto/ethsecp256k1" + "github.com/evmos/os/crypto/ethsecp256k1" "golang.org/x/exp/constraints" ) diff --git a/utils/utils_test.go b/utils/utils_test.go index 3ccbbbc..adc29bd 100644 --- a/utils/utils_test.go +++ b/utils/utils_test.go @@ -10,7 +10,7 @@ import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" - "github.com/evmos/evmos/v19/crypto/ethsecp256k1" + "github.com/evmos/os/crypto/ethsecp256k1" "github.com/stretchr/testify/require" ) diff --git a/wallets/ledger/ledger_test.go b/wallets/ledger/ledger_test.go index 957214a..d1eb54e 100644 --- a/wallets/ledger/ledger_test.go +++ b/wallets/ledger/ledger_test.go @@ -9,7 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/evmos/evmos/v19/app" - "github.com/evmos/evmos/v19/encoding" + "github.com/evmos/os/encoding" "github.com/evmos/os/ethereum/eip712" "github.com/evmos/os/wallets/accounts" "github.com/evmos/os/wallets/ledger"