Function to get private key from ASN.1 serialized structure (#109)
* func to get privkey from raw bytes * comments fix * review fixes; version * version
This commit is contained in:
parent
5b57a10250
commit
fa1da2cb91
2 changed files with 11 additions and 1 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
0.45.12
|
||||
0.45.14
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"crypto/elliptic"
|
||||
"crypto/rand"
|
||||
"crypto/sha256"
|
||||
"crypto/x509"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
@ -57,6 +58,15 @@ func NewPrivateKeyFromBytes(b []byte) (*PrivateKey, error) {
|
|||
return &PrivateKey{b}, nil
|
||||
}
|
||||
|
||||
// NewPrivateKeyFromRawBytes returns a NEO PrivateKey from the ASN.1 serialized keys.
|
||||
func NewPrivateKeyFromRawBytes(b []byte) (*PrivateKey, error) {
|
||||
privkey, err := x509.ParseECPrivateKey(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return NewPrivateKeyFromBytes(privkey.D.Bytes())
|
||||
}
|
||||
|
||||
// PublicKey derives the public key from the private key.
|
||||
func (p *PrivateKey) PublicKey() ([]byte, error) {
|
||||
var (
|
||||
|
|
Loading…
Reference in a new issue