From 6603d85c05360dbd299cb5383885b547c030ee05 Mon Sep 17 00:00:00 2001 From: HuangYi Date: Fri, 26 Apr 2024 14:44:51 +0800 Subject: [PATCH 1/8] Problem: no end-to-end encryption module add keeper add grpc query signer option getter/setter genesis init/export fix lint --- app/app.go | 12 + app/upgrades.go | 2 + proto/e2ee/genesis.proto | 18 ++ proto/e2ee/query.proto | 25 ++ proto/e2ee/tx.proto | 27 ++ x/e2ee/README.md | 2 + x/e2ee/autocli.go | 22 ++ x/e2ee/keeper/keeper.go | 87 ++++++ x/e2ee/module.go | 135 +++++++++ x/e2ee/types/genesis.go | 12 + x/e2ee/types/genesis.pb.go | 557 ++++++++++++++++++++++++++++++++++ x/e2ee/types/keys.go | 29 ++ x/e2ee/types/query.pb.go | 585 ++++++++++++++++++++++++++++++++++++ x/e2ee/types/query.pb.gw.go | 189 ++++++++++++ x/e2ee/types/tx.pb.go | 585 ++++++++++++++++++++++++++++++++++++ 15 files changed, 2287 insertions(+) create mode 100644 proto/e2ee/genesis.proto create mode 100644 proto/e2ee/query.proto create mode 100644 proto/e2ee/tx.proto create mode 100644 x/e2ee/README.md create mode 100644 x/e2ee/autocli.go create mode 100644 x/e2ee/keeper/keeper.go create mode 100644 x/e2ee/module.go create mode 100644 x/e2ee/types/genesis.go create mode 100644 x/e2ee/types/genesis.pb.go create mode 100644 x/e2ee/types/keys.go create mode 100644 x/e2ee/types/query.pb.go create mode 100644 x/e2ee/types/query.pb.gw.go create mode 100644 x/e2ee/types/tx.pb.go diff --git a/app/app.go b/app/app.go index 055ae5bd70..be1ab44896 100644 --- a/app/app.go +++ b/app/app.go @@ -162,6 +162,10 @@ import ( icaauthkeeper "github.com/crypto-org-chain/cronos/v2/x/icaauth/keeper" icaauthtypes "github.com/crypto-org-chain/cronos/v2/x/icaauth/types" + e2ee "github.com/crypto-org-chain/cronos/v2/x/e2ee" + e2eekeeper "github.com/crypto-org-chain/cronos/v2/x/e2ee/keeper" + e2eetypes "github.com/crypto-org-chain/cronos/v2/x/e2ee/types" + // force register the extension json-rpc. _ "github.com/crypto-org-chain/cronos/v2/x/cronos/rpc" _ "github.com/ethereum/go-ethereum/eth/tracers/js" @@ -250,6 +254,8 @@ func StoreKeys() ( icahosttypes.StoreKey, // ethermint keys evmtypes.StoreKey, feemarkettypes.StoreKey, + // e2ee keys + e2eetypes.StoreKey, // this line is used by starport scaffolding # stargate/app/storeKey cronostypes.StoreKey, } @@ -320,6 +326,9 @@ type App struct { EvmKeeper *evmkeeper.Keeper FeeMarketKeeper feemarketkeeper.Keeper + // e2ee keeper + E2EEKeeper e2eekeeper.Keeper + // this line is used by starport scaffolding # stargate/app/keeperDeclaration CronosKeeper cronoskeeper.Keeper @@ -704,6 +713,8 @@ func New( // If evidence needs to be handled for the app, set routes in router here and seal app.EvidenceKeeper = *evidenceKeeper + app.E2EEKeeper = e2eekeeper.NewKeeper(keys[e2eetypes.StoreKey], app.AccountKeeper.AddressCodec()) + /**** Module Options ****/ // NOTE: we may consider parsing `appOpts` inside module constructors. For the moment @@ -754,6 +765,7 @@ func New( // Ethermint app modules feemarket.NewAppModule(app.FeeMarketKeeper, feeMarketS), evm.NewAppModule(app.EvmKeeper, app.AccountKeeper, evmS), + e2ee.NewAppModule(app.E2EEKeeper), // Cronos app modules cronosModule, diff --git a/app/upgrades.go b/app/upgrades.go index d49b946fbb..906b1a32e5 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -11,6 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" icahosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types" clientkeeper "github.com/cosmos/ibc-go/v8/modules/core/02-client/keeper" + e2eetypes "github.com/crypto-org-chain/cronos/v2/x/e2ee/types" ) func (app *App) RegisterUpgradeHandlers(cdc codec.BinaryCodec, clientKeeper clientkeeper.Keeper) { @@ -39,6 +40,7 @@ func (app *App) RegisterUpgradeHandlers(cdc codec.BinaryCodec, clientKeeper clie app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storetypes.StoreUpgrades{ Added: []string{ icahosttypes.StoreKey, + e2eetypes.StoreKey, }, })) } diff --git a/proto/e2ee/genesis.proto b/proto/e2ee/genesis.proto new file mode 100644 index 0000000000..cf69a6b70c --- /dev/null +++ b/proto/e2ee/genesis.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; +package e2ee; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/crypto-org-chain/cronos/v2/x/e2ee/types"; + +// EncryptionKeyEntry is a type that contains the owner and the public key. +message EncryptionKeyEntry { + string address = 1; + bytes key = 2; +} + +// GenesisState defines the e2ee module's genesis state. +message GenesisState { + // params defines all the paramaters of the module. + repeated EncryptionKeyEntry keys = 1 [(gogoproto.nullable) = false]; +} diff --git a/proto/e2ee/query.proto b/proto/e2ee/query.proto new file mode 100644 index 0000000000..6c5c7a6b84 --- /dev/null +++ b/proto/e2ee/query.proto @@ -0,0 +1,25 @@ +syntax = "proto3"; +package e2ee; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; + +option go_package = "github.com/crypto-org-chain/cronos/v2/x/e2ee/types"; + +// Query defines the gRPC querier service. +service Query { + // Key queries the encryption key of a given address + rpc Key(KeyRequest) returns (KeyResponse) { + option (google.api.http).get = "/e2ee/v1/key/{address}"; + } +} + +// KeyRequest is the request type for the Query/Key RPC method. +message KeyRequest { + string address = 1; +} + +// KeyResponse is the response type for the Query/Key RPC method. +message KeyResponse { + bytes key = 1; +} diff --git a/proto/e2ee/tx.proto b/proto/e2ee/tx.proto new file mode 100644 index 0000000000..93a6d0e51a --- /dev/null +++ b/proto/e2ee/tx.proto @@ -0,0 +1,27 @@ +syntax = "proto3"; +package e2ee; + +import "cosmos/msg/v1/msg.proto"; +import "gogoproto/gogo.proto"; + +option go_package = "github.com/crypto-org-chain/cronos/v2/x/e2ee/types"; + +// Msg defines the e2ee Msg service +service Msg { + option (cosmos.msg.v1.service) = true; + + // RegisterEncryptionKey registers a new encryption key to a specific account + rpc RegisterEncryptionKey(MsgRegisterEncryptionKey) returns (MsgRegisterEncryptionKeyResponse); +} + +// MsgRegisterEncryptionKey defines the Msg/RegisterEncryptionKey request type +message MsgRegisterEncryptionKey { + option (cosmos.msg.v1.signer) = "address"; + + string address = 1; + bytes key = 2; +} + +// MsgRegisterEncryptionKeyResponse defines the Msg/RegisterEncryptionKey response type +message MsgRegisterEncryptionKeyResponse { +} diff --git a/x/e2ee/README.md b/x/e2ee/README.md new file mode 100644 index 0000000000..4c5f7dd7dd --- /dev/null +++ b/x/e2ee/README.md @@ -0,0 +1,2 @@ +e2ee a module for end-to-end encrypted messaging, user can register encryption keys on chain, and receive encrypted +messages on/off chain. diff --git a/x/e2ee/autocli.go b/x/e2ee/autocli.go new file mode 100644 index 0000000000..1d4ec40126 --- /dev/null +++ b/x/e2ee/autocli.go @@ -0,0 +1,22 @@ +package e2ee + +import ( + autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" +) + +// AutoCLIOptions implements the autocli.HasAutoCLIConfig interface. +func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { + return &autocliv1.ModuleOptions{ + Query: &autocliv1.ServiceCommandDescriptor{ + Service: "e2ee.Query", + RpcCommandOptions: []*autocliv1.RpcCommandOptions{ + { + RpcMethod: "Key", + Use: "key [address]", + Short: "Query an encryption key by address", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "address"}}, + }, + }, + }, + } +} diff --git a/x/e2ee/keeper/keeper.go b/x/e2ee/keeper/keeper.go new file mode 100644 index 0000000000..de1c3acab3 --- /dev/null +++ b/x/e2ee/keeper/keeper.go @@ -0,0 +1,87 @@ +package keeper + +import ( + "context" + + "cosmossdk.io/core/address" + "cosmossdk.io/store/prefix" + storetypes "cosmossdk.io/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/crypto-org-chain/cronos/v2/x/e2ee/types" +) + +type Keeper struct { + storeKey storetypes.StoreKey + addressCodec address.Codec +} + +var ( + _ types.MsgServer = Keeper{} + _ types.QueryServer = Keeper{} +) + +func NewKeeper(storeKey storetypes.StoreKey, addressCodec address.Codec) Keeper { + return Keeper{ + storeKey: storeKey, + addressCodec: addressCodec, + } +} + +func (k Keeper) RegisterEncryptionKey( + ctx context.Context, + req *types.MsgRegisterEncryptionKey, +) (*types.MsgRegisterEncryptionKeyResponse, error) { + bz, err := k.addressCodec.StringToBytes(req.Address) + if err != nil { + return nil, err + } + sdkCtx := sdk.UnwrapSDKContext(ctx) + sdkCtx.KVStore(k.storeKey).Set(types.KeyPrefix(bz), req.Key) + return &types.MsgRegisterEncryptionKeyResponse{}, nil +} + +func (k Keeper) InitGenesis( + ctx context.Context, + state *types.GenesisState, +) error { + for _, key := range state.Keys { + if _, err := k.RegisterEncryptionKey(ctx, &types.MsgRegisterEncryptionKey{ + Address: key.Address, + Key: key.Key, + }); err != nil { + return err + } + } + return nil +} + +func (k Keeper) ExportGenesis(ctx context.Context) (*types.GenesisState, error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + iter := prefix.NewStore(sdkCtx.KVStore(k.storeKey), types.KeyPrefixEncryptionKey).Iterator(nil, nil) + defer iter.Close() + + var keys []types.EncryptionKeyEntry + for ; iter.Valid(); iter.Next() { + address, err := k.addressCodec.BytesToString(iter.Key()) + if err != nil { + return nil, err + } + key := iter.Value() + keys = append(keys, types.EncryptionKeyEntry{ + Address: address, + Key: key, + }) + } + return &types.GenesisState{Keys: keys}, nil +} + +func (k Keeper) Key(ctx context.Context, req *types.KeyRequest) (*types.KeyResponse, error) { + bz, err := k.addressCodec.StringToBytes(req.Address) + if err != nil { + return nil, err + } + sdkCtx := sdk.UnwrapSDKContext(ctx) + value := sdkCtx.KVStore(k.storeKey).Get(types.KeyPrefix(bz)) + return &types.KeyResponse{Key: value}, nil +} diff --git a/x/e2ee/module.go b/x/e2ee/module.go new file mode 100644 index 0000000000..8fea66c4a3 --- /dev/null +++ b/x/e2ee/module.go @@ -0,0 +1,135 @@ +package e2ee + +import ( + "encoding/json" + "fmt" + + abci "github.com/cometbft/cometbft/abci/types" + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + + "github.com/crypto-org-chain/cronos/v2/x/e2ee/keeper" + "github.com/crypto-org-chain/cronos/v2/x/e2ee/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} + _ module.HasGenesisBasics = AppModuleBasic{} + // this line is used by starport scaffolding # ibc/module/interface +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface for the capability module. +type AppModuleBasic struct{} + +func NewAppModuleBasic() AppModuleBasic { + return AppModuleBasic{} +} + +// AddModuleInitFlags implements servertypes.ModuleInitFlags interface. +func AddModuleInitFlags(startCmd *cobra.Command) { +} + +// Name returns the capability module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) { +} + +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +} + +// RegisterInterfaces registers the module's interface types +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { +} + +// DefaultGenesis returns the capability module's default genesis state. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis performs genesis state validation for the capability module. +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + var genState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + return genState.Validate() +} + +// RegisterRESTRoutes registers the capability module's REST service handlers. +func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface for the capability module. +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper +} + +func NewAppModule(keeper keeper.Keeper) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(), + keeper: keeper, + } +} + +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) + types.RegisterMsgServer(cfg.MsgServer(), am.keeper) +} + +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { + var genState types.GenesisState + // Initialize global index to index in genesis state + cdc.MustUnmarshalJSON(gs, &genState) + if err := am.keeper.InitGenesis(ctx, &genState); err != nil { + panic(err) + } + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the capability module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState, err := am.keeper.ExportGenesis(ctx) + if err != nil { + panic(err) + } + return cdc.MustMarshalJSON(genState) +} + +// ConsensusVersion implements AppModule/ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// Name returns the capability module's name. +func (am AppModule) Name() string { + return am.AppModuleBasic.Name() +} + +// IsAppModule implements the appmodule.AppModule interface. +func (am AppModule) IsAppModule() {} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} diff --git a/x/e2ee/types/genesis.go b/x/e2ee/types/genesis.go new file mode 100644 index 0000000000..5c5ec3cc2e --- /dev/null +++ b/x/e2ee/types/genesis.go @@ -0,0 +1,12 @@ +package types + +// DefaultGenesis returns the default Capability genesis state +func DefaultGenesis() *GenesisState { + return &GenesisState{} +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + return nil +} diff --git a/x/e2ee/types/genesis.pb.go b/x/e2ee/types/genesis.pb.go new file mode 100644 index 0000000000..28bd2085ee --- /dev/null +++ b/x/e2ee/types/genesis.pb.go @@ -0,0 +1,557 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: e2ee/genesis.proto + +package types + +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 + +// EncryptionKeyEntry is a type that contains the owner and the public key. +type EncryptionKeyEntry struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + Key []byte `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` +} + +func (m *EncryptionKeyEntry) Reset() { *m = EncryptionKeyEntry{} } +func (m *EncryptionKeyEntry) String() string { return proto.CompactTextString(m) } +func (*EncryptionKeyEntry) ProtoMessage() {} +func (*EncryptionKeyEntry) Descriptor() ([]byte, []int) { + return fileDescriptor_e81aee24edfec633, []int{0} +} +func (m *EncryptionKeyEntry) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EncryptionKeyEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EncryptionKeyEntry.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 *EncryptionKeyEntry) XXX_Merge(src proto.Message) { + xxx_messageInfo_EncryptionKeyEntry.Merge(m, src) +} +func (m *EncryptionKeyEntry) XXX_Size() int { + return m.Size() +} +func (m *EncryptionKeyEntry) XXX_DiscardUnknown() { + xxx_messageInfo_EncryptionKeyEntry.DiscardUnknown(m) +} + +var xxx_messageInfo_EncryptionKeyEntry proto.InternalMessageInfo + +func (m *EncryptionKeyEntry) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *EncryptionKeyEntry) GetKey() []byte { + if m != nil { + return m.Key + } + return nil +} + +// GenesisState defines the e2ee module's genesis state. +type GenesisState struct { + // params defines all the paramaters of the module. + Keys []EncryptionKeyEntry `protobuf:"bytes,1,rep,name=keys,proto3" json:"keys"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_e81aee24edfec633, []int{1} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.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 *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetKeys() []EncryptionKeyEntry { + if m != nil { + return m.Keys + } + return nil +} + +func init() { + proto.RegisterType((*EncryptionKeyEntry)(nil), "e2ee.EncryptionKeyEntry") + proto.RegisterType((*GenesisState)(nil), "e2ee.GenesisState") +} + +func init() { proto.RegisterFile("e2ee/genesis.proto", fileDescriptor_e81aee24edfec633) } + +var fileDescriptor_e81aee24edfec633 = []byte{ + // 239 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4a, 0x35, 0x4a, 0x4d, + 0xd5, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, + 0x01, 0x89, 0x49, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x05, 0xf4, 0x41, 0x2c, 0x88, 0x9c, 0x92, + 0x03, 0x97, 0x90, 0x6b, 0x5e, 0x72, 0x51, 0x65, 0x41, 0x49, 0x66, 0x7e, 0x9e, 0x77, 0x6a, 0xa5, + 0x6b, 0x5e, 0x49, 0x51, 0xa5, 0x90, 0x04, 0x17, 0x7b, 0x62, 0x4a, 0x4a, 0x51, 0x6a, 0x71, 0xb1, + 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x67, 0x10, 0x8c, 0x2b, 0x24, 0xc0, 0xc5, 0x9c, 0x9d, 0x5a, 0x29, + 0xc1, 0xa4, 0xc0, 0xa8, 0xc1, 0x13, 0x04, 0x62, 0x2a, 0x39, 0x71, 0xf1, 0xb8, 0x43, 0xac, 0x0b, + 0x2e, 0x49, 0x2c, 0x49, 0x15, 0x32, 0xe2, 0x62, 0xc9, 0x4e, 0xad, 0x04, 0x69, 0x64, 0xd6, 0xe0, + 0x36, 0x92, 0xd0, 0x03, 0x59, 0xae, 0x87, 0x69, 0x87, 0x13, 0xcb, 0x89, 0x7b, 0xf2, 0x0c, 0x41, + 0x60, 0xb5, 0x4e, 0x3e, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, + 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0x65, 0x94, + 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0x36, 0x22, 0x5f, 0x37, 0xbf, + 0x28, 0x5d, 0x37, 0x39, 0x23, 0x31, 0x33, 0x4f, 0x3f, 0xb9, 0x28, 0x3f, 0x2f, 0xbf, 0x58, 0xbf, + 0xcc, 0x48, 0xbf, 0x42, 0x1f, 0xec, 0xef, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0xd7, + 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x1b, 0xe5, 0x9f, 0x8e, 0x0c, 0x01, 0x00, 0x00, +} + +func (m *EncryptionKeyEntry) 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 *EncryptionKeyEntry) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EncryptionKeyEntry) 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 = encodeVarintGenesis(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *GenesisState) 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 *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Keys) > 0 { + for iNdEx := len(m.Keys) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Keys[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *EncryptionKeyEntry) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = len(m.Key) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + return n +} + +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Keys) > 0 { + for _, e := range m.Keys { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *EncryptionKeyEntry) 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 ErrIntOverflowGenesis + } + 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: EncryptionKeyEntry: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EncryptionKeyEntry: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + 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 := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GenesisState) 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 ErrIntOverflowGenesis + } + 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: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Keys", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Keys = append(m.Keys, EncryptionKeyEntry{}) + if err := m.Keys[len(m.Keys)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(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, ErrIntOverflowGenesis + } + 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, ErrIntOverflowGenesis + } + 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, ErrIntOverflowGenesis + } + 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, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/e2ee/types/keys.go b/x/e2ee/types/keys.go new file mode 100644 index 0000000000..e3256462df --- /dev/null +++ b/x/e2ee/types/keys.go @@ -0,0 +1,29 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const ( + // ModuleName defines the module name + ModuleName = "e2ee" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // RouterKey is the message route for slashing + RouterKey = ModuleName +) + +const ( + prefixEncryptionKey = iota + 1 +) + +var KeyPrefixEncryptionKey = []byte{prefixEncryptionKey} + +func KeyPrefix(addr sdk.AccAddress) []byte { + key := make([]byte, 1+len(addr)) + key[0] = prefixEncryptionKey + copy(key[1:], addr) + return key +} diff --git a/x/e2ee/types/query.pb.go b/x/e2ee/types/query.pb.go new file mode 100644 index 0000000000..b03eaf7284 --- /dev/null +++ b/x/e2ee/types/query.pb.go @@ -0,0 +1,585 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: e2ee/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + 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 + +// KeyRequest is the request type for the Query/Key RPC method. +type KeyRequest struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *KeyRequest) Reset() { *m = KeyRequest{} } +func (m *KeyRequest) String() string { return proto.CompactTextString(m) } +func (*KeyRequest) ProtoMessage() {} +func (*KeyRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_1e8b28e605d00558, []int{0} +} +func (m *KeyRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *KeyRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_KeyRequest.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 *KeyRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_KeyRequest.Merge(m, src) +} +func (m *KeyRequest) XXX_Size() int { + return m.Size() +} +func (m *KeyRequest) XXX_DiscardUnknown() { + xxx_messageInfo_KeyRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_KeyRequest proto.InternalMessageInfo + +func (m *KeyRequest) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +// KeyResponse is the response type for the Query/Key RPC method. +type KeyResponse struct { + Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (m *KeyResponse) Reset() { *m = KeyResponse{} } +func (m *KeyResponse) String() string { return proto.CompactTextString(m) } +func (*KeyResponse) ProtoMessage() {} +func (*KeyResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1e8b28e605d00558, []int{1} +} +func (m *KeyResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *KeyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_KeyResponse.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 *KeyResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_KeyResponse.Merge(m, src) +} +func (m *KeyResponse) XXX_Size() int { + return m.Size() +} +func (m *KeyResponse) XXX_DiscardUnknown() { + xxx_messageInfo_KeyResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_KeyResponse proto.InternalMessageInfo + +func (m *KeyResponse) GetKey() []byte { + if m != nil { + return m.Key + } + return nil +} + +func init() { + proto.RegisterType((*KeyRequest)(nil), "e2ee.KeyRequest") + proto.RegisterType((*KeyResponse)(nil), "e2ee.KeyResponse") +} + +func init() { proto.RegisterFile("e2ee/query.proto", fileDescriptor_1e8b28e605d00558) } + +var fileDescriptor_1e8b28e605d00558 = []byte{ + // 273 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x4f, 0x3d, 0x4b, 0xc4, 0x40, + 0x14, 0xbc, 0x78, 0x7e, 0xe0, 0x6a, 0x11, 0x17, 0x91, 0x10, 0x64, 0x95, 0x14, 0x62, 0x73, 0x79, + 0x18, 0xff, 0x81, 0xa5, 0x67, 0x63, 0xec, 0xec, 0x72, 0xb9, 0xc7, 0x5e, 0x38, 0xdd, 0x97, 0xdb, + 0xdd, 0x1c, 0x2e, 0x62, 0xe3, 0x2f, 0x10, 0xfc, 0x53, 0x96, 0x07, 0x36, 0x96, 0x92, 0xf8, 0x43, + 0x24, 0x89, 0xa2, 0xdd, 0xbc, 0x99, 0x61, 0xde, 0x0c, 0xf3, 0x31, 0x41, 0x84, 0x45, 0x85, 0xda, + 0xc5, 0xa5, 0x26, 0x4b, 0x7c, 0xbd, 0x65, 0xc2, 0x7d, 0x49, 0x92, 0x3a, 0x02, 0x5a, 0xd4, 0x6b, + 0xe1, 0xa1, 0x24, 0x92, 0x77, 0x08, 0x59, 0x59, 0x40, 0xa6, 0x14, 0xd9, 0xcc, 0x16, 0xa4, 0x4c, + 0xaf, 0x46, 0x27, 0x8c, 0x8d, 0xd1, 0xa5, 0xb8, 0xa8, 0xd0, 0x58, 0x1e, 0xb0, 0xad, 0x6c, 0x3a, + 0xd5, 0x68, 0x4c, 0xe0, 0x1d, 0x7b, 0xa7, 0xdb, 0xe9, 0xef, 0x19, 0x1d, 0xb1, 0x9d, 0xce, 0x67, + 0x4a, 0x52, 0x06, 0xb9, 0xcf, 0x86, 0x73, 0x74, 0x9d, 0x69, 0x37, 0x6d, 0x61, 0x72, 0xc3, 0x36, + 0xae, 0xdb, 0x46, 0xfc, 0x92, 0x0d, 0xc7, 0xe8, 0xb8, 0x1f, 0xb7, 0x9d, 0xe2, 0xbf, 0xf0, 0x70, + 0xef, 0x1f, 0xd3, 0xc7, 0x44, 0xe2, 0xf9, 0xfd, 0xeb, 0x75, 0x2d, 0xe0, 0x07, 0xd0, 0x4d, 0x5a, + 0x9e, 0xc1, 0x1c, 0x1d, 0x3c, 0xfe, 0x3c, 0x7d, 0xba, 0xb8, 0x7a, 0xab, 0x85, 0xb7, 0xaa, 0x85, + 0xf7, 0x59, 0x0b, 0xef, 0xa5, 0x11, 0x83, 0x55, 0x23, 0x06, 0x1f, 0x8d, 0x18, 0xdc, 0x26, 0xb2, + 0xb0, 0xb3, 0x6a, 0x12, 0xe7, 0x74, 0x0f, 0xb9, 0x76, 0xa5, 0xa5, 0x11, 0x69, 0x39, 0xca, 0x67, + 0x59, 0xa1, 0x20, 0xd7, 0xa4, 0xc8, 0xc0, 0x32, 0x81, 0x87, 0x3e, 0xd8, 0xba, 0x12, 0xcd, 0x64, + 0xb3, 0x9b, 0x7c, 0xfe, 0x1d, 0x00, 0x00, 0xff, 0xff, 0xdf, 0x82, 0xd7, 0xdb, 0x40, 0x01, 0x00, + 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Key queries the encryption key of a given address + Key(ctx context.Context, in *KeyRequest, opts ...grpc.CallOption) (*KeyResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Key(ctx context.Context, in *KeyRequest, opts ...grpc.CallOption) (*KeyResponse, error) { + out := new(KeyResponse) + err := c.cc.Invoke(ctx, "/e2ee.Query/Key", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Key queries the encryption key of a given address + Key(context.Context, *KeyRequest) (*KeyResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Key(ctx context.Context, req *KeyRequest) (*KeyResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Key not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Key_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(KeyRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Key(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/e2ee.Query/Key", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Key(ctx, req.(*KeyRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "e2ee.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Key", + Handler: _Query_Key_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "e2ee/query.proto", +} + +func (m *KeyRequest) 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 *KeyRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *KeyRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *KeyResponse) 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 *KeyResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *KeyResponse) 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 = encodeVarintQuery(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *KeyRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *KeyResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *KeyRequest) 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 ErrIntOverflowQuery + } + 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: KeyRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: KeyRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *KeyResponse) 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 ErrIntOverflowQuery + } + 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: KeyResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: KeyResponse: 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 ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + 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 := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(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, ErrIntOverflowQuery + } + 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, ErrIntOverflowQuery + } + 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, ErrIntOverflowQuery + } + 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, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/e2ee/types/query.pb.gw.go b/x/e2ee/types/query.pb.gw.go new file mode 100644 index 0000000000..23fb826796 --- /dev/null +++ b/x/e2ee/types/query.pb.gw.go @@ -0,0 +1,189 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: e2ee/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_Key_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq KeyRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + msg, err := client.Key(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Key_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq KeyRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + msg, err := server.Key(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_Key_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Key_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Key_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Key_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Key_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Key_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Key_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"e2ee", "v1", "key", "address"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Key_0 = runtime.ForwardResponseMessage +) diff --git a/x/e2ee/types/tx.pb.go b/x/e2ee/types/tx.pb.go new file mode 100644 index 0000000000..0b596d6c77 --- /dev/null +++ b/x/e2ee/types/tx.pb.go @@ -0,0 +1,585 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: e2ee/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + 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 + +// MsgRegisterEncryptionKey defines the Msg/RegisterEncryptionKey request type +type MsgRegisterEncryptionKey struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + Key []byte `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` +} + +func (m *MsgRegisterEncryptionKey) Reset() { *m = MsgRegisterEncryptionKey{} } +func (m *MsgRegisterEncryptionKey) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterEncryptionKey) ProtoMessage() {} +func (*MsgRegisterEncryptionKey) Descriptor() ([]byte, []int) { + return fileDescriptor_85e46bdbb1c358a8, []int{0} +} +func (m *MsgRegisterEncryptionKey) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterEncryptionKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterEncryptionKey.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 *MsgRegisterEncryptionKey) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterEncryptionKey.Merge(m, src) +} +func (m *MsgRegisterEncryptionKey) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterEncryptionKey) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterEncryptionKey.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterEncryptionKey proto.InternalMessageInfo + +func (m *MsgRegisterEncryptionKey) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *MsgRegisterEncryptionKey) GetKey() []byte { + if m != nil { + return m.Key + } + return nil +} + +// MsgRegisterEncryptionKeyResponse defines the Msg/RegisterEncryptionKey response type +type MsgRegisterEncryptionKeyResponse struct { +} + +func (m *MsgRegisterEncryptionKeyResponse) Reset() { *m = MsgRegisterEncryptionKeyResponse{} } +func (m *MsgRegisterEncryptionKeyResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterEncryptionKeyResponse) ProtoMessage() {} +func (*MsgRegisterEncryptionKeyResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_85e46bdbb1c358a8, []int{1} +} +func (m *MsgRegisterEncryptionKeyResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterEncryptionKeyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterEncryptionKeyResponse.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 *MsgRegisterEncryptionKeyResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterEncryptionKeyResponse.Merge(m, src) +} +func (m *MsgRegisterEncryptionKeyResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterEncryptionKeyResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterEncryptionKeyResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterEncryptionKeyResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgRegisterEncryptionKey)(nil), "e2ee.MsgRegisterEncryptionKey") + proto.RegisterType((*MsgRegisterEncryptionKeyResponse)(nil), "e2ee.MsgRegisterEncryptionKeyResponse") +} + +func init() { proto.RegisterFile("e2ee/tx.proto", fileDescriptor_85e46bdbb1c358a8) } + +var fileDescriptor_85e46bdbb1c358a8 = []byte{ + // 273 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4d, 0x35, 0x4a, 0x4d, + 0xd5, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x01, 0x71, 0xa5, 0xc4, 0x93, + 0xf3, 0x8b, 0x73, 0xf3, 0x8b, 0xf5, 0x73, 0x8b, 0xd3, 0xf5, 0xcb, 0x0c, 0x41, 0x14, 0x44, 0x5a, + 0x4a, 0x24, 0x3d, 0x3f, 0x3d, 0x1f, 0xcc, 0xd4, 0x07, 0xb1, 0x20, 0xa2, 0x4a, 0x21, 0x5c, 0x12, + 0xbe, 0xc5, 0xe9, 0x41, 0xa9, 0xe9, 0x99, 0xc5, 0x25, 0xa9, 0x45, 0xae, 0x79, 0xc9, 0x45, 0x95, + 0x05, 0x25, 0x99, 0xf9, 0x79, 0xde, 0xa9, 0x95, 0x42, 0x12, 0x5c, 0xec, 0x89, 0x29, 0x29, 0x45, + 0xa9, 0xc5, 0xc5, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x41, 0x30, 0xae, 0x90, 0x00, 0x17, 0x73, + 0x76, 0x6a, 0xa5, 0x04, 0x93, 0x02, 0xa3, 0x06, 0x4f, 0x10, 0x88, 0x69, 0xc5, 0xd3, 0xf4, 0x7c, + 0x83, 0x16, 0x4c, 0x5e, 0x49, 0x89, 0x4b, 0x01, 0x97, 0xa9, 0x41, 0xa9, 0xc5, 0x05, 0xf9, 0x79, + 0xc5, 0xa9, 0x46, 0xb9, 0x5c, 0xcc, 0xbe, 0xc5, 0xe9, 0x42, 0xf1, 0x5c, 0xa2, 0xd8, 0x6d, 0x97, + 0xd3, 0x03, 0xf9, 0x47, 0x0f, 0x97, 0x39, 0x52, 0x6a, 0xf8, 0xe5, 0x61, 0xf6, 0x48, 0xb1, 0x36, + 0x3c, 0xdf, 0xa0, 0xc5, 0xe8, 0xe4, 0x73, 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, 0x46, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0x60, 0x03, 0xf2, + 0x75, 0xf3, 0x8b, 0xd2, 0x75, 0x93, 0x33, 0x12, 0x33, 0xf3, 0xf4, 0x93, 0x8b, 0xf2, 0xf3, 0xf2, + 0x8b, 0xf5, 0xcb, 0x8c, 0xf4, 0x2b, 0xf4, 0x21, 0xc1, 0x5d, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, + 0x0e, 0x3d, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x3d, 0x69, 0x77, 0xe5, 0x83, 0x01, 0x00, + 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + // RegisterEncryptionKey registers a new encryption key to a specific account + RegisterEncryptionKey(ctx context.Context, in *MsgRegisterEncryptionKey, opts ...grpc.CallOption) (*MsgRegisterEncryptionKeyResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) RegisterEncryptionKey(ctx context.Context, in *MsgRegisterEncryptionKey, opts ...grpc.CallOption) (*MsgRegisterEncryptionKeyResponse, error) { + out := new(MsgRegisterEncryptionKeyResponse) + err := c.cc.Invoke(ctx, "/e2ee.Msg/RegisterEncryptionKey", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // RegisterEncryptionKey registers a new encryption key to a specific account + RegisterEncryptionKey(context.Context, *MsgRegisterEncryptionKey) (*MsgRegisterEncryptionKeyResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) RegisterEncryptionKey(ctx context.Context, req *MsgRegisterEncryptionKey) (*MsgRegisterEncryptionKeyResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RegisterEncryptionKey not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_RegisterEncryptionKey_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRegisterEncryptionKey) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RegisterEncryptionKey(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/e2ee.Msg/RegisterEncryptionKey", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RegisterEncryptionKey(ctx, req.(*MsgRegisterEncryptionKey)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "e2ee.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "RegisterEncryptionKey", + Handler: _Msg_RegisterEncryptionKey_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "e2ee/tx.proto", +} + +func (m *MsgRegisterEncryptionKey) 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 *MsgRegisterEncryptionKey) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegisterEncryptionKey) 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 = encodeVarintTx(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRegisterEncryptionKeyResponse) 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 *MsgRegisterEncryptionKeyResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegisterEncryptionKeyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgRegisterEncryptionKey) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Key) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgRegisterEncryptionKeyResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgRegisterEncryptionKey) 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 ErrIntOverflowTx + } + 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: MsgRegisterEncryptionKey: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterEncryptionKey: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + 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 := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgRegisterEncryptionKeyResponse) 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 ErrIntOverflowTx + } + 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: MsgRegisterEncryptionKeyResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterEncryptionKeyResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(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, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) From 6ad0d392e6f3e041861a5973d3e18422c70fcd58 Mon Sep 17 00:00:00 2001 From: HuangYi Date: Fri, 26 Apr 2024 14:51:31 +0800 Subject: [PATCH 2/8] fix proto lint --- proto/e2ee/query.proto | 1 - proto/e2ee/tx.proto | 1 - 2 files changed, 2 deletions(-) diff --git a/proto/e2ee/query.proto b/proto/e2ee/query.proto index 6c5c7a6b84..cccb307a10 100644 --- a/proto/e2ee/query.proto +++ b/proto/e2ee/query.proto @@ -1,7 +1,6 @@ syntax = "proto3"; package e2ee; -import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; option go_package = "github.com/crypto-org-chain/cronos/v2/x/e2ee/types"; diff --git a/proto/e2ee/tx.proto b/proto/e2ee/tx.proto index 93a6d0e51a..611e373472 100644 --- a/proto/e2ee/tx.proto +++ b/proto/e2ee/tx.proto @@ -2,7 +2,6 @@ syntax = "proto3"; package e2ee; import "cosmos/msg/v1/msg.proto"; -import "gogoproto/gogo.proto"; option go_package = "github.com/crypto-org-chain/cronos/v2/x/e2ee/types"; From baff86e2d89ae9ef6d23fed587853c175b7e1b1e Mon Sep 17 00:00:00 2001 From: HuangYi Date: Fri, 26 Apr 2024 14:52:17 +0800 Subject: [PATCH 3/8] fix test --- app/app.go | 1 + 1 file changed, 1 insertion(+) diff --git a/app/app.go b/app/app.go index be1ab44896..ec746a7509 100644 --- a/app/app.go +++ b/app/app.go @@ -876,6 +876,7 @@ func New( consensusparamtypes.ModuleName, // NOTE: crisis module must go at the end to check for invariants on each module crisistypes.ModuleName, + e2ee.ModuleName, } app.ModuleManager.SetOrderPreBlockers( From 09d4d6a0c75495971c0feab4a789f1df661b3ce4 Mon Sep 17 00:00:00 2001 From: HuangYi Date: Fri, 26 Apr 2024 14:56:00 +0800 Subject: [PATCH 4/8] register codec --- x/e2ee/module.go | 9 ++++++--- x/e2ee/types/codec.go | 20 ++++++++++++++++++++ x/e2ee/types/query.pb.go | 38 ++++++++++++++++++-------------------- x/e2ee/types/tx.pb.go | 32 +++++++++++++++----------------- 4 files changed, 59 insertions(+), 40 deletions(-) create mode 100644 x/e2ee/types/codec.go diff --git a/x/e2ee/module.go b/x/e2ee/module.go index 8fea66c4a3..e2e33ccb42 100644 --- a/x/e2ee/module.go +++ b/x/e2ee/module.go @@ -1,6 +1,7 @@ package e2ee import ( + "context" "encoding/json" "fmt" @@ -46,14 +47,13 @@ func (AppModuleBasic) Name() string { return types.ModuleName } -func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) { -} - func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(cdc) } // RegisterInterfaces registers the module's interface types func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) } // DefaultGenesis returns the capability module's default genesis state. @@ -76,6 +76,9 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } } // ---------------------------------------------------------------------------- diff --git a/x/e2ee/types/codec.go b/x/e2ee/types/codec.go new file mode 100644 index 0000000000..e0d341911d --- /dev/null +++ b/x/e2ee/types/codec.go @@ -0,0 +1,20 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +// RegisterLegacyAminoCodec registers the necessary x/bank interfaces and concrete types +// on the provided LegacyAmino codec. These types are used for Amino JSON serialization. +func RegisterLegacyAminoCodec(_ *codec.LegacyAmino) {} + +func RegisterInterfaces(registry types.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgRegisterEncryptionKey{}, + ) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} diff --git a/x/e2ee/types/query.pb.go b/x/e2ee/types/query.pb.go index b03eaf7284..0505dcde42 100644 --- a/x/e2ee/types/query.pb.go +++ b/x/e2ee/types/query.pb.go @@ -6,7 +6,6 @@ package types import ( context "context" fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" _ "google.golang.org/genproto/googleapis/api/annotations" @@ -127,25 +126,24 @@ func init() { func init() { proto.RegisterFile("e2ee/query.proto", fileDescriptor_1e8b28e605d00558) } var fileDescriptor_1e8b28e605d00558 = []byte{ - // 273 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x4f, 0x3d, 0x4b, 0xc4, 0x40, - 0x14, 0xbc, 0x78, 0x7e, 0xe0, 0x6a, 0x11, 0x17, 0x91, 0x10, 0x64, 0x95, 0x14, 0x62, 0x73, 0x79, - 0x18, 0xff, 0x81, 0xa5, 0x67, 0x63, 0xec, 0xec, 0x72, 0xb9, 0xc7, 0x5e, 0x38, 0xdd, 0x97, 0xdb, - 0xdd, 0x1c, 0x2e, 0x62, 0xe3, 0x2f, 0x10, 0xfc, 0x53, 0x96, 0x07, 0x36, 0x96, 0x92, 0xf8, 0x43, - 0x24, 0x89, 0xa2, 0xdd, 0xbc, 0x99, 0x61, 0xde, 0x0c, 0xf3, 0x31, 0x41, 0x84, 0x45, 0x85, 0xda, - 0xc5, 0xa5, 0x26, 0x4b, 0x7c, 0xbd, 0x65, 0xc2, 0x7d, 0x49, 0x92, 0x3a, 0x02, 0x5a, 0xd4, 0x6b, - 0xe1, 0xa1, 0x24, 0x92, 0x77, 0x08, 0x59, 0x59, 0x40, 0xa6, 0x14, 0xd9, 0xcc, 0x16, 0xa4, 0x4c, - 0xaf, 0x46, 0x27, 0x8c, 0x8d, 0xd1, 0xa5, 0xb8, 0xa8, 0xd0, 0x58, 0x1e, 0xb0, 0xad, 0x6c, 0x3a, - 0xd5, 0x68, 0x4c, 0xe0, 0x1d, 0x7b, 0xa7, 0xdb, 0xe9, 0xef, 0x19, 0x1d, 0xb1, 0x9d, 0xce, 0x67, - 0x4a, 0x52, 0x06, 0xb9, 0xcf, 0x86, 0x73, 0x74, 0x9d, 0x69, 0x37, 0x6d, 0x61, 0x72, 0xc3, 0x36, - 0xae, 0xdb, 0x46, 0xfc, 0x92, 0x0d, 0xc7, 0xe8, 0xb8, 0x1f, 0xb7, 0x9d, 0xe2, 0xbf, 0xf0, 0x70, - 0xef, 0x1f, 0xd3, 0xc7, 0x44, 0xe2, 0xf9, 0xfd, 0xeb, 0x75, 0x2d, 0xe0, 0x07, 0xd0, 0x4d, 0x5a, - 0x9e, 0xc1, 0x1c, 0x1d, 0x3c, 0xfe, 0x3c, 0x7d, 0xba, 0xb8, 0x7a, 0xab, 0x85, 0xb7, 0xaa, 0x85, - 0xf7, 0x59, 0x0b, 0xef, 0xa5, 0x11, 0x83, 0x55, 0x23, 0x06, 0x1f, 0x8d, 0x18, 0xdc, 0x26, 0xb2, - 0xb0, 0xb3, 0x6a, 0x12, 0xe7, 0x74, 0x0f, 0xb9, 0x76, 0xa5, 0xa5, 0x11, 0x69, 0x39, 0xca, 0x67, - 0x59, 0xa1, 0x20, 0xd7, 0xa4, 0xc8, 0xc0, 0x32, 0x81, 0x87, 0x3e, 0xd8, 0xba, 0x12, 0xcd, 0x64, - 0xb3, 0x9b, 0x7c, 0xfe, 0x1d, 0x00, 0x00, 0xff, 0xff, 0xdf, 0x82, 0xd7, 0xdb, 0x40, 0x01, 0x00, - 0x00, + // 264 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x8f, 0xbf, 0x4a, 0xc4, 0x40, + 0x10, 0xc6, 0x13, 0xcf, 0x3f, 0xb8, 0x5a, 0xc4, 0x2d, 0x24, 0x1c, 0xb2, 0x4a, 0x0a, 0xb1, 0xb9, + 0x0c, 0xc6, 0x37, 0xb0, 0xf4, 0x6c, 0x8c, 0x9d, 0x5d, 0x2e, 0x37, 0xe4, 0xc2, 0xe9, 0xce, 0xde, + 0xee, 0xe6, 0x70, 0x11, 0x1b, 0x9f, 0x40, 0xf0, 0xa5, 0x2c, 0x0f, 0x6c, 0x2c, 0x25, 0xf1, 0x41, + 0x24, 0x89, 0xe2, 0x75, 0x33, 0x1f, 0x1f, 0xbf, 0xdf, 0x0c, 0x0b, 0x30, 0x41, 0x84, 0x45, 0x85, + 0xda, 0xc5, 0x4a, 0x93, 0x25, 0xbe, 0xd9, 0x26, 0xc3, 0xa3, 0x82, 0xa8, 0xb8, 0x47, 0xc8, 0x54, + 0x09, 0x99, 0x94, 0x64, 0x33, 0x5b, 0x92, 0x34, 0x7d, 0x27, 0x3a, 0x65, 0x6c, 0x8c, 0x2e, 0xc5, + 0x45, 0x85, 0xc6, 0xf2, 0x90, 0xed, 0x64, 0xd3, 0xa9, 0x46, 0x63, 0x42, 0xff, 0xc4, 0x3f, 0xdb, + 0x4d, 0xff, 0xd6, 0xe8, 0x98, 0xed, 0x75, 0x3d, 0xa3, 0x48, 0x1a, 0xe4, 0x01, 0x1b, 0xcc, 0xd1, + 0x75, 0xa5, 0xfd, 0xb4, 0x1d, 0x93, 0x5b, 0xb6, 0x75, 0xd3, 0xba, 0xf9, 0x15, 0x1b, 0x8c, 0xd1, + 0xf1, 0x20, 0x6e, 0xed, 0xf1, 0x3f, 0x7c, 0x78, 0xb0, 0x96, 0xf4, 0x98, 0x48, 0xbc, 0x7c, 0x7c, + 0xbf, 0x6d, 0x84, 0xfc, 0x10, 0xba, 0xe3, 0x97, 0xe7, 0x30, 0x47, 0x07, 0x4f, 0xbf, 0xd2, 0xe7, + 0xcb, 0xeb, 0xf7, 0x5a, 0xf8, 0xab, 0x5a, 0xf8, 0x5f, 0xb5, 0xf0, 0x5f, 0x1b, 0xe1, 0xad, 0x1a, + 0xe1, 0x7d, 0x36, 0xc2, 0xbb, 0x4b, 0x8a, 0xd2, 0xce, 0xaa, 0x49, 0x9c, 0xd3, 0x03, 0xe4, 0xda, + 0x29, 0x4b, 0x23, 0xd2, 0xc5, 0x28, 0x9f, 0x65, 0xa5, 0x84, 0x5c, 0x93, 0x24, 0x03, 0xcb, 0x04, + 0x1e, 0x7b, 0xb0, 0x75, 0x0a, 0xcd, 0x64, 0xbb, 0x7b, 0xf9, 0xe2, 0x27, 0x00, 0x00, 0xff, 0xff, + 0x41, 0x96, 0x8b, 0x79, 0x2a, 0x01, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/e2ee/types/tx.pb.go b/x/e2ee/types/tx.pb.go index 0b596d6c77..9a7cc7d9ce 100644 --- a/x/e2ee/types/tx.pb.go +++ b/x/e2ee/types/tx.pb.go @@ -7,7 +7,6 @@ import ( context "context" fmt "fmt" _ "github.com/cosmos/cosmos-sdk/types/msgservice" - _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" grpc "google.golang.org/grpc" @@ -127,25 +126,24 @@ func init() { func init() { proto.RegisterFile("e2ee/tx.proto", fileDescriptor_85e46bdbb1c358a8) } var fileDescriptor_85e46bdbb1c358a8 = []byte{ - // 273 bytes of a gzipped FileDescriptorProto + // 260 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4d, 0x35, 0x4a, 0x4d, 0xd5, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x01, 0x71, 0xa5, 0xc4, 0x93, 0xf3, 0x8b, 0x73, 0xf3, 0x8b, 0xf5, 0x73, 0x8b, 0xd3, 0xf5, 0xcb, 0x0c, 0x41, 0x14, 0x44, 0x5a, - 0x4a, 0x24, 0x3d, 0x3f, 0x3d, 0x1f, 0xcc, 0xd4, 0x07, 0xb1, 0x20, 0xa2, 0x4a, 0x21, 0x5c, 0x12, - 0xbe, 0xc5, 0xe9, 0x41, 0xa9, 0xe9, 0x99, 0xc5, 0x25, 0xa9, 0x45, 0xae, 0x79, 0xc9, 0x45, 0x95, - 0x05, 0x25, 0x99, 0xf9, 0x79, 0xde, 0xa9, 0x95, 0x42, 0x12, 0x5c, 0xec, 0x89, 0x29, 0x29, 0x45, - 0xa9, 0xc5, 0xc5, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x41, 0x30, 0xae, 0x90, 0x00, 0x17, 0x73, - 0x76, 0x6a, 0xa5, 0x04, 0x93, 0x02, 0xa3, 0x06, 0x4f, 0x10, 0x88, 0x69, 0xc5, 0xd3, 0xf4, 0x7c, - 0x83, 0x16, 0x4c, 0x5e, 0x49, 0x89, 0x4b, 0x01, 0x97, 0xa9, 0x41, 0xa9, 0xc5, 0x05, 0xf9, 0x79, - 0xc5, 0xa9, 0x46, 0xb9, 0x5c, 0xcc, 0xbe, 0xc5, 0xe9, 0x42, 0xf1, 0x5c, 0xa2, 0xd8, 0x6d, 0x97, - 0xd3, 0x03, 0xf9, 0x47, 0x0f, 0x97, 0x39, 0x52, 0x6a, 0xf8, 0xe5, 0x61, 0xf6, 0x48, 0xb1, 0x36, - 0x3c, 0xdf, 0xa0, 0xc5, 0xe8, 0xe4, 0x73, 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, 0x46, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0x60, 0x03, 0xf2, - 0x75, 0xf3, 0x8b, 0xd2, 0x75, 0x93, 0x33, 0x12, 0x33, 0xf3, 0xf4, 0x93, 0x8b, 0xf2, 0xf3, 0xf2, - 0x8b, 0xf5, 0xcb, 0x8c, 0xf4, 0x2b, 0xf4, 0x21, 0xc1, 0x5d, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, - 0x0e, 0x3d, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x3d, 0x69, 0x77, 0xe5, 0x83, 0x01, 0x00, - 0x00, + 0x29, 0x84, 0x4b, 0xc2, 0xb7, 0x38, 0x3d, 0x28, 0x35, 0x3d, 0xb3, 0xb8, 0x24, 0xb5, 0xc8, 0x35, + 0x2f, 0xb9, 0xa8, 0xb2, 0xa0, 0x24, 0x33, 0x3f, 0xcf, 0x3b, 0xb5, 0x52, 0x48, 0x82, 0x8b, 0x3d, + 0x31, 0x25, 0xa5, 0x28, 0xb5, 0xb8, 0x58, 0x82, 0x51, 0x81, 0x51, 0x83, 0x33, 0x08, 0xc6, 0x15, + 0x12, 0xe0, 0x62, 0xce, 0x4e, 0xad, 0x94, 0x60, 0x52, 0x60, 0xd4, 0xe0, 0x09, 0x02, 0x31, 0xad, + 0x78, 0x9a, 0x9e, 0x6f, 0xd0, 0x82, 0xc9, 0x2b, 0x29, 0x71, 0x29, 0xe0, 0x32, 0x35, 0x28, 0xb5, + 0xb8, 0x20, 0x3f, 0xaf, 0x38, 0xd5, 0x28, 0x97, 0x8b, 0xd9, 0xb7, 0x38, 0x5d, 0x28, 0x9e, 0x4b, + 0x14, 0xbb, 0xed, 0x72, 0x7a, 0x20, 0x97, 0xeb, 0xe1, 0x32, 0x47, 0x4a, 0x0d, 0xbf, 0x3c, 0xcc, + 0x1e, 0x29, 0xd6, 0x86, 0xe7, 0x1b, 0xb4, 0x18, 0x9d, 0x7c, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, + 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, + 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x28, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, + 0x1f, 0x6c, 0x40, 0xbe, 0x6e, 0x7e, 0x51, 0xba, 0x6e, 0x72, 0x46, 0x62, 0x66, 0x9e, 0x7e, 0x72, + 0x51, 0x7e, 0x5e, 0x7e, 0xb1, 0x7e, 0x99, 0x91, 0x7e, 0x85, 0x3e, 0x24, 0x60, 0x2b, 0x0b, 0x52, + 0x8b, 0x93, 0xd8, 0xc0, 0xa1, 0x67, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x38, 0xff, 0xe3, 0x1c, + 0x6d, 0x01, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. From cdc24cb6c0366f37dc387c692445a7779d72f7f6 Mon Sep 17 00:00:00 2001 From: HuangYi Date: Fri, 26 Apr 2024 14:56:40 +0800 Subject: [PATCH 5/8] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ebfe614b85..67b9c59cc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * [#1377](https://github.com/crypto-org-chain/cronos/pull/1377) Upgrade sdk to 0.50, and integrate block-stm parallel tx execution. * [#1394](https://github.com/crypto-org-chain/cronos/pull/1394) Add icahost wirings but disable in parameters. +* [#1407](https://github.com/crypto-org-chain/cronos/pull/1407) Add end-to-end encryption module. ### Improvements From b00e2ca140848e5ee8816e404fa84d96b9d2047a Mon Sep 17 00:00:00 2001 From: HuangYi Date: Fri, 26 Apr 2024 14:57:26 +0800 Subject: [PATCH 6/8] fix build --- app/app.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/app.go b/app/app.go index ec746a7509..91b7687cda 100644 --- a/app/app.go +++ b/app/app.go @@ -876,7 +876,7 @@ func New( consensusparamtypes.ModuleName, // NOTE: crisis module must go at the end to check for invariants on each module crisistypes.ModuleName, - e2ee.ModuleName, + e2eetypes.ModuleName, } app.ModuleManager.SetOrderPreBlockers( From 7de8a6351c5119f8c2d1fe3936f33c508574481a Mon Sep 17 00:00:00 2001 From: yihuang Date: Fri, 26 Apr 2024 15:44:02 +0800 Subject: [PATCH 7/8] Update x/e2ee/types/keys.go Co-authored-by: mmsqe Signed-off-by: yihuang --- x/e2ee/types/keys.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/e2ee/types/keys.go b/x/e2ee/types/keys.go index e3256462df..c89cac2311 100644 --- a/x/e2ee/types/keys.go +++ b/x/e2ee/types/keys.go @@ -11,7 +11,7 @@ const ( // StoreKey defines the primary module store key StoreKey = ModuleName - // RouterKey is the message route for slashing + // RouterKey is the message route for e2ee RouterKey = ModuleName ) From 90864494d7508e39e2e1d1809e5296934ecbae7b Mon Sep 17 00:00:00 2001 From: yihuang Date: Fri, 26 Apr 2024 15:44:16 +0800 Subject: [PATCH 8/8] Update x/e2ee/types/codec.go Co-authored-by: mmsqe Signed-off-by: yihuang --- x/e2ee/types/codec.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/e2ee/types/codec.go b/x/e2ee/types/codec.go index e0d341911d..b24da784c4 100644 --- a/x/e2ee/types/codec.go +++ b/x/e2ee/types/codec.go @@ -7,7 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/msgservice" ) -// RegisterLegacyAminoCodec registers the necessary x/bank interfaces and concrete types +// RegisterLegacyAminoCodec registers the necessary x/e2ee interfaces and concrete types // on the provided LegacyAmino codec. These types are used for Amino JSON serialization. func RegisterLegacyAminoCodec(_ *codec.LegacyAmino) {}