adjusted for ed25519

Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
Lorenz Herzberger 2023-06-14 16:54:08 +02:00
parent dc0de3732d
commit 2e587783b6
No known key found for this signature in database
GPG Key ID: FA5EE906EB55316A
3 changed files with 5 additions and 6 deletions

View File

@ -5,14 +5,13 @@ import (
machinetypes "planetmint-go/x/machine/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// KeyPair returns a sample private / public keypair
func KeyPair() (string, string) {
secret := "Don't tell anybody"
sk := secp256k1.GenPrivKeyFromSecret([]byte(secret))
sk := ed25519.GenPrivKeyFromSecret([]byte(secret))
pk := sk.PubKey()
return hex.EncodeToString(sk.Bytes()), hex.EncodeToString(pk.Bytes())
}

View File

@ -8,7 +8,7 @@ import (
"planetmint-go/x/asset/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
sdk "github.com/cosmos/cosmos-sdk/types"
)
@ -47,7 +47,7 @@ func ValidateSignature(message string, signature string, publicKey string) bool
hash := sha256.Sum256(messageBytes)
// Create a secp256k1 public key object
pubKey := &secp256k1.PubKey{Key: publicKeyBytes}
pubKey := &ed25519.PubKey{Key: publicKeyBytes}
// Verify the signature
isValid := pubKey.VerifySignature(hash[:], signatureBytes)

View File

@ -11,7 +11,7 @@ import (
"planetmint-go/x/asset/keeper"
"planetmint-go/x/asset/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/assert"
)
@ -29,7 +29,7 @@ func TestMsgServerNotarizeAsset(t *testing.T) {
if err != nil {
assert.Equal(t, true, false)
}
privKey := &secp256k1.PrivKey{Key: skBytes}
privKey := &ed25519.PrivKey{Key: skBytes}
cidBytes, _ := hex.DecodeString(cid)
hash := sha256.Sum256(cidBytes)