encryptionkey

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package encryptionkey manages encryption keys for users

Index

Constants

KemID for HPKE protocol.

View Source
const SignerProductionPublicKey = "" /* 130-byte string literal not displayed */

SignerProductionPublicKey is the enclave quorum public key.

Variables

This section is empty.

Functions

func DecodeZeroXKeyPrivateKey

func DecodeZeroXKeyPrivateKey(encodedPrivateKey string) (*kem.PrivateKey, error)

DecodeZeroXKeyPrivateKey takes a 0xkey-encoded private key and creates a KEM private key.

func DecodeZeroXKeyPublicKey

func DecodeZeroXKeyPublicKey(encodedPublicKey string) (*kem.PublicKey, error)

DecodeZeroXKeyPublicKey takes a 0xkey-encoded public key and creates a KEM public key.

func EncodePrivateKey

func EncodePrivateKey(privateKey kem.PrivateKey) (string, error)

EncodePrivateKey encodes a KEM private key into the 0xkey format. For now, "0xkey format" = raw DER form.

func EncodePublicKey

func EncodePublicKey(publicKey kem.PublicKey) (string, error)

EncodePublicKey encodes a KEM public key into the 0xkey format. For now, "0xkey format" = raw DER form.

Types

type Key

type Key struct {
	Metadata

	EncodedPrivateKey string `json:"-"` // do not store the private key in the metadata file
	EncodedPublicKey  string `json:"public_key"`
	// contains filtered or unexported fields
}

Key defines a structure in which to hold both serialized and ecdh-lib-friendly versions of a 0xkey Encryption keypair.

func FromKemPrivateKey

func FromKemPrivateKey(privateKey kem.PrivateKey) (*Key, error)

FromKemPrivateKey takes a HPKE KEM keypair and forms a 0xkey encryption key from it. Assumes that privateKey.Public() has already been derived.

func FromZeroXKeyPrivateKey

func FromZeroXKeyPrivateKey(encodedPrivateKey string) (*Key, error)

FromZeroXKeyPrivateKey takes a 0xkey-encoded private key, derives a public key from it, and then returns the corresponding 0xkey API key.

func New

func New(userID string, organizationID string) (*Key, error)

New generates a new 0xkey encryption key.

func (Key) GetCurve

func (k Key) GetCurve() string

GetCurve returns the curve used.

func (Key) GetMetadata

func (k Key) GetMetadata() Metadata

GetMetadata gets the key's metadata.

func (Key) GetPrivateKey

func (k Key) GetPrivateKey() string

GetPrivateKey gets the key's private key.

func (Key) GetPublicKey

func (k Key) GetPublicKey() string

GetPublicKey gets the key's public key.

func (Key) LoadMetadata

func (k Key) LoadMetadata(fn string) (*Metadata, error)

LoadMetadata loads a JSON metadata file.

func (*Key) MergeMetadata

func (k *Key) MergeMetadata(md Metadata) error

MergeMetadata merges the given metadata with the api key.

type Metadata

type Metadata struct {
	Name         string `json:"name"`
	Organization string `json:"organization"`
	User         string `json:"user"`
	PublicKey    string `json:"public_key"`
}

Metadata stores non-secret metadata about the Encryption key.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL