Documentation ¶
Overview ¶
Copyright 2023 The Go SSI Framework Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Copyright 2023 The Go SSI Framework Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Copyright 2023 The Go SSI Framework Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Copyright 2023 The Go SSI Framework Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Index ¶
- Constants
- func GeneratePrivateKeyAsJwk(didController string) (jwk.Key, error)
- type EciesEncrypted
- type PrivateKey
- func GeneratePrivateKey() (*PrivateKey, error)
- func NewPrivateKeyFromBytes(privBytes []byte) (*PrivateKey, error)
- func NewPrivateKeyFromHex(privHex string) (*PrivateKey, error)
- func NewPrivateKeyFromJwk(privJwk jwk.Key) (*PrivateKey, error)
- func NewPrivateKeyFromMap(privMap map[string]interface{}) (*PrivateKey, error)
- func SetPrivateKey(priv *ecdsa.PrivateKey) *PrivateKey
- func (k *PrivateKey) Bytes() []byte
- func (k *PrivateKey) Decrypt(msg []byte) ([]byte, error)
- func (k *PrivateKey) ECDH(pub *ecdsa.PublicKey) ([]byte, error)
- func (k *PrivateKey) Encrypt(pubKey *ecdsa.PublicKey, plaintext []byte) ([]byte, error)
- func (k *PrivateKey) Equals(priv *ecdsa.PrivateKey) bool
- func (k *PrivateKey) Hex() string
- func (k *PrivateKey) Jwk(didController string) (jwk.Key, error)
- func (k *PrivateKey) MarshalJSON() ([]byte, error)
- func (k *PrivateKey) Sign(payload interface{}) (interface{}, error)
- func (k *PrivateKey) UnmarshalJSON(data []byte) error
- type PublicKey
- func NewPublicKeyFromBytes(pubBytes []byte) (*PublicKey, error)
- func NewPublicKeyFromHex(pubHex string) (*PublicKey, error)
- func NewPublicKeyFromJwk(pubJwk jwk.Key) (*PublicKey, error)
- func NewPublicKeyFromMap(pubMap map[string]interface{}) (*PublicKey, error)
- func SetPublicKey(pub *ecdsa.PublicKey) *PublicKey
- func (k *PublicKey) Bytes(compressed bool) []byte
- func (k *PublicKey) ECDH(priv *ecdsa.PrivateKey) ([]byte, error)
- func (k *PublicKey) Equals(pub *ecdsa.PublicKey) bool
- func (k *PublicKey) GetAdress() (string, error)
- func (k *PublicKey) Hex(compressed bool) string
- func (k *PublicKey) Jwk() (jwk.Key, error)
- func (k *PublicKey) MarshalJSON() ([]byte, error)
- func (k *PublicKey) UnmarshalJSON(data []byte) error
- func (k *PublicKey) Verify(signed interface{}, options ...jwt.ParseOption) error
Constants ¶
const Secp256k1 jwa.EllipticCurveAlgorithm = "secp256k1"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type EciesEncrypted ¶
type PrivateKey ¶
type PrivateKey struct { *ecdsa.PrivateKey // Needed to include because information is lost when transforming between jwk and ecdsa JwkKey jwk.Key }
PrivateKey is an instance of secp256k1 private key with nested public key
func GeneratePrivateKey ¶
func GeneratePrivateKey() (*PrivateKey, error)
GenerateKey generates secp256k1 key pair
func NewPrivateKeyFromBytes ¶
func NewPrivateKeyFromBytes(privBytes []byte) (*PrivateKey, error)
NewPrivateKeyFromBytes decodes private key raw bytes, computes public key and returns PrivateKey instance
func NewPrivateKeyFromHex ¶
func NewPrivateKeyFromHex(privHex string) (*PrivateKey, error)
NewPrivateKeyFromHex decodes hex form of private key raw bytes, computes public key and returns PrivateKey instance
func NewPrivateKeyFromJwk ¶
func NewPrivateKeyFromJwk(privJwk jwk.Key) (*PrivateKey, error)
func NewPrivateKeyFromMap ¶
func NewPrivateKeyFromMap(privMap map[string]interface{}) (*PrivateKey, error)
NewPrivateKeyFromMap decodes private key from a map, map must be a valid json web key
func SetPrivateKey ¶
func SetPrivateKey(priv *ecdsa.PrivateKey) *PrivateKey
func (*PrivateKey) Decrypt ¶
func (k *PrivateKey) Decrypt(msg []byte) ([]byte, error)
Decrypt decrypts a passed message with a receiver private key, returns plaintext or decryption error
func (*PrivateKey) ECDH ¶
func (k *PrivateKey) ECDH(pub *ecdsa.PublicKey) ([]byte, error)
ECDH encapsulates key by using Key Encapsulation Mechanism and returns symmetric key; can be safely used as encryption key
func (*PrivateKey) Encrypt ¶
Encrypt encrypts a passed message with a sender private key and receivers public key, returns ecies structure or encryption error
func (*PrivateKey) Equals ¶
func (k *PrivateKey) Equals(priv *ecdsa.PrivateKey) bool
Equals compares two private keys with constant time (to resist timing attacks)
func (*PrivateKey) Hex ¶
func (k *PrivateKey) Hex() string
Hex returns private key bytes in hex form
func (*PrivateKey) Jwk ¶
func (k *PrivateKey) Jwk(didController string) (jwk.Key, error)
Jwk returns private key as json web key
func (*PrivateKey) MarshalJSON ¶
func (k *PrivateKey) MarshalJSON() ([]byte, error)
func (*PrivateKey) Sign ¶
func (k *PrivateKey) Sign(payload interface{}) (interface{}, error)
Sign signs the payload, jwt (payload is jwt.Token) and linked data proof are supported (payload is map[string]interface)
func (*PrivateKey) UnmarshalJSON ¶
func (k *PrivateKey) UnmarshalJSON(data []byte) error
type PublicKey ¶
type PublicKey struct { *ecdsa.PublicKey // Needed to include because information is lost when transforming between jwk and ecdsa JwkKey jwk.Key }
PublicKey instance with nested elliptic.Curve interface (secp256k1 instance in our case)
func NewPublicKeyFromBytes ¶
NewPublicKeyFromBytes decodes public key raw bytes and returns PublicKey instance; Supports both compressed and uncompressed public keys
func NewPublicKeyFromHex ¶
NewPublicKeyFromHex decodes hex form of public key raw bytes and returns PublicKey instance
func NewPublicKeyFromMap ¶
NewPublicKeyFromMap decodes public key from a map, map must be a valid json web key
func SetPublicKey ¶
func (*PublicKey) Bytes ¶
Bytes returns public key raw bytes; Could be optionally compressed by dropping Y part
func (*PublicKey) ECDH ¶
func (k *PublicKey) ECDH(priv *ecdsa.PrivateKey) ([]byte, error)
Decapsulate decapsulates key by using Key Encapsulation Mechanism and returns symmetric key; can be safely used as encryption key
func (*PublicKey) Equals ¶
Equals compares two public keys with constant time (to resist timing attacks)