crypto: Remove Ed25519 and Secp256k1 suffix on GenPrivKey

This commit is contained in:
ValarDragon
2018-07-20 10:44:21 -07:00
parent 17c0029233
commit c798702764
29 changed files with 62 additions and 62 deletions
+1 -1
View File
@@ -22,7 +22,7 @@
// pubKey := key.PubKey()
// For example:
// privKey, err := ed25519.GenPrivKeyEd25519()
// privKey, err := ed25519.GenPrivKey()
// if err != nil {
// ...
// }
+4 -4
View File
@@ -124,10 +124,10 @@ func (privKey PrivKeyEd25519) Generate(index int) PrivKeyEd25519 {
return PrivKeyEd25519(*newKey)
}
// GenPrivKeyEd25519 generates a new ed25519 private key.
// GenPrivKey generates a new ed25519 private key.
// It uses OS randomness in conjunction with the current global random seed
// in tendermint/libs/common to generate the private key.
func GenPrivKeyEd25519() PrivKeyEd25519 {
func GenPrivKey() PrivKeyEd25519 {
privKey := new([64]byte)
copy(privKey[:32], crypto.CRandBytes(32))
// ed25519.MakePublicKey(privKey) alters the last 32 bytes of privKey.
@@ -137,11 +137,11 @@ func GenPrivKeyEd25519() PrivKeyEd25519 {
return PrivKeyEd25519(*privKey)
}
// GenPrivKeyEd25519FromSecret hashes the secret with SHA2, and uses
// GenPrivKeyFromSecret hashes the secret with SHA2, and uses
// that 32 byte output to create the private key.
// NOTE: secret should be the output of a KDF like bcrypt,
// if it's derived from user input.
func GenPrivKeyEd25519FromSecret(secret []byte) PrivKeyEd25519 {
func GenPrivKeyFromSecret(secret []byte) PrivKeyEd25519 {
privKey32 := crypto.Sha256(secret) // Not Ripemd160 because we want 32 bytes.
privKey := new([64]byte)
copy(privKey[:32], privKey32)
+2 -2
View File
@@ -10,7 +10,7 @@ import (
)
func TestGeneratePrivKey(t *testing.T) {
testPriv := ed25519.GenPrivKeyEd25519()
testPriv := ed25519.GenPrivKey()
testGenerate := testPriv.Generate(1)
signBytes := []byte("something to sign")
pub := testGenerate.PubKey()
@@ -21,7 +21,7 @@ func TestGeneratePrivKey(t *testing.T) {
func TestSignAndValidateEd25519(t *testing.T) {
privKey := ed25519.GenPrivKeyEd25519()
privKey := ed25519.GenPrivKey()
pubKey := privKey.PubKey()
msg := crypto.CRandBytes(128)
+2 -2
View File
@@ -63,12 +63,12 @@ func TestKeyEncodings(t *testing.T) {
privSize, pubSize int // binary sizes
}{
{
privKey: ed25519.GenPrivKeyEd25519(),
privKey: ed25519.GenPrivKey(),
privSize: 69,
pubSize: 37,
},
{
privKey: secp256k1.GenPrivKeySecp256k1(),
privKey: secp256k1.GenPrivKey(),
privSize: 37,
pubSize: 38,
},
+2 -2
View File
@@ -91,7 +91,7 @@ func (key PrivKeySecp256k1) Generate(index int) PrivKeySecp256k1 {
}
*/
func GenPrivKeySecp256k1() PrivKeySecp256k1 {
func GenPrivKey() PrivKeySecp256k1 {
privKeyBytes := [32]byte{}
copy(privKeyBytes[:], crypto.CRandBytes(32))
priv, _ := secp256k1.PrivKeyFromBytes(secp256k1.S256(), privKeyBytes[:])
@@ -101,7 +101,7 @@ func GenPrivKeySecp256k1() PrivKeySecp256k1 {
// NOTE: secret should be the output of a KDF like bcrypt,
// if it's derived from user input.
func GenPrivKeySecp256k1FromSecret(secret []byte) PrivKeySecp256k1 {
func GenPrivKeyFromSecret(secret []byte) PrivKeySecp256k1 {
privKey32 := crypto.Sha256(secret) // Not Ripemd160 because we want 32 bytes.
priv, _ := secp256k1.PrivKeyFromBytes(secp256k1.S256(), privKey32)
privKeyBytes := [32]byte{}
+1 -1
View File
@@ -47,7 +47,7 @@ func TestPubKeySecp256k1Address(t *testing.T) {
}
func TestSignAndValidateSecp256k1(t *testing.T) {
privKey := secp256k1.GenPrivKeySecp256k1()
privKey := secp256k1.GenPrivKey()
pubKey := privKey.PubKey()
msg := crypto.CRandBytes(128)