Skip to content
docsv0.1.0

StateSignature

The result of {@see \Milpa\Live\Contracts\Security\StateSignerInterface::sign()} — a signature value plus the metadata needed to independently verify and expire it. Carries no reference to what was signed; the signer re-derives that binding at {@see \Milpa\Live\Contracts\Security\StateSignerInterface::verify()} time from the original payload and `$claims`, which is why `$claims` MUST round-trip byte-for-byte via {@see toAttributes()}/{@see fromAttributes()}.

StateSignature::__construct()

public function __construct(string $algorithm, string $value, int $issuedAt, int $expiresAt, string $nonce, array $claims = []):

Parameters

Parameters of __construct()
NameTypeDescription
$algorithmstringThe signing algorithm identifier (e.g. `'hmac-sha256'`); verification MUST reject a signature whose algorithm it does not implement.
$valuestringThe signature/MAC value itself.
$issuedAtintUnix timestamp the signature was issued at.
$expiresAtintUnix timestamp after which the signature MUST be treated as invalid.
$noncestringA per-signature random value preventing signature reuse/replay across calls.
$claimsarray<string, mixed>Domain data bound into the signature (e.g. component id, kind); MUST match what the caller re-supplies as `$requiredClaims` on verify.

StateSignature::toAttributes()

public function toAttributes(): array

Flattens this signature into a string-keyed attribute map (the `sig-*` counterpart of {@see fromAttributes()}) suitable for embedding as XML/HTML element attributes, as the `Signed*Codec` decorators in this package do.

StateSignature::fromAttributes()

public static function fromAttributes(array $attributes): self

Rebuilds a signature from the attribute map produced by {@see toAttributes()}. Missing attributes default to empty/zero rather than throw, so a tampered or partial attribute set still decodes into a signature — one that will then simply fail cryptographic verification rather than failing to parse.

Parameters

Parameters of fromAttributes()
NameTypeDescription
$attributesarray<string, mixed>