Search code examples
javaencryptionbouncycastleelliptic-curve

Turn an byte encoded Key back into it's original ECPublicKey in Bouncy Castle


In Java I have a ECDH public Key that I am sending as a byte array.

Once I have received the byte array how can I turn it back into a public key?

I am using Bouncy Castle but a Java solution would be just as useful.

Thanks


Solution

  • How are the raw bytes formatted for the ECDH key? Where are you getting the raw bytes?

    Generally, one uses the appropriate *Spec class to turn raw key material into a Key but the ECPublicKeySpec and DHPublicKeySpec classes don't accept a raw byte array.