Documentation
¶
Index ¶
- func BytesToPrivKey(keyBytes []byte, kt KeyType) (crypto.PrivateKey, error)
- func BytesToPubKey(keyBytes []byte, kt KeyType, opts ...Option) (crypto.PublicKey, error)
- func Contains(needle string, haystack []string) bool
- func Copy(src any, dst any) error
- func GenerateEd25519Key() (ed25519.PublicKey, ed25519.PrivateKey, error)
- func GenerateJWK(eca jwa.EllipticCurveAlgorithm) (jwk.Key, error)
- func GenerateKeyByEllipticCurveAlgorithm(eca jwa.EllipticCurveAlgorithm) (crypto.PublicKey, crypto.PrivateKey, error)
- func GenerateKeyByKeyType(kt KeyType) (crypto.PublicKey, crypto.PrivateKey, error)
- func GenerateP224Key() (ecdsa.PublicKey, ecdsa.PrivateKey, error)
- func GenerateP256Key() (ecdsa.PublicKey, ecdsa.PrivateKey, error)
- func GenerateP384Key() (ecdsa.PublicKey, ecdsa.PrivateKey, error)
- func GenerateP521Key() (ecdsa.PublicKey, ecdsa.PrivateKey, error)
- func GenerateSECP256k1Key() (secp.PublicKey, secp.PrivateKey, error)
- func GenerateX25519Key() (x25519.PublicKey, x25519.PrivateKey, error)
- func IsSupportedKeyType(kt KeyType) bool
- func IsValidStruct(data any) error
- func NewValidator() *validator.Validate
- func PrettyJSON(data any) ([]byte, error)
- func PrivKeyToBytes(key crypto.PrivateKey) ([]byte, error)
- func PubKeyToBytes(key crypto.PublicKey, opts ...Option) ([]byte, error)
- func SECP256k1ECDSAPubKeyToSECP256k1(key ecdsa.PublicKey) secp.PublicKey
- func SECP256k1ECDSASPrivKeyToSECP256k1(key ecdsa.PrivateKey) secp.PrivateKey
- type HashType
- type KeyType
- type Option
- type Proof
- type SignatureAlgorithm
- type SingleOrArray
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BytesToPrivKey ¶
func BytesToPrivKey(keyBytes []byte, kt KeyType) (crypto.PrivateKey, error)
BytesToPrivKey reconstructs a private key given some bytes and a target key type It is assumed the key was turned into byte form using the sibling method `PrivKeyToBytes`
func BytesToPubKey ¶
BytesToPubKey reconstructs a public key given some bytes and a target key type It is assumed the key was turned into byte form using the sibling method `PubKeyToBytes`
func GenerateEd25519Key ¶
func GenerateEd25519Key() (ed25519.PublicKey, ed25519.PrivateKey, error)
func GenerateJWK ¶
func GenerateJWK(eca jwa.EllipticCurveAlgorithm) (jwk.Key, error)
GenerateJWK creates a new JWK key pair for the given elliptic curve algorithm The key ID is set to the base64 URL-encoded SHA-256 thumbprint of the key.
func GenerateKeyByEllipticCurveAlgorithm ¶
func GenerateKeyByEllipticCurveAlgorithm(eca jwa.EllipticCurveAlgorithm) (crypto.PublicKey, crypto.PrivateKey, error)
GenerateKeyByEllipticCurveAlgorithm creates a brand-new key, returning the public and private key for the given elliptic curve algorithm
func GenerateKeyByKeyType ¶
GenerateKeyByKeyType creates a brand-new key, returning the public and private key for the given key type
func GenerateP224Key ¶
func GenerateP224Key() (ecdsa.PublicKey, ecdsa.PrivateKey, error)
func GenerateP256Key ¶
func GenerateP256Key() (ecdsa.PublicKey, ecdsa.PrivateKey, error)
func GenerateP384Key ¶
func GenerateP384Key() (ecdsa.PublicKey, ecdsa.PrivateKey, error)
func GenerateP521Key ¶
func GenerateP521Key() (ecdsa.PublicKey, ecdsa.PrivateKey, error)
func GenerateSECP256k1Key ¶
func GenerateSECP256k1Key() (secp.PublicKey, secp.PrivateKey, error)
func GenerateX25519Key ¶
func GenerateX25519Key() (x25519.PublicKey, x25519.PrivateKey, error)
func IsSupportedKeyType ¶
IsSupportedKeyType returns true if the key type is supported
func IsValidStruct ¶
func NewValidator ¶
func PrettyJSON ¶
PrettyJSON JSON-ifies data in a 'pretty-print' fashion
func PrivKeyToBytes ¶
func PrivKeyToBytes(key crypto.PrivateKey) ([]byte, error)
PrivKeyToBytes constructs a byte representation of a private key, for a set number of supported key types
func PubKeyToBytes ¶
PubKeyToBytes constructs a byte representation of a public key, for a set number of supported key types
func SECP256k1ECDSAPubKeyToSECP256k1 ¶
SECP256k1ECDSAPubKeyToSECP256k1 converts an ecdsa.PublicKey to a secp.PublicKey
func SECP256k1ECDSASPrivKeyToSECP256k1 ¶
func SECP256k1ECDSASPrivKeyToSECP256k1(key ecdsa.PrivateKey) secp.PrivateKey
SECP256k1ECDSASPrivKeyToSECP256k1 converts an ecdsa.PrivateKey to a secp.PrivateKey
Types ¶
type KeyType ¶
type KeyType string
func GetKeyTypeFromPrivateKey ¶
func GetKeyTypeFromPrivateKey(key crypto.PrivateKey) (KeyType, error)
GetKeyTypeFromPrivateKey returns the key type for a private key for known key types
func GetSupportedJWKKeyTypes ¶
func GetSupportedJWKKeyTypes() []KeyType
GetSupportedJWKKeyTypes returns a list of supported JWK key types RSA, secp256k1, and P-224 are not supported by the lib we use for JWK
func GetSupportedKeyTypes ¶
func GetSupportedKeyTypes() []KeyType
GetSupportedKeyTypes returns a list of supported key types
type SignatureAlgorithm ¶
type SignatureAlgorithm string
type SingleOrArray ¶
type SingleOrArray[T any] []T
SingleOrArray represents a value that can be either a single item or an array of items
func (SingleOrArray[T]) MarshalJSON ¶
func (sa SingleOrArray[T]) MarshalJSON() ([]byte, error)
MarshalJSON implements custom marshaling for SingleOrArray
func (*SingleOrArray[T]) UnmarshalJSON ¶
func (sa *SingleOrArray[T]) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom unmarshaling for SingleOrArray