bundlesign

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0, MIT Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package bundlesign signs a bundle of the kinds of request, and verifies such a signature.

A bundle is a zip of a requests directory and its Wasm module. What is signed is not the zip's bytes directly but a short text: the fixed prefix line "ringi bundle v1", then the SHA-256 of the whole bundle as one line of lower-case hexadecimal. The digest keeps the signature small and independent of how large the bundle is; the prefix keeps a signature of a bundle from being read as a signature of anything else. The signature file holds the 64-byte ed25519 signature of that line in standard base64, as one line.

Sign makes the signature file's content with a private key, and Verify checks it with public keys. ReadPrivateKey and ReadPublicKeys read the keys in the PEM forms common tools write (PKCS#8 and PKIX). The package uses the standard library alone.

A server checks a bundle's signature only when its configuration lists ed25519 public keys. Without such a list, a bundle is not refused for having no signature; the server's other checks and approvals decide whether it is taken.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Digest

func Digest(bundle []byte) string

Digest answers the SHA-256 of bundle in lower-case hexadecimal.

func KeyFingerprint

func KeyFingerprint(key ed25519.PublicKey) string

KeyFingerprint names a key: the SHA-256 of its bytes, in lower-case hexadecimal. It names the key, not what it signed, so that a store can record which key signed a bundle without keeping the key.

func ReadPrivateKey

func ReadPrivateKey(pemData []byte) (ed25519.PrivateKey, error)

ReadPrivateKey reads one PEM block of type "PRIVATE KEY", a private key in the PKCS#8 form crypto/x509.MarshalPKCS8PrivateKey and common tools write. It refuses data that is not exactly one such block, and a key that is not ed25519.

func ReadPublicKeys

func ReadPublicKeys(pemData []byte) ([]ed25519.PublicKey, error)

ReadPublicKeys reads one or more PEM blocks of type "PUBLIC KEY", each a public key in the PKIX form crypto/x509.MarshalPKIXPublicKey and common tools write. It refuses a block of another type, a key that is not ed25519, data outside the blocks, and data with no block.

func Sign

func Sign(key ed25519.PrivateKey, bundle []byte) []byte

Sign answers the content of the signature file for bundle: the 64-byte ed25519 signature in standard base64, one line ending with a newline. key is a private key as ed25519.GenerateKey or ReadPrivateKey answers it.

func Verify

func Verify(keys []ed25519.PublicKey, bundle []byte, sig []byte) error

Verify checks that sig is the content of a signature file for bundle made by one of keys. It answers nil when any key verifies it. The file may end at the base64 line, or with a newline or CRLF; anything else around the base64 is refused.

func VerifyKey

func VerifyKey(keys []ed25519.PublicKey, bundle []byte, sig []byte) (ed25519.PublicKey, error)

VerifyKey is Verify, and answers the key that verifies the signature (nil when none does, with the error). A server keeps which key signed a bundle, so that a decision made later can say whether the keys it lists still verify it.

Types

This section is empty.

Jump to

Keyboard shortcuts

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