Documentation
¶
Index ¶
Constants ¶
const ( // SIG1Prefix is the wire format prefix SIG1Prefix = "SIG1" // SIG1Separator is the field separator in the wire format SIG1Separator = "." )
Variables ¶
var ( // ErrTokenExpired indicates the token has expired ErrTokenExpired = errors.New("token has expired") // ErrInvalidToken indicates the token payload failed validation ErrInvalidToken = errors.New("token is invalid") )
Common errors
Functions ¶
func ComputeCapabilityID ¶
ComputeCapabilityID computes the 128-bit capability identifier from capability tokens per ADR-002 section 3.1.
The computation: 1. Sort tokens numerically 2. Deduplicate (keep first occurrence after sort) 3. Encode as canonical CBOR array 4. Hash with domain separation and truncate to 128 bits
Empty capability lists:
- nil or []uint64{} both normalize to empty array
- Empty capabilities produce a deterministic hash
- Semantics: "no capabilities" typically means "no access" unless the authorization layer explicitly grants default permissions
- This allows tokens to be issued without capabilities for revocation checking or identity verification only
func EncodeSIG1 ¶
EncodeSIG1 encodes a token into SIG1 wire format using COSE Sign1
Format: SIG1.<base64url(CBOR)>.<base64url(COSE_Sign1)>
func ValidateCapabilityID ¶
ValidateCapabilityID verifies that a capability ID matches the computed hash of the provided capability tokens.
Types ¶
type SIG1 ¶
type SIG1 struct {
// Token is the decoded Signet token
Token *Token
// Signature is the COSE Sign1 signature bytes
Signature []byte
// Raw is the original wire format string
Raw string
}
SIG1 represents a Signet token in SIG1 wire format.
Format: SIG1.<base64url(CBOR)>.<base64url(COSE_Sign1)>
The structure contains the decoded token, the COSE signature bytes, and the original wire format string for reference.
func DecodeSIG1 ¶
DecodeSIG1 decodes a SIG1 wire format string and verifies the signature
Returns the token and COSE signature. Does NOT verify signature - caller must verify using cose.Verifier.
type Token ¶
type Token struct {
IssuerID string `cbor:"1,keyasint"`
AudienceID string `cbor:"2,keyasint,omitempty"`
SubjectPPID []byte `cbor:"3,keyasint"`
ExpiresAt int64 `cbor:"4,keyasint"`
NotBefore int64 `cbor:"5,keyasint"`
IssuedAt int64 `cbor:"6,keyasint"`
CapabilityID []byte `cbor:"7,keyasint"`
CapabilityVer uint32 `cbor:"8,keyasint,omitempty"`
ConfirmationID []byte `cbor:"9,keyasint"`
KeyID []byte `cbor:"10,keyasint,omitempty"`
CapTokens []uint64 `cbor:"11,keyasint,omitempty"`
CapCustom map[string]interface{} `cbor:"12,keyasint,omitempty"`
JTI []byte `cbor:"13,keyasint"`
Actor map[string]interface{} `cbor:"14,keyasint,omitempty"`
Delegator map[string]interface{} `cbor:"15,keyasint,omitempty"`
AudienceStr string `cbor:"16,keyasint,omitempty"`
Nonce []byte `cbor:"17,keyasint,omitempty"`
EphemeralKeyID []byte `cbor:"18,keyasint,omitempty"`
Epoch uint64 `cbor:"19,keyasint,omitempty"`
}
Token represents the CBOR-encoded Signet token structure as defined in ADR-002. Integer keys are used to keep payloads compact and deterministic across languages.
Optional fields are omitted from the encoding when zero-valued.
func NewToken ¶
func NewToken(issuerID string, confirmationID []byte, ephemeralKeyID []byte, nonce []byte, validityDuration time.Duration) (*Token, error)
NewToken creates a new Signet token with sensible defaults derived from the provided cryptographic context. Additional fields can be set by mutating the returned Token before marshaling.
func VerifySIG1 ¶
VerifySIG1 decodes and verifies a SIG1 wire format string