Skip to content

Commit

Permalink
chore: unlint lines
Browse files Browse the repository at this point in the history
  • Loading branch information
wnjoon committed Jan 10, 2025
1 parent e2c51bf commit 43431dd
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 51 deletions.
15 changes: 0 additions & 15 deletions crypto/erc2335/erc2335_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand All @@ -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)

Expand All @@ -76,20 +64,17 @@ 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")
require.NoError(t, err)
})

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)

Expand Down
16 changes: 0 additions & 16 deletions privval/bls.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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()))
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions privval/bls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
)

func TestNewBlsPV(t *testing.T) {

tempDir := t.TempDir()
defer os.RemoveAll(tempDir)

Expand All @@ -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)

Expand Down
14 changes: 0 additions & 14 deletions privval/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package privval
import (
"errors"
"fmt"
"os"
"path/filepath"

cmtcrypto "github.com/cometbft/cometbft/crypto"
Expand Down Expand Up @@ -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()
}
4 changes: 0 additions & 4 deletions test/replay/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 43431dd

Please sign in to comment.