Skip to content
SDKs · ServerIn developmentView source

Go

Dependency-free module over net/http. Construct once; safe for concurrent use. Wire 8.0 from v0.3.0.

In development

This SDK is implemented but not yet published to its package registry. Until it ships, collect an opaque evidence blob on the device and appraise it server-side with @rootherald/node (or any available server SDK). The API shown below is the planned surface and may change before release.

terminalbash
go get github.com/RootHerald/sdk-go

The calls

  • rootherald.NewClient(secretKey, WithBaseURL(…), WithHTTPClient(…))
  • RelayEnroll(ctx, blob) or RelayEnrollJSON(ctx, body) → the 201 body for the device's EnrollComplete / RelayActivate(ctx, activation) → DeviceID. A flat TPM body is the 7.0 shape and is refused locally with ErrInvalidEnrollBlob.
  • IssueChallengeWithOptions(ctx, ChallengeOptions{Ask, ExpectedKey, ExpectedDevices}) → Challenge{Nonce, Challenge, ExpiresAt}. IssueChallenge(ctx) asks for identity + posture.
  • Verify(ctx, evidence, AttestOptions{Nonce, RequestedDisclosureClass, ExpectedKey, ExpectedDevices}) → AttestResult{Verdict, Device, Expected, AssuranceClaimsMet, EnrollmentRequired, Raw}; a verdict that does not echo the binding is ErrExpectedNotEnforced.
  • IssueKeyChallenge(ctx, KeyChallengeOptions{Purpose, ExpectedDevices}) → KeyChallenge{Nonce, KeyChallenge, ExpiresAt}; CertifyKey(ctx, nonce, certification) → CertifiedKey{DeviceID, KeyID, Purpose, Alg, Format, JWK, HardwareBound, CertifiedAt}. Format is set on a decrypt key.
  • VerifyKeySignature(jwk, message, signature) bool — ES256 or RS256 by the JWK, crypto/ecdsa / crypto/rsa, raw or DER, never panics.
  • EncryptToDevice(key CertifiedKey, plaintext []byte) (string, error) — the JWE compact serialization only that device opens: ECDH-ES for an EC key, RSA-OAEP-256 for an RSA key, A256GCM for both, with crypto/ecdh / crypto/rsa and no Root Herald call. A sign key is ErrInvalidArgument; a macOS apple-ecies key is ErrEnvelopeFormatNotSupported.
  • Sentinels for errors.Is: ErrInvalidSecretKey, ErrChallenge, ErrInvalidEvidence, ErrInvalidAsk, ErrUnknownPolicy, ErrAdmissionRefused, ErrQuotaExceeded, ErrActivationRefused, ErrRateLimited; other codes are ErrAttestHTTP with APIError.Code preserved. Each is an error code in the API reference.