Example #1
0
func Test0Key(t *testing.T) {
	t.Skip()
	key, _ := hex.DecodeString("1111111111111111111111111111111111111111111111111111111111111111")

	p, err := secp256k1.GeneratePubKey(key)
	addr := Sha3(p[1:])[12:]
	fmt.Printf("%x\n", p)
	fmt.Printf("%v %x\n", err, addr)
}
Example #2
0
func keyFromPrivSecp256k1(addrType AddrType, priv []byte) (*Key, error) {
	pub, err := secp256k1.GeneratePubKey(priv)
	if err != nil {
		return nil, err
	}
	return &Key{
		Id:         uuid.NewRandom(),
		Type:       KeyType{CurveTypeSecp256k1, addrType},
		Address:    AddressFromPub(addrType, pub),
		PrivateKey: priv,
	}, nil
}
Example #3
0
func pubKeySecp256k1(k *Key) ([]byte, error) {
	return secp256k1.GeneratePubKey(k.PrivateKey)
}