Skip to content
Snippets Groups Projects
Commit 051a023d authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Merge remote-tracking branch 'origin/master' into more_pem

parents 657d9ba2 bc3f946a
No related branches found
No related tags found
1 merge request!3Split ToPEMFile and FromPEMFile
......@@ -5,6 +5,7 @@ package ctidh
import "C"
import (
"bytes"
"crypto/hmac"
"encoding/pem"
"fmt"
"io/ioutil"
......@@ -156,6 +157,11 @@ func (p *PublicKey) FromBytes(data []byte) error {
return nil
}
// Equal is a constant time comparison of the two public keys.
func (p *PublicKey) Equal(publicKey *PublicKey) bool {
return hmac.Equal(p.Bytes(), publicKey.Bytes())
}
// Blind performs a blinding operation
// and mutates the public key.
// See notes below about blinding operation with CTIDH.
......@@ -215,6 +221,11 @@ func (p *PrivateKey) FromBytes(data []byte) error {
return nil
}
// Equal is a constant time comparison of the two private keys.
func (p *PrivateKey) Equal(privateKey *PrivateKey) bool {
return hmac.Equal(p.Bytes(), privateKey.Bytes())
}
// ToPEM writes out the PrivateKey to a PEM block.
func (p *PrivateKey) ToPEM() (*pem.Block, error) {
keyType := Name() + " PRIVATE KEY"
......@@ -267,6 +278,12 @@ func (p *PrivateKey) FromPEMFile(f string) error {
return nil
}
// PublicKey returns the public key associated
// with the given private key.
func (p *PrivateKey) PublicKey() *PublicKey {
return DerivePublicKey(p)
}
// DerivePublicKey derives a public key given a private key.
func DerivePublicKey(privKey *PrivateKey) *PublicKey {
var base C.public_key
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment