Add the security gate that makes the proprietary engine refuse to run unless
it is handed a valid, unexpired, correctly-scoped Hanzo-issued license token,
per SECURE-ENGINE-DISTRIBUTION-DESIGN.md.
- hanzo-engine/src/license.rs: offline Ed25519 verify core (ed25519-dalek).
Token = base64url(JSON claims) "." base64url(sig[64]); the sig is over the
encoded-payload bytes so verify never re-canonicalizes JSON. Claims:
{v, app_id, holder, iat, exp, features, nonce}. verify_license() returns
distinct errors (Malformed/BadSig/Expired/WrongApp/NotYetValid); load_and_verify()
reads HANZO_ENGINE_LICENSE_TOKEN (or *_FILE) and checks the embedded pubkey +
build's expected_app + now. Embedded HANZO_LICENSE_PUBKEY is a DEV key (marked
for KMS swap at release). expected_app fixed per build via cargo features
license-app-{hanzo,lux,zoo} (default "hanzo-dev").
- Gate (cargo feature license-enforce, OFF by default): top of run_server
(hanzo-cli serve.rs) hard-exits on failure; HanzoForServerBuilder::build()
(hanzo-server-core) returns Err so every embedder (node/CLI/pyo3-via-server)
is gated. Dev builds skip with a one-line note.
- hanzo-engine/examples/license_issuer.rs: mints signed per-app tokens; private
key from --signing-key-file / HANZO_LICENSE_SIGNING_KEY, never hardcoded.
- Unit tests (9): valid, tampered-sig, tampered-payload, expired, wrong-app,
malformed, future-dated, wrong-version, dev-key==embedded-pubkey.
cargo test -p hanzo-engine --no-default-features license -> 9/9 pass.
- DEV private seed lives only in gitignored license-dev-key/; the public key
artifacts + regeneration README are committed.
Co-authored-by: Hanzo Dev <[email protected]>
1.6 KiB
License DEV signing key (development only)
This directory holds the development Ed25519 keypair used to mint and verify license tokens in
unit tests and via the license_issuer example. It is NOT the production key.
dev_signing_key.b64-- PRIVATE 32-byte Ed25519 seed, base64url (no padding). gitignored, never committed.dev_public_key.b64-- public verification key, base64url (committed, harmless).dev_public_key.rs.txt-- the same public key as a Rust[u8; 32]array literal; this is what is embedded asHANZO_LICENSE_PUBKEYinhanzo-engine/src/license.rs.
The matching PUBLIC key is the compile-time const HANZO_LICENSE_PUBKEY in
hanzo-engine/src/license.rs (clearly marked DEV KEY -- replace with prod pubkey from KMS for release).
Regenerating the private seed on a fresh clone
hanzo-engine/src/license.rs tests read dev_signing_key.b64. Because it is gitignored, a fresh
clone must recreate it before cargo test -p hanzo-engine license. The committed
dev_public_key.rs.txt pins the public half, so any regenerated seed MUST reproduce that pubkey --
i.e. you cannot just generate a fresh random key, you must use the seed below (kept out of git on
purpose; this is a throwaway dev value, never used for releases):
# Recreate the dev signing seed locally (throwaway dev value; matches the embedded pubkey const).
printf '%s\n' 'REDACTED-DEAD-DEV-SIGNING-SEED' > license-dev-key/dev_signing_key.b64
For a real release, generate a fresh keypair on a private host, store the private key in the KMS / CI
secret, and replace HANZO_LICENSE_PUBKEY with the new public key.