diff --git a/CHANGELOG.md b/CHANGELOG.md index b6d964a5b9..c8613f9153 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,7 +21,7 @@ ### Features -- [#1406](https://github.com/crypto-org-chain/cronos/pull/1406) Add set-encryption-key for encryption module. +* [#1406](https://github.com/crypto-org-chain/cronos/pull/1406) Add set-encryption-key for encryption module. *April 8, 2024* diff --git a/integration_tests/configs/default.jsonnet b/integration_tests/configs/default.jsonnet index 4b19a0f1b1..04dc9271bc 100644 --- a/integration_tests/configs/default.jsonnet +++ b/integration_tests/configs/default.jsonnet @@ -87,6 +87,12 @@ ibc_cro_denom: '${IBC_CRO_DENOM}', }, }, + e2ee: { + keys: [{ + address: 'crc16z0herz998946wr659lr84c8c556da55dc34hh', + key: std.base64('key'), + }], + }, gov: { params: { expedited_voting_period: '1s', diff --git a/integration_tests/cosmoscli.py b/integration_tests/cosmoscli.py index f8d83ab90f..06f459590a 100644 --- a/integration_tests/cosmoscli.py +++ b/integration_tests/cosmoscli.py @@ -1864,7 +1864,6 @@ def set_e2ee_key(self, key, **kwargs): key, "-y", home=self.data_dir, - stderr=subprocess.DEVNULL, **kwargs, ) ) diff --git a/x/e2ee/types/genesis.go b/x/e2ee/types/genesis.go index 5c5ec3cc2e..d2a392ceab 100644 --- a/x/e2ee/types/genesis.go +++ b/x/e2ee/types/genesis.go @@ -8,5 +8,10 @@ func DefaultGenesis() *GenesisState { // Validate performs basic genesis state validation returning an error upon any // failure. func (gs GenesisState) Validate() error { + for _, key := range gs.Keys { + if err := key.Validate(); err != nil { + return err + } + } return nil } diff --git a/x/e2ee/types/keys.go b/x/e2ee/types/keys.go index c89cac2311..c5744d7c7a 100644 --- a/x/e2ee/types/keys.go +++ b/x/e2ee/types/keys.go @@ -1,6 +1,8 @@ package types import ( + "errors" + sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -27,3 +29,14 @@ func KeyPrefix(addr sdk.AccAddress) []byte { copy(key[1:], addr) return key } + +// Validate checks for address and key correctness. +func (e EncryptionKeyEntry) Validate() error { + if _, err := sdk.AccAddressFromBech32(e.Address); err != nil { + return err + } + if e.Key == nil { + return errors.New("key can't be nil") + } + return nil +}