Merge pull request #208 from harmony-one/crypto-unit-test
add unit test for crypto/pki/utils.gopull/211/head
commit
4ccb7ae019
@ -0,0 +1,25 @@ |
||||
package pki |
||||
|
||||
import ( |
||||
"github.com/harmony-one/harmony/crypto" |
||||
"reflect" |
||||
"testing" |
||||
"time" |
||||
) |
||||
|
||||
func TestGetPublicKeyFromPrivateKey(test *testing.T) { |
||||
suite := crypto.Ed25519Curve |
||||
t := time.Now().UnixNano() |
||||
scalar := suite.Scalar().SetInt64(t) |
||||
pubKey := GetPublicKeyFromScalar(scalar) |
||||
bytes := [32]byte{} |
||||
tmp, err := scalar.MarshalBinary() |
||||
copy(bytes[:], tmp) |
||||
if err != nil { |
||||
test.Error("unable to marshal private key to binary") |
||||
} |
||||
pubKey1 := GetPublicKeyFromPrivateKey(bytes) |
||||
if !reflect.DeepEqual(pubKey, pubKey1) { |
||||
test.Error("two public keys should be equal") |
||||
} |
||||
} |
Loading…
Reference in new issue