Documentation ¶
Overview ¶
Package apikey manages Turnkey API keys for organizations
Index ¶
- Constants
- func DecodeTurnkeyPublicKey(encodedPublicKey string) (*ecdsa.PublicKey, error)
- func EncodePrivateKey(privateKey *ecdsa.PrivateKey) string
- func EncodePublicKey(publicKey *ecdsa.PublicKey) string
- func Stamp(message []byte, apiKey *Key) (out string, err error)
- type APIStamp
- type Key
- type Metadata
Constants ¶
const TurnkeyAPISignatureScheme = "SIGNATURE_SCHEME_TK_API_P256"
TurnkeyAPISignatureScheme is the signature scheme to use for the API request signature.
Variables ¶
This section is empty.
Functions ¶
func DecodeTurnkeyPublicKey ¶
DecodeTurnkeyPublicKey takes a Turnkey-encoded public key and creates an ECDSA public key.
func EncodePrivateKey ¶
func EncodePrivateKey(privateKey *ecdsa.PrivateKey) string
EncodePrivateKey encodes an ECDSA private key into the Turnkey format. For now, "Turnkey format" = raw DER form.
func EncodePublicKey ¶
EncodePublicKey encodes an ECDSA public key into the Turnkey format. For now, "Turnkey format" = standard compressed form for ECDSA keys.
Types ¶
type APIStamp ¶
type APIStamp struct { // API public key, hex-encoded PublicKey string `json:"publicKey"` // Signature is the P-256 signature bytes, hex-encoded Signature string `json:"signature"` // Signature scheme. Must be set to "SIGNATURE_SCHEME_TK_API_P256" Scheme string `json:"scheme"` }
APIStamp defines the stamp format used to authenticate payloads to the API.
type Key ¶
type Key struct { Metadata TkPrivateKey string `json:"-"` // do not store the private key in the metadata file TkPublicKey string `json:"public_key"` // contains filtered or unexported fields }
Key defines a structure in which to hold both serialized and ecdsa-lib-friendly versions of a Turnkey API keypair.
func FromECDSAPrivateKey ¶
func FromECDSAPrivateKey(privateKey *ecdsa.PrivateKey) (*Key, error)
FromECDSAPrivateKey takes an ECDSA keypair and forms a Turnkey API key from it. Assumes that privateKey.PublicKey has already been derived.
func FromTurnkeyPrivateKey ¶
FromTurnkeyPrivateKey takes a Turnkey-encoded private key, derives a public key from it, and then returns the corresponding Turnkey API key.
func (Key) GetPrivateKey ¶
GetPrivateKey gets the key's private key.
func (Key) GetPublicKey ¶
GetPublicKey gets the key's public key.
func (Key) LoadMetadata ¶
LoadMetadata loads a JSON metadata file.
func (Key) MergeMetadata ¶
MergeMetadata merges the given metadata with the api key.