diff --git a/crypto/erc2335/erc2335_test.go b/crypto/erc2335/erc2335_test.go index 4cd28ac1..aa56f650 100644 --- a/crypto/erc2335/erc2335_test.go +++ b/crypto/erc2335/erc2335_test.go @@ -10,25 +10,19 @@ import ( ) func TestEncryptBLS(t *testing.T) { - // TODO t.Run("create bls key", func(t *testing.T) { - blsPrivKey := bls12381.GenPrivKey() blsPubKey := blsPrivKey.PubKey().Bytes() t.Run("encrypt bls key", func(t *testing.T) { - password := CreateRandomPassword() t.Logf("password: %s", password) - encryptedBlsKey, err := Encrypt(blsPrivKey, blsPubKey, password) require.NoError(t, err) t.Logf("encrypted bls key: %s", encryptedBlsKey) t.Run("decrypt bls key", func(t *testing.T) { - var keystore Erc2335KeyStore - err = json.Unmarshal(encryptedBlsKey, &keystore) require.NoError(t, err) @@ -38,19 +32,15 @@ func TestEncryptBLS(t *testing.T) { }) t.Run("decrypt bls key with wrong password", func(t *testing.T) { - var keystore Erc2335KeyStore - err = json.Unmarshal(encryptedBlsKey, &keystore) require.NoError(t, err) - _, err := Decrypt(keystore, "wrong password") require.Error(t, err) }) }) t.Run("save password and encrypt bls key", func(t *testing.T) { - password := CreateRandomPassword() t.Logf("password: %s", password) @@ -61,12 +51,10 @@ func TestEncryptBLS(t *testing.T) { require.NoError(t, err) t.Run("load password and decrypt bls key", func(t *testing.T) { - password, err := LoadPaswordFromFile("password.txt") require.NoError(t, err) var keystore Erc2335KeyStore - err = json.Unmarshal(encryptedBlsKey, &keystore) require.NoError(t, err) @@ -76,7 +64,6 @@ func TestEncryptBLS(t *testing.T) { }) t.Run("save new password into same file", func(t *testing.T) { - newPassword := CreateRandomPassword() t.Logf("new password: %s", newPassword) err = SavePasswordToFile(newPassword, "password.txt") @@ -84,12 +71,10 @@ func TestEncryptBLS(t *testing.T) { }) t.Run("failed when load different password and decrypt bls key", func(t *testing.T) { - password, err := LoadPaswordFromFile("password.txt") require.NoError(t, err) var keystore Erc2335KeyStore - err = json.Unmarshal(encryptedBlsKey, &keystore) require.NoError(t, err) diff --git a/privval/bls.go b/privval/bls.go index 71a093d3..e990db8e 100644 --- a/privval/bls.go +++ b/privval/bls.go @@ -34,20 +34,6 @@ type BlsPVKey struct { passwordPath string } -func LoadOrGenBlsPV(keyFilePath, passwordFilePath, password, delegatorAddress string) *BlsPV { - if err := IsValidFilePath(keyFilePath, passwordFilePath); err != nil { - panic(err) - } - - if cmtos.FileExists(keyFilePath) { - if !cmtos.FileExists(passwordFilePath) { - panic(fmt.Errorf("BLS password file does not exist: %s", passwordFilePath)) - } - return LoadBlsPV(keyFilePath, passwordFilePath) - } - return GenBlsPV(keyFilePath, passwordFilePath, password, delegatorAddress) -} - func NewBlsPV(privKey bls12381.PrivateKey, keyFilePath, passwordFilePath, delegatorAddress string) *BlsPV { return &BlsPV{ Key: BlsPVKey{ @@ -67,7 +53,6 @@ func GenBlsPV(keyFilePath, passwordFilePath, password, delegatorAddress string) } func LoadBlsPV(keyFilePath, passwordFilePath string) *BlsPV { - password, err := erc2335.LoadPaswordFromFile(passwordFilePath) if err != nil { cmtos.Exit(fmt.Sprintf("failed to read BLS password file: %v", err.Error())) @@ -108,7 +93,6 @@ func GetBlsPassword() string { // Save bls key using password // Check both paths of bls key and password inside function func (k *BlsPVKey) Save(password, addr string) { - // check file path is valid if err := IsValidFilePath(k.filePath, k.passwordPath); err != nil { panic(err) diff --git a/privval/bls_test.go b/privval/bls_test.go index aa8141f1..6e6c134e 100644 --- a/privval/bls_test.go +++ b/privval/bls_test.go @@ -14,7 +14,6 @@ import ( ) func TestNewBlsPV(t *testing.T) { - tempDir := t.TempDir() defer os.RemoveAll(tempDir) @@ -40,7 +39,6 @@ func TestNewBlsPV(t *testing.T) { }) t.Run("save bls key to file with delegator address", func(t *testing.T) { - pv := NewBlsPV(bls12381.GenPrivKey(), keyFilePath, passwordFilePath, "") assert.NotNil(t, pv) diff --git a/privval/file.go b/privval/file.go index cb4e4c68..dbdffdd7 100644 --- a/privval/file.go +++ b/privval/file.go @@ -3,7 +3,6 @@ package privval import ( "errors" "fmt" - "os" "path/filepath" cmtcrypto "github.com/cometbft/cometbft/crypto" @@ -115,16 +114,3 @@ func (pv *WrappedFilePV) SignMsgWithBls(msg []byte) (bls12381.Signature, error) } return bls12381.Sign(blsPrivKey, msg), nil } - -// Clean removes PVKey file and PVState file -func (pv *WrappedFilePV) Clean(paths ...string) { - for _, path := range paths { - _ = os.RemoveAll(filepath.Dir(path)) - } -} - -func (pv *WrappedFilePV) Save(password string) { - pv.Key.CometPVKey.Save() - pv.Key.BlsPVKey.Save(password, "") - pv.LastSignState.Save() -} diff --git a/test/replay/driver.go b/test/replay/driver.go index 0c31140c..3a8eccf1 100644 --- a/test/replay/driver.go +++ b/test/replay/driver.go @@ -194,10 +194,6 @@ func NewBabylonAppDriver( panic(err) } - // if err := testutilsigner.GeneratePrivSigner(chain.Nodes[0].ConfigDir); err != nil { - // panic(err) - // } - signer, err := appsigner.InitPrivSigner(chain.Nodes[0].ConfigDir) require.NoError(t, err) require.NotNil(t, signer)