installation

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package installation manages license-bound installation keys and

Package installation manages license-bound installation keys and machine activation. An installation generates an Ed25519 key pair; the machine fingerprint is the lowercase hex SHA-256 of the raw 32-byte public key. Activation attaches the fingerprint and the base64-encoded public key to the machine's metadata, binding the key to the license.

Key creation and storage:

key, err := installation.NewKey()
seed := key.Seed()
// ... persist seed ...
key, err = installation.ParseKey(seed)

Activation:

machine, err := installation.Activate(ctx, license, key,
    licensing.WithMachineName("my-installation"))

Air-gapped activation:

req := installation.ActivationRequest{
    Fingerprint: key.Fingerprint(),
    PublicKey:   base64.StdEncoding.EncodeToString(key.Public()),
    LicenseID:   license.ID,
    Version:     "1.0.0",
}
data, _ := json.Marshal(req)
// ... transfer data to the vendor side ...

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrKeyMismatch reports that the public key from machine metadata
	// does not hash to the machine's fingerprint.
	ErrKeyMismatch = errors.New("public key does not hash to the machine fingerprint")

	// ErrPublicKeyMissing reports that the machine metadata has no
	// publicKey entry.
	ErrPublicKeyMissing = errors.New("machine metadata does not contain a public key")

	// ErrPublicKeyInvalid reports that the publicKey metadata value is
	// not valid base64 or not a 32-byte key.
	ErrPublicKeyInvalid = errors.New("machine metadata public key is invalid")

	// ErrSeedSize reports that a seed passed to ParseKey has the wrong
	// length.
	ErrSeedSize = errors.New("seed must be 32 bytes")

	// ErrFingerprintRequired reports that an activation request is
	// missing the fingerprint field.
	ErrFingerprintRequired = errors.New("activation request fingerprint is required")

	// ErrLicenseIDRequired reports that an activation request is missing
	// the license_id field.
	ErrLicenseIDRequired = errors.New("activation request license_id is required")
)

Activation and key errors matched with errors.Is.

Functions

func Activate

func Activate(
	ctx context.Context,
	license *licensing.License,
	key Key,
	opts ...licensing.ActivationOption,
) (*licensing.Machine, error)

Activate activates a machine for the license with the installation key's fingerprint and publicKey metadata. The caller's metadata is merged; publicKey and fingerprint from the key always win.

func Fingerprint

func Fingerprint(pub ed25519.PublicKey) string

Fingerprint computes the installation fingerprint of a raw Ed25519 public key: lowercase hex SHA-256.

func PublicKeyOf

func PublicKeyOf(machine *licensing.Machine) (ed25519.PublicKey, error)

PublicKeyOf reads the "publicKey" entry from the machine's metadata, verifies it hashes to the machine's fingerprint, and returns the raw 32-byte Ed25519 public key. It returns ErrPublicKeyMissing, ErrPublicKeyInvalid, or ErrKeyMismatch on failure.

func ValidFingerprint

func ValidFingerprint(s string) bool

ValidFingerprint reports whether s is a well-formed fingerprint: exactly 64 lowercase hex characters.

Types

type ActivationRequest

type ActivationRequest struct {
	// Fingerprint is the lowercase hex SHA-256 of the public key.
	Fingerprint string `json:"fingerprint"`

	// PublicKey is standard base64 of the 32-byte Ed25519 public key.
	PublicKey string `json:"public_key"`

	// LicenseID is the license UUID (not the license key).
	LicenseID string `json:"license_id"`

	// Version is the build version of the installation.
	Version string `json:"version"`
}

ActivationRequest is the payload for air-gapped activation: the installation sends this to the vendor side, which activates a machine from it on the vendor's network.

func ParseActivationRequest

func ParseActivationRequest(data []byte) (*ActivationRequest, error)

ParseActivationRequest decodes an activation request from JSON.

type Key

type Key struct {
	// contains filtered or unexported fields
}

Key is an Ed25519 installation key pair. The private key is 64 bytes (seed + public key); the public key is 32 bytes.

func NewKey

func NewKey() (Key, error)

NewKey generates a fresh Ed25519 key pair from the system CSPRNG.

func ParseKey

func ParseKey(seed []byte) (Key, error)

ParseKey reconstructs a Key from its 32-byte seed.

func (Key) Fingerprint

func (k Key) Fingerprint() string

Fingerprint returns the lowercase hex SHA-256 of the raw public key. It matches Fingerprint(k.Public()).

func (Key) PrivateKey

func (k Key) PrivateKey() ed25519.PrivateKey

PrivateKey returns the underlying ed25519.PrivateKey.

func (Key) Public

func (k Key) Public() ed25519.PublicKey

Public returns the 32-byte Ed25519 public key. The public key bytes are the last 32 bytes of the private key seed+pub encoding.

func (Key) Seed

func (k Key) Seed() []byte

Seed returns the 32-byte seed that can reconstruct the key.

func (Key) Sign

func (k Key) Sign(msg []byte) []byte

Sign signs msg with the private key.

Jump to

Keyboard shortcuts

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