dsse

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package dsse implements the DSSE pre-authentication encoding (PAE), Ed25519 signing over PAE bytes, and the Week-1 leaf hash, exactly per docs/export-format-v1.md §1.2:

pae = "DSSEv1" SP LEN(payloadType) SP payloadType SP LEN(payload) SP payload

where LEN is the decimal ASCII byte length and SP is a single 0x20. The payload is framed as opaque length-prefixed bytes: no canonicalization step exists (receipt-schema-v1.md §2, Q27).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LeafHash

func LeafHash(payloadType string, payload []byte) [32]byte

LeafHash returns the Week-1 leaf hash: SHA-256 over the PAE bytes (export-format-v1.md §1.2).

func PAE

func PAE(payloadType string, payload []byte) []byte

PAE returns the DSSE v1 pre-authentication encoding of payloadType and payload. Lengths are byte lengths, written in decimal ASCII; separators are single 0x20 bytes; nothing is escaped or canonicalized.

func Sign

func Sign(priv ed25519.PrivateKey, payloadType string, payload []byte) []byte

Sign returns the Ed25519 signature over PAE(payloadType, payload).

func Verify

func Verify(pub ed25519.PublicKey, payloadType string, payload, sig []byte) bool

Verify reports whether sig is a valid Ed25519 signature by pub over PAE(payloadType, payload).

Types

type JWK

type JWK struct {
	Kty string `json:"kty"`
	Crv string `json:"crv"`
	X   string `json:"x"`
}

JWK is an Ed25519 public key in JWK form (RFC 8037): kty OKP, crv Ed25519, x = base64url(raw 32-byte public key), no padding.

func JWKFromPublic

func JWKFromPublic(pub ed25519.PublicKey) JWK

JWKFromPublic returns the JWK for an Ed25519 public key.

func (JWK) Thumbprint

func (j JWK) Thumbprint() string

Thumbprint returns the RFC 7638 JWK thumbprint: SHA-256 over the JSON object containing exactly the required members (crv, kty, x for OKP keys) in lexicographic order with no whitespace, base64url-encoded without padding.

The construction string is built by hand rather than via encoding/json so the member order and absence of escaping are explicit; base64url values never need JSON escaping.

Jump to

Keyboard shortcuts

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