func newKeySecp256k1(addrType AddrType) *Key { pub, priv := secp256k1.GenerateKeyPair() return &Key{ Id: uuid.NewRandom(), Type: KeyType{CurveTypeSecp256k1, addrType}, Address: AddressFromPub(addrType, pub), PrivateKey: priv, } }
func keyFromPrivEd25519(addrType AddrType, priv []byte) (*Key, error) { privKeyBytes := new([64]byte) copy(privKeyBytes[:32], priv) pubKeyBytes := ed25519.MakePublicKey(privKeyBytes) pubKey := account.PubKeyEd25519(*pubKeyBytes) return &Key{ Id: uuid.NewRandom(), Type: KeyType{CurveTypeEd25519, addrType}, Address: pubKey.Address(), PrivateKey: privKeyBytes[:], }, nil }
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 }