The core protocol of WoopChain
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
woop/crypto/pki/utils_test.go

24 lines
544 B

package pki
import (
6 years ago
"encoding/binary"
"reflect"
"testing"
"time"
6 years ago
"github.com/harmony-one/bls/ffi/go/bls"
)
func TestGetAddressFromPublicKey(test *testing.T) {
t := time.Now().UnixNano()
6 years ago
priKey := [32]byte{}
binary.LittleEndian.PutUint32(priKey[:], uint32(t))
var privateKey bls.SecretKey
privateKey.SetLittleEndian(priKey[:])
addr1 := GetAddressFromPublicKey(privateKey.GetPublicKey())
addr2 := GetAddressFromPrivateKey(&privateKey)
if !reflect.DeepEqual(addr1, addr2) {
test.Error("two public address should be equal")
}
}