Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add new constructor for an ecdsa.PublicKey #157

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion openpgp/ecdsa/ecdsa.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
package ecdsa

import (
"crypto/elliptic"
"errors"
"github.com/ProtonMail/go-crypto/openpgp/internal/ecc"
"io"
"math/big"

"github.com/ProtonMail/go-crypto/openpgp/internal/ecc"
)

type PublicKey struct {
Expand All @@ -19,6 +21,14 @@ type PrivateKey struct {
D *big.Int
}

// NewPublicKeyFromCurve takes an elliptic curve, and returns a PublicKey
// of that curve type.
func NewPublicKeyFromCurve(c elliptic.Curve) *PublicKey {
return &PublicKey{
curve: ecc.NewGenericCurve(c),
}
}

func NewPublicKey(curve ecc.ECDSACurve) *PublicKey {
return &PublicKey{
curve: curve,
Expand Down