I am using the ecdsa.GenerateKey method to generate a private key pair in Go. I would like to send my private key(priva) with socket programming and can read other private key(privb) from other program.
priva, _ := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
_, err = connection.Write([]byte(priva))
buffer := make([]byte, 1024)
mLen, err := connection.Read(buffer)
if err != nil {
fmt.Println("Error reading:", err.Error())
}
privb := buffer[:mLen]
There is my code to send data and read data to/from other program, but i can't send my private key(priva) because it can't change the types. How to fixed, or is there a recommended way to send/read the data ?