Drop useless encoding (#110)

* drop asec private key encoding

* remove pubkey/relaykey/url encoding in common pkg

* fix pubkey encoding

* remove SecKey
This commit is contained in:
Louis Singer
2024-02-20 17:35:11 +01:00
committed by GitHub
parent ffcf08420f
commit 936f9c5f51
9 changed files with 27 additions and 471 deletions

View File

@@ -119,12 +119,12 @@ func getWalletPublicKey() (*secp256k1.PublicKey, error) {
return nil, fmt.Errorf("public key not found")
}
_, publicKey, err := common.DecodePubKey(publicKeyString)
publicKeyBytes, err := hex.DecodeString(publicKeyString)
if err != nil {
return nil, err
}
return publicKey, nil
return secp256k1.ParsePubKey(publicKeyBytes)
}
func getServiceProviderPublicKey() (*secp256k1.PublicKey, error) {
@@ -138,12 +138,12 @@ func getServiceProviderPublicKey() (*secp256k1.PublicKey, error) {
return nil, fmt.Errorf("ark public key not found")
}
_, pubKey, err := common.DecodePubKey(arkPubKey)
pubKeyBytes, err := hex.DecodeString(arkPubKey)
if err != nil {
return nil, err
}
return pubKey, nil
return secp256k1.ParsePubKey(pubKeyBytes)
}
func coinSelect(vtxos []vtxo, amount uint64) ([]vtxo, uint64, error) {

View File

@@ -6,7 +6,6 @@ import (
"strings"
arkv1 "github.com/ark-network/ark/api-spec/protobuf/gen/ark/v1"
"github.com/ark-network/ark/common"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/decred/dcrd/dcrec/secp256k1/v4"
"github.com/urfave/cli/v2"
@@ -108,16 +107,7 @@ func initWallet(ctx *cli.Context, key, password string) error {
privateKey = secp256k1.PrivKeyFromBytes(privKeyBytes)
}
cypher := NewAES128Cypher()
arkNetwork, _ := getNetwork()
publicKey, err := common.EncodePubKey(arkNetwork.PubKey, privateKey.PubKey())
if err != nil {
return err
}
encryptedPrivateKey, err := cypher.Encrypt(privateKey.Serialize(), []byte(password))
encryptedPrivateKey, err := NewAES128Cypher().Encrypt(privateKey.Serialize(), []byte(password))
if err != nil {
return err
}
@@ -127,7 +117,7 @@ func initWallet(ctx *cli.Context, key, password string) error {
state := map[string]string{
"encrypted_private_key": hex.EncodeToString(encryptedPrivateKey),
"password_hash": hex.EncodeToString(passwordHash),
"public_key": publicKey,
"public_key": hex.EncodeToString(privateKey.PubKey().SerializeCompressed()),
}
if err := setState(state); err != nil {