TrustGraphSDK

Signing

Graph key IDs, canonical JSON, and edge certificate signatures.

Signing

Graph keys

Graph keys are public P-256 EC JWKs. The SDK rejects private JWKs for graph key IDs and registration helpers.

import { graphKeyId } from "@rebellion-systems/trust-graph-sdk";
 
const id = graphKeyId(publicKeyJwk);

The ID is:

sha256(canonicalJson({ crv, kty, x, y }))

Canonical JSON

Trust edge signatures use canonical JSON:

  • Object keys are sorted.
  • undefined object properties are omitted.
  • Arrays keep order.
  • Values are serialized with JSON.stringify.
import { canonicalJson } from "@rebellion-systems/trust-graph-sdk";
 
canonicalJson({ z: 1, a: { b: 2 } });

Edge certificate payloads

Only these fields are signed:

{
  signerGraphKeyId: string;
  subjectGraphKeyId: string;
  trust: number;
  scope: TrustScope;
  createdAt: string;
  expiresAt?: string;
  nonce: string;
}

The helper strips accidental extra fields such as signature before signing:

import { edgeCertificatePayload } from "@rebellion-systems/trust-graph-sdk";
 
const payload = edgeCertificatePayload(input);

Node signatures

The current server verifies Node/OpenSSL DER-encoded ECDSA signatures:

import { signEdgeCertificatePayload } from "@rebellion-systems/trust-graph-sdk";
 
const signature = signEdgeCertificatePayload(privateKey, payload);

privateKey can be a Node KeyObject, PEM string, or private JWK.

Do not use raw WebCrypto ECDSA output directly against the current server. Web Crypto returns raw r || s signatures, while the server expects DER. A browser signing helper should DER-encode the signature before submission.

On this page