Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

Add UnmarshalEd25519PublicKey #24

Merged
merged 1 commit into from
May 11, 2017
Merged
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
13 changes: 13 additions & 0 deletions ed25519.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,19 @@ func (k *Ed25519PublicKey) ToCurve25519() (*[32]byte, error) {
return &pk, nil
}

func UnmarshalEd25519PublicKey(data []byte) (*Ed25519PublicKey, error) {
if len(data) != 32 {
return nil, fmt.Errorf("expect ed25519 public key data size to be 32")
}

var pub [32]byte
copy(pub[:], data)

return &Ed25519PublicKey{
k: &pub,
}, nil
}

func UnmarshalEd25519PrivateKey(data []byte) (*Ed25519PrivateKey, error) {
if len(data) != 96 {
return nil, fmt.Errorf("expected ed25519 data size to be 96")
Expand Down