-
Notifications
You must be signed in to change notification settings - Fork 1
Description
π Is your feature request related to a specific issue?
Currently, the Mortar compiler outputs dialogue scripts as plain-text JSON.
For narrative-driven games using external scripting languages, this poses a significant risk: players can easily open script files to read spoilers, plot twists, or datamine hidden mechanics. Narrative designers often need a way to "seal" their logic and text to protect the player experience.
Furthermore, while protection is necessary, we must also support authorized third-party access, such as localization teams. There needs to be a mechanism where the original author can securely provide a key/method for translators to decode and edit the scripts without exposing the raw source to the general public.
π‘ Feature Description
Implement a native encryption and binary compilation pipeline within the Mortar CLI and Runtime.
1. Binary Compilation Target (.mb)
- Extend the compiler to support a binary serialization format (e.g., Bincode) instead of standard JSON.
- This provides immediate performance benefits (smaller size, faster parsing) and basic obfuscation against casual text editors.
2. "Sealing" (Encryption) with Keys
- Add a
--sealor--encryptflag to the CLI, accepting a user-defined key. - The compiler should obfuscate/encrypt the output using this key (e.g., XOR with a magic header).
- Localization Support: Provide a corresponding
--decryptor--unlockcommand in the CLI. If a translator is given the correct key by the author, they can convert the binary back to editable source/JSON, perform translations, and re-compile.
3. Runtime Support
- Update the
mortarruntime library to handle encrypted streams. - The
loadfunction should accept an optional key parameter to decode assets on the fly.
β Alternatives Considered
1. Relying on Host Engine Encryption:
- Most generic game engines (or custom frameworks) require complex asset packing plugins to handle encryption.
- By handling this at the language compiler level, Mortar provides "out-of-the-box" protection regardless of whether the host engine is Bevy, Unity, Godot, or a custom framework.
2. Plain Text JSON:
- Leaving scripts as JSON makes the narrative extremely vulnerable to datamining, which is unacceptable for story-heavy commercial or fan projects.
π Additional Information
Proposed Workflow:
# Author builds the game:
mortar build main.mortar --format binary --seal --key "secret-key-123"
# Runtime loading (in Rust):
let script = Mortar::load_bytes(data, Some("secret-key-123"));
# Localization Workflow:
# Author sends the encrypted file and key to the translator.
# Translator runs:
mortar tool decrypt main.mb --key "secret-key-123" --out main_translated.mortar