Skip to content

feat(license): Ed25519 license-verification core + startup gate (recover engine#19) - #21

Merged
zooqueen merged 1 commit into
mainfrom
feat/license-verification-core-recover
Jun 17, 2026
Merged

zooqueen merged 1 commit into
mainfrom
feat/license-verification-core-recover

Conversation

@zooqueen

Copy link
Copy Markdown
Member

Recovers the real feature from #19 onto current main as a focused, reviewable change. #19 is a 430k-line / 1402-file fork-sync blob (its merge-base with main is from 2024); this PR extracts only the ~5-file license feature and drops all the fork-sync noise.

What this is

Engine-side license verification: with the license-enforce feature on, the proprietary engine refuses to serve unless it is handed a valid, unexpired, correctly-scoped Hanzo-issued Ed25519 token for the right app. With the feature off (the default — dev/CLI/perf/test), both gate sites are a one-line no-op.

Files (9 changed, +154; 3 new source/artifact files)

License core — hanzo-engine/src/license.rs

  • Ed25519 verification via ed25519-dalek.
  • Token wire format (minimal JWT-ish, no header): base64url(JSON(claims)) "." base64url(ed25519_sig[64]). The signature is over the ASCII bytes of the encoded payload, so verification never re-canonicalizes JSON. Claims: {v:u8, app_id, holder, iat, exp, features, nonce}.
  • verify_license(token, pubkey, expected_app, now_unix) -> Result<License, LicenseError> with distinct errors Missing / Malformed / BadSig / Expired / NotYetValid / WrongApp.
  • load_and_verify() reads HANZO_ENGINE_LICENSE_TOKEN (fallback file via HANZO_ENGINE_LICENSE_FILE), checks embedded pubkey + build expected_app + current time.
  • HANZO_LICENSE_PUBKEY is a DEV key, clearly marked DEV KEY -- replace with prod pubkey from KMS for release. The private seed is not committed (gitignored license-dev-key/dev_signing_key.b64).
  • expected_app fixed per build via cargo features license-app-hanzo / license-app-lux / license-app-zoo (default "hanzo-dev"), so a Zoo token cannot run a Hanzo build.
  • 9 unit tests.

Issuer — hanzo-engine/examples/license_issuer.rs

  • Mints signed per-app tokens. Private key from --signing-key-file or HANZO_LICENSE_SIGNING_KEY (base64url/base64 32-byte seed), never hardcoded. Self-checks the freshly minted token before printing.

Gate (cargo feature license-enforce, OFF by default)

  • hanzo-cli/src/commands/serve.rs — top of run_server, before initialize_logging(): on failure prints to stderr and hard-exits 78 (EX_CONFIG).
  • hanzo-server-core/src/hanzo_for_server_builder.rs — top of HanzoForServerBuilder::build(): returns Err so the engine never binds its listener (covers every embedder that goes through the builder: node / CLI / pyo3-via-server).

Wiring

  • Workspace + engine dep ed25519-dalek = { version = "2.1.1", default-features = false, features = ["rand_core"] } (all other deps — base64, rand, serde_json, clap — were already present on current main at the exact versions used).
  • license-enforce + license-app-{hanzo,lux,zoo} features added to hanzo-engine, hanzo-cli, hanzo-server-core.
  • license-dev-key/ holds the committed public key (dev_public_key.b64, dev_public_key.rs.txt) + README.md; private seed gitignored.

Insertion points on current main

  • serve.rs: run_server opens with initialize_logging(); — the gate call goes immediately above it; the two #[cfg] fn definitions go after run_server closes (before pub(crate) fn log_api_surfaces).
  • hanzo_for_server_builder.rs: the two #[cfg] fns go after the use block (before struct ModelConfig); build() is at the pub async fn build(self) -> Result<SharedHanzoState> and the gate call is its first line.

(These had "moved" only in the sense that #19's diff showed them as new file — an artifact of the 2024 merge-base. On current main both files exist; the feature delta vs. #19's copies is exactly the gate, with the rest being fork-sync churn that is intentionally excluded.)

Verification

  • cargo test -p hanzo-engine --no-default-features license -> 9 passed, 0 failed (incl. dev_keypair_matches_embedded_pubkey).
  • cargo check -p hanzo-cli --no-default-features --features license-enforce,license-app-hanzo -> clean (both gate sites build under enforcement).
  • cargo build -p hanzo-engine --example license_issuer -> builds; ran end-to-end and it mints a token decoding to the exact claim schema, self-verified.
  • Confirmed no fork-sync noise leaked (no MISTRALRS_API_ROUTES rename, no RouteKind::MistralRs, no PAGED_ATTN_ROCM / is_rocm).

Note: on a fresh clone the gitignored license-dev-key/dev_signing_key.b64 must be recreated before cargo test (one-liner in license-dev-key/README.md).

Follow-ups (NOT in this PR)

  • Prod key: HANZO_LICENSE_PUBKEY is a throwaway DEV key. Generate the prod keypair on a private host, hold the private key in KMS / CI secret, and swap this const before release.
  • App-side wiring: inject the token via option_env!("HANZO_ENGINE_LICENSE_TOKEN") in the node-options structs and pass through to the sidecar env; add the 3 CI secrets; build per-app with the license-app-* feature.
  • pyo3 paths that build models without going through HanzoForServerBuilder are not gated here.
  • Binary signing (cosign + Apple/Windows) and revocation are out of scope.

Does not auto-merge (proprietary licensing code — needs human review). #19 left open intentionally; close it once this extraction is confirmed good.

🤖 Generated with Claude Code

…ver engine#19)

Engine-side license verification: the proprietary engine refuses to serve
unless handed a valid, unexpired, correctly-scoped Hanzo-issued Ed25519 token
for the right app.

Recovers the actual feature from #19 (a 430k-line fork-sync blob) onto current
main as a focused ~5-file change. No fork-sync noise (route renames, ROCM
defaults) is dragged in.

- hanzo-engine/src/license.rs: Ed25519 verify core via ed25519-dalek.
  Token = base64url(JSON claims)"."base64url(ed25519 sig[64]); sig is over the
  encoded payload bytes so verify never re-canonicalizes JSON. Claims
  {v,app_id,holder,iat,exp,features,nonce}. verify_license / load_and_verify
  with distinct errors Missing/Malformed/BadSig/Expired/NotYetValid/WrongApp.
  Embedded HANZO_LICENSE_PUBKEY is a DEV key (clearly marked; prod pubkey from
  KMS swapped in at release). expected_app fixed per build via cargo features
  license-app-hanzo/lux/zoo (default "hanzo-dev"). 9 unit tests.
- hanzo-engine/examples/license_issuer.rs: mints signed per-app tokens; private
  key from --signing-key-file / HANZO_LICENSE_SIGNING_KEY, never hardcoded;
  self-checks the freshly minted token.
- Gate (cargo feature license-enforce, OFF by default):
  hanzo-cli/src/commands/serve.rs top of run_server (exit 78 on failure) and
  hanzo-server-core/src/hanzo_for_server_builder.rs top of build() (returns
  Err). No-op note when the feature is off.
- workspace + engine dep: ed25519-dalek 2.1.1. license-dev-key/ holds the
  committed public key + README; the private seed is gitignored.

Verified:
- cargo test -p hanzo-engine --no-default-features license -> 9 passed.
- cargo check -p hanzo-cli --no-default-features --features license-enforce,license-app-hanzo -> clean.
- cargo build -p hanzo-engine --example license_issuer -> builds; mints a token
  that decodes to the exact claim schema and self-verifies.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@zooqueen
zooqueen merged commit 9f165ec into main Jun 17, 2026
0 of 16 checks passed
@zooqueen
zooqueen deleted the feat/license-verification-core-recover branch June 17, 2026 06:41
hanzo-dev pushed a commit that referenced this pull request Jul 16, 2026
…ver engine#19) (#21)

Engine-side license verification: the proprietary engine refuses to serve
unless handed a valid, unexpired, correctly-scoped Hanzo-issued Ed25519 token
for the right app.

Recovers the actual feature from #19 (a 430k-line fork-sync blob) onto current
main as a focused ~5-file change. No fork-sync noise (route renames, ROCM
defaults) is dragged in.

- hanzo-engine/src/license.rs: Ed25519 verify core via ed25519-dalek.
  Token = base64url(JSON claims)"."base64url(ed25519 sig[64]); sig is over the
  encoded payload bytes so verify never re-canonicalizes JSON. Claims
  {v,app_id,holder,iat,exp,features,nonce}. verify_license / load_and_verify
  with distinct errors Missing/Malformed/BadSig/Expired/NotYetValid/WrongApp.
  Embedded HANZO_LICENSE_PUBKEY is a DEV key (clearly marked; prod pubkey from
  KMS swapped in at release). expected_app fixed per build via cargo features
  license-app-hanzo/lux/zoo (default "hanzo-dev"). 9 unit tests.
- hanzo-engine/examples/license_issuer.rs: mints signed per-app tokens; private
  key from --signing-key-file / HANZO_LICENSE_SIGNING_KEY, never hardcoded;
  self-checks the freshly minted token.
- Gate (cargo feature license-enforce, OFF by default):
  hanzo-cli/src/commands/serve.rs top of run_server (exit 78 on failure) and
  hanzo-server-core/src/hanzo_for_server_builder.rs top of build() (returns
  Err). No-op note when the feature is off.
- workspace + engine dep: ed25519-dalek 2.1.1. license-dev-key/ holds the
  committed public key + README; the private seed is gitignored.

Verified:
- cargo test -p hanzo-engine --no-default-features license -> 9 passed.
- cargo check -p hanzo-cli --no-default-features --features license-enforce,license-app-hanzo -> clean.
- cargo build -p hanzo-engine --example license_issuer -> builds; mints a token
  that decodes to the exact claim schema and self-verifies.

Co-authored-by: Antje Worring <[email protected]>
Co-authored-by: Claude Opus 4.8 <[email protected]>
zeekay pushed a commit that referenced this pull request Jul 26, 2026
…ver engine#19) (#21)

Engine-side license verification: the proprietary engine refuses to serve
unless handed a valid, unexpired, correctly-scoped Hanzo-issued Ed25519 token
for the right app.

Recovers the actual feature from #19 (a 430k-line fork-sync blob) onto current
main as a focused ~5-file change. No fork-sync noise (route renames, ROCM
defaults) is dragged in.

- hanzo-engine/src/license.rs: Ed25519 verify core via ed25519-dalek.
  Token = base64url(JSON claims)"."base64url(ed25519 sig[64]); sig is over the
  encoded payload bytes so verify never re-canonicalizes JSON. Claims
  {v,app_id,holder,iat,exp,features,nonce}. verify_license / load_and_verify
  with distinct errors Missing/Malformed/BadSig/Expired/NotYetValid/WrongApp.
  Embedded HANZO_LICENSE_PUBKEY is a DEV key (clearly marked; prod pubkey from
  KMS swapped in at release). expected_app fixed per build via cargo features
  license-app-hanzo/lux/zoo (default "hanzo-dev"). 9 unit tests.
- hanzo-engine/examples/license_issuer.rs: mints signed per-app tokens; private
  key from --signing-key-file / HANZO_LICENSE_SIGNING_KEY, never hardcoded;
  self-checks the freshly minted token.
- Gate (cargo feature license-enforce, OFF by default):
  hanzo-cli/src/commands/serve.rs top of run_server (exit 78 on failure) and
  hanzo-server-core/src/hanzo_for_server_builder.rs top of build() (returns
  Err). No-op note when the feature is off.
- workspace + engine dep: ed25519-dalek 2.1.1. license-dev-key/ holds the
  committed public key + README; the private seed is gitignored.

Verified:
- cargo test -p hanzo-engine --no-default-features license -> 9 passed.
- cargo check -p hanzo-cli --no-default-features --features license-enforce,license-app-hanzo -> clean.
- cargo build -p hanzo-engine --example license_issuer -> builds; mints a token
  that decodes to the exact claim schema and self-verifies.

Co-authored-by: Antje Worring <[email protected]>
Co-authored-by: Hanzo Dev <[email protected]>
zeekay pushed a commit that referenced this pull request Jul 26, 2026
…ver engine#19) (#21)

Engine-side license verification: the proprietary engine refuses to serve
unless handed a valid, unexpired, correctly-scoped Hanzo-issued Ed25519 token
for the right app.

Recovers the actual feature from #19 (a 430k-line fork-sync blob) onto current
main as a focused ~5-file change. No fork-sync noise (route renames, ROCM
defaults) is dragged in.

- hanzo-engine/src/license.rs: Ed25519 verify core via ed25519-dalek.
  Token = base64url(JSON claims)"."base64url(ed25519 sig[64]); sig is over the
  encoded payload bytes so verify never re-canonicalizes JSON. Claims
  {v,app_id,holder,iat,exp,features,nonce}. verify_license / load_and_verify
  with distinct errors Missing/Malformed/BadSig/Expired/NotYetValid/WrongApp.
  Embedded HANZO_LICENSE_PUBKEY is a DEV key (clearly marked; prod pubkey from
  KMS swapped in at release). expected_app fixed per build via cargo features
  license-app-hanzo/lux/zoo (default "hanzo-dev"). 9 unit tests.
- hanzo-engine/examples/license_issuer.rs: mints signed per-app tokens; private
  key from --signing-key-file / HANZO_LICENSE_SIGNING_KEY, never hardcoded;
  self-checks the freshly minted token.
- Gate (cargo feature license-enforce, OFF by default):
  hanzo-cli/src/commands/serve.rs top of run_server (exit 78 on failure) and
  hanzo-server-core/src/hanzo_for_server_builder.rs top of build() (returns
  Err). No-op note when the feature is off.
- workspace + engine dep: ed25519-dalek 2.1.1. license-dev-key/ holds the
  committed public key + README; the private seed is gitignored.

Verified:
- cargo test -p hanzo-engine --no-default-features license -> 9 passed.
- cargo check -p hanzo-cli --no-default-features --features license-enforce,license-app-hanzo -> clean.
- cargo build -p hanzo-engine --example license_issuer -> builds; mints a token
  that decodes to the exact claim schema and self-verifies.

Co-authored-by: Antje Worring <[email protected]>
Co-authored-by: Hanzo Dev <[email protected]>
hanzo-dev pushed a commit that referenced this pull request Jul 27, 2026
…ver engine#19) (#21)

Engine-side license verification: the proprietary engine refuses to serve
unless handed a valid, unexpired, correctly-scoped Hanzo-issued Ed25519 token
for the right app.

Recovers the actual feature from #19 (a 430k-line fork-sync blob) onto current
main as a focused ~5-file change. No fork-sync noise (route renames, ROCM
defaults) is dragged in.

- hanzo-engine/src/license.rs: Ed25519 verify core via ed25519-dalek.
  Token = base64url(JSON claims)"."base64url(ed25519 sig[64]); sig is over the
  encoded payload bytes so verify never re-canonicalizes JSON. Claims
  {v,app_id,holder,iat,exp,features,nonce}. verify_license / load_and_verify
  with distinct errors Missing/Malformed/BadSig/Expired/NotYetValid/WrongApp.
  Embedded HANZO_LICENSE_PUBKEY is a DEV key (clearly marked; prod pubkey from
  KMS swapped in at release). expected_app fixed per build via cargo features
  license-app-hanzo/lux/zoo (default "hanzo-dev"). 9 unit tests.
- hanzo-engine/examples/license_issuer.rs: mints signed per-app tokens; private
  key from --signing-key-file / HANZO_LICENSE_SIGNING_KEY, never hardcoded;
  self-checks the freshly minted token.
- Gate (cargo feature license-enforce, OFF by default):
  hanzo-cli/src/commands/serve.rs top of run_server (exit 78 on failure) and
  hanzo-server-core/src/hanzo_for_server_builder.rs top of build() (returns
  Err). No-op note when the feature is off.
- workspace + engine dep: ed25519-dalek 2.1.1. license-dev-key/ holds the
  committed public key + README; the private seed is gitignored.

Verified:
- cargo test -p hanzo-engine --no-default-features license -> 9 passed.
- cargo check -p hanzo-cli --no-default-features --features license-enforce,license-app-hanzo -> clean.
- cargo build -p hanzo-engine --example license_issuer -> builds; mints a token
  that decodes to the exact claim schema and self-verifies.

Co-authored-by: Antje Worring <[email protected]>
zeekay pushed a commit that referenced this pull request Sep 15, 2026
…ver engine#19) (#21)

Engine-side license verification: the proprietary engine refuses to serve
unless handed a valid, unexpired, correctly-scoped Hanzo-issued Ed25519 token
for the right app.

Recovers the actual feature from #19 (a 430k-line fork-sync blob) onto current
main as a focused ~5-file change. No fork-sync noise (route renames, ROCM
defaults) is dragged in.

- hanzo-engine/src/license.rs: Ed25519 verify core via ed25519-dalek.
  Token = base64url(JSON claims)"."base64url(ed25519 sig[64]); sig is over the
  encoded payload bytes so verify never re-canonicalizes JSON. Claims
  {v,app_id,holder,iat,exp,features,nonce}. verify_license / load_and_verify
  with distinct errors Missing/Malformed/BadSig/Expired/NotYetValid/WrongApp.
  Embedded HANZO_LICENSE_PUBKEY is a DEV key (clearly marked; prod pubkey from
  KMS swapped in at release). expected_app fixed per build via cargo features
  license-app-hanzo/lux/zoo (default "hanzo-dev"). 9 unit tests.
- hanzo-engine/examples/license_issuer.rs: mints signed per-app tokens; private
  key from --signing-key-file / HANZO_LICENSE_SIGNING_KEY, never hardcoded;
  self-checks the freshly minted token.
- Gate (cargo feature license-enforce, OFF by default):
  hanzo-cli/src/commands/serve.rs top of run_server (exit 78 on failure) and
  hanzo-server-core/src/hanzo_for_server_builder.rs top of build() (returns
  Err). No-op note when the feature is off.
- workspace + engine dep: ed25519-dalek 2.1.1. license-dev-key/ holds the
  committed public key + README; the private seed is gitignored.

Verified:
- cargo test -p hanzo-engine --no-default-features license -> 9 passed.
- cargo check -p hanzo-cli --no-default-features --features license-enforce,license-app-hanzo -> clean.
- cargo build -p hanzo-engine --example license_issuer -> builds; mints a token
  that decodes to the exact claim schema and self-verifies.

Co-authored-by: Antje Worring <[email protected]>

Co-authored-by: Hanzo Dev <[email protected]>
zeekay pushed a commit that referenced this pull request Sep 15, 2026
…ver engine#19) (#21)

Engine-side license verification: the proprietary engine refuses to serve
unless handed a valid, unexpired, correctly-scoped Hanzo-issued Ed25519 token
for the right app.

Recovers the actual feature from #19 (a 430k-line fork-sync blob) onto current
main as a focused ~5-file change. No fork-sync noise (route renames, ROCM
defaults) is dragged in.

- hanzo-engine/src/license.rs: Ed25519 verify core via ed25519-dalek.
  Token = base64url(JSON claims)"."base64url(ed25519 sig[64]); sig is over the
  encoded payload bytes so verify never re-canonicalizes JSON. Claims
  {v,app_id,holder,iat,exp,features,nonce}. verify_license / load_and_verify
  with distinct errors Missing/Malformed/BadSig/Expired/NotYetValid/WrongApp.
  Embedded HANZO_LICENSE_PUBKEY is a DEV key (clearly marked; prod pubkey from
  KMS swapped in at release). expected_app fixed per build via cargo features
  license-app-hanzo/lux/zoo (default "hanzo-dev"). 9 unit tests.
- hanzo-engine/examples/license_issuer.rs: mints signed per-app tokens; private
  key from --signing-key-file / HANZO_LICENSE_SIGNING_KEY, never hardcoded;
  self-checks the freshly minted token.
- Gate (cargo feature license-enforce, OFF by default):
  hanzo-cli/src/commands/serve.rs top of run_server (exit 78 on failure) and
  hanzo-server-core/src/hanzo_for_server_builder.rs top of build() (returns
  Err). No-op note when the feature is off.
- workspace + engine dep: ed25519-dalek 2.1.1. license-dev-key/ holds the
  committed public key + README; the private seed is gitignored.

Verified:
- cargo test -p hanzo-engine --no-default-features license -> 9 passed.
- cargo check -p hanzo-cli --no-default-features --features license-enforce,license-app-hanzo -> clean.
- cargo build -p hanzo-engine --example license_issuer -> builds; mints a token
  that decodes to the exact claim schema and self-verifies.

Co-authored-by: Antje Worring <[email protected]>

Co-authored-by: Hanzo Dev <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants