Skip to content

Commit

Permalink
move command to e2ee module
Browse files Browse the repository at this point in the history
move encrypt cmd to e2ee module

move decrypt cmd to e2ee

update integration test

store key as string, to make autocli better

fix integration test

Update x/e2ee/client/cli/encrypt.go

Signed-off-by: yihuang <huang@crypto.com>

fix lint
  • Loading branch information
yihuang authored and mmsqe committed Apr 29, 2024
1 parent a8631b2 commit c3e60d1
Show file tree
Hide file tree
Showing 23 changed files with 447 additions and 391 deletions.
104 changes: 0 additions & 104 deletions cmd/cronosd/cmd/decrypt.go

This file was deleted.

111 changes: 0 additions & 111 deletions cmd/cronosd/cmd/encrypt.go

This file was deleted.

52 changes: 0 additions & 52 deletions cmd/cronosd/cmd/generate.go

This file was deleted.

5 changes: 2 additions & 3 deletions cmd/cronosd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import (
"github.com/crypto-org-chain/cronos/v2/app"
"github.com/crypto-org-chain/cronos/v2/cmd/cronosd/opendb"
"github.com/crypto-org-chain/cronos/v2/x/cronos"
e2eecli "github.com/crypto-org-chain/cronos/v2/x/e2ee/client/cli"
// this line is used by starport scaffolding # stargate/root/import
)

Expand Down Expand Up @@ -189,9 +190,7 @@ func initRootCmd(
queryCommand(),
txCommand(),
ethermintclient.KeyCommands(app.DefaultNodeHome),
KeygenCommand(),
EncryptMsgCommand(),
DecryptMsgCommand(),
e2eecli.E2EECommand(),
)

// add rosetta
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
c2sp.org/CCTV/age v0.0.0-20221230231406-5ea85644bd03 h1:0e2QjhWG02SgzlUOvNYaFraf04OBsUPOLxf+K+Ae/yM=
c2sp.org/CCTV/age v0.0.0-20221230231406-5ea85644bd03/go.mod h1:FomMrUJ2Lxt5jCLmZkG3FHa72zUprnhd3v/Z18Snm4w=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
Expand Down
7 changes: 5 additions & 2 deletions gomod2nix.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ schema = 3
version = "v0.1.1"
hash = "sha256-bM9ybpaibMH7k4M6/QAXCZ3fJcADfJHxvMgp4AVUihs="
[mod."filippo.io/age"]
version = "v1.1.2-0.20240110114017-29b68c20fc24"
hash = "sha256-LZ6W2ZNQyA1s6SAY5rXOhztgF0pmCKQR7B+73V1tB4Q="
version = "v1.1.1"
hash = "sha256-LRxxJQLQkzoCNYGS/XBixVmYXoZ1mPHKvFicPGXYLcw="
[mod."filippo.io/edwards25519"]
version = "v1.1.0"
hash = "sha256-9ACANrgWZSd5HYPfDZHY8DVbPSC9LOMgy8deq3rDOoc="
Expand Down Expand Up @@ -578,6 +578,9 @@ schema = 3
[mod."github.com/tendermint/go-amino"]
version = "v0.16.0"
hash = "sha256-JW4zO/0vMzf1dXLePOqaMtiLUZgNbuIseh9GV+jQlf0="
[mod."github.com/test-go/testify"]
version = "v1.1.4"
hash = "sha256-8xygO1Rd4eTrmRe/g7zaifpNkeb6EmjNfUvTWbjDtPg="
[mod."github.com/tidwall/btree"]
version = "v0.0.0-20240406140148-2687063b042c"
hash = "sha256-8eDLGHhw4qXG6MEa7w5Q9KLwOobXr8Vn5qqyQhuipQw="
Expand Down
42 changes: 30 additions & 12 deletions integration_tests/cosmoscli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import binascii
import enum
import hashlib
import itertools
import json
import os
import re
Expand Down Expand Up @@ -1851,16 +1852,16 @@ def query_e2ee_key(self, address):
home=self.data_dir,
output="json",
)
)
)["key"]

def set_e2ee_key(self, key, **kwargs):
def register_e2ee_key(self, key, **kwargs):
kwargs.setdefault("gas_prices", DEFAULT_GAS_PRICE)
kwargs.setdefault("gas", DEFAULT_GAS)
rsp = json.loads(
self.raw(
"tx",
"e2ee",
"set-encryption-key",
"register-encryption-key",
key,
"-y",
home=self.data_dir,
Expand All @@ -1872,15 +1873,32 @@ def set_e2ee_key(self, key, **kwargs):
return rsp

def keygen(self, **kwargs):
return self.raw("keygen", home=self.data_dir, **kwargs).strip().decode()
return self.raw("e2ee", "keygen", home=self.data_dir, **kwargs).strip().decode()

def encrypt(self, input, receipts, **kwargs):
return self.raw(
"encrypt",
input,
*[val for a in [["--r", val] for val in receipts] for val in a],
**kwargs,
def encrypt(self, input, *recipients, **kwargs):
return (
self.raw(
"e2ee",
"encrypt",
input,
*itertools.chain.from_iterable(("-r", r) for r in recipients),
home=self.data_dir,
**kwargs,
)
.strip()
.decode()
)

def decrypt(self, input, **kwargs):
return self.raw("decrypt", input, home=self.data_dir, **kwargs).strip().decode()
def decrypt(self, input, identity="e2ee-identity", **kwargs):
return (
self.raw(
"e2ee",
"decrypt",
input,
home=self.data_dir,
identity=identity,
**kwargs,
)
.strip()
.decode()
)
Loading

0 comments on commit c3e60d1

Please sign in to comment.