cloudflare / circl

CIRCL: Cloudflare Interoperable Reusable Cryptographic Library
http://blog.cloudflare.com/introducing-circl
Other
1.23k stars 136 forks source link

OPRF - Export Public Key #401

Closed krissully closed 1 year ago

krissully commented 1 year ago

Is there a way to use a private key in pem format when configuring an oprf server?

bwesterb commented 1 year ago

@cjpatton

armfazh commented 1 year ago

The format of a OPRF keys are raw scalar and curve point. https://github.com/cloudflare/circl/blob/main/oprf/keys.go#L21

For example, for P256, the private key is a 32-byte number and the public key is a compressed point in 33 bytes.

Assuming your key.pem was generated as:

$ openssl ecparam -name prime256v1 -genkey -out key.pem 

You can recover the internal values with:

$ openssl ec -in key.pem  -text -noout

In Go, you can do so similarly as in ParseECPrivateKey, but instead use the UnmarshalBinary method from the OPRF package.

armfazh commented 1 year ago

Closing as answered.