Skip to content

Resource encryption and keys

The resource key created in the publishing guide lets the server authenticate published releases. Remote resources require it even with encryption = false.

Enabling encryption also keeps the packaged file contents encrypted on the storage host and in the client’s resource cache. The client receives a derived decryption key from the game server and reads the files in memory. The original resources.key stays with the publisher and server.

The manifest remains readable and includes file paths, sizes and hashes. Content is accessible to the running client, so keep credentials and private server logic outside client resources.

Use the existing key and publishing configuration from Package and publish client resources. Update these sections in publish.toml:

[resources]
mode = "local"
path = "dist/resources-encrypted"
url = "https://cdn.example.com/resources/"
key_path = "resources.key"
[resources.pack]
path = "client"
compression = true
encryption = true

Keep the existing [publish] and [api] settings. The output path must be fresh when changing encryption. Reusing the previous unencrypted output produces an error. Encryption applies to all files in the package. Compression can stay enabled together with encryption.

From the publishing folder, run:

Terminal window
& "C:\Revo\resource-tool\resource-tool.exe" publish --config .\publish.toml

Check the published release through the CDN, then restart the game server. A server using mode = "remote" reads the encryption setting from the release. Its key_path must still point to the same key used by the publisher. Script imports and resources:// URLs stay the same.

To disable encryption later, set encryption = false and choose another fresh output path. Keep the resource key for release authentication.

File Location and purpose
resources.key Keep a private copy on the publishing machine and each game server that uses its releases. Back it up with deployment secrets.
<resources.path>/cache/package.json Keep it with the private packing cache. It contains the decryption key when encryption is enabled.

Keep both outside the client source folder and any public HTTP root. The publish command uploads the public release files and excludes the private packing cache.

You can use the same resource key for all subsequent uploads and releases. Run keygen again only when you intend to rotate the key.

keygen refuses to overwrite an existing file. Restoring a missing key requires the original backup if you need to use its earlier releases.

For local packing without key_path, an encryption key is generated and saved in the private packing cache. Preserve that cache between builds. The separate publishing workflow requires an explicit, persistent key_path.

Rotation changes both release authentication and the derived decryption key. Use a new output folder and a new storage prefix with a matching CDN URL. The publisher verifies the existing release before replacing it, so publishing with a different key to the old prefix fails authentication.

  1. Generate a new key from your publishing folder:

    Terminal window
    & "C:\Revo\resource-tool\resource-tool.exe" keygen --output resources-v2.key
  2. Copy the existing publishing configuration to publish-v2.toml and change:

    Setting Example value
    resources.key_path "resources-v2.key"
    resources.path "dist/resources-v2"
    resources.url "https://cdn.example.com/resources-v2/"
    publish.target "s3://revo-assets-example/resources-v2"

    Ensure the new prefix is empty and the CDN serves it with the same delivery and cache rules as the original prefix.

  3. Publish and verify the new release using the steps in the publishing guide:

    Terminal window
    & "C:\Revo\resource-tool\resource-tool.exe" publish --config .\publish-v2.toml
  4. Copy the new key securely to the game server. Update resources.key_path and resources.url together, then restart it. If resources.release is pinned, replace it with the new manifest hash or clear it.

Clients download the new encrypted payloads when they update their resources. Plan for this download when scheduling the change.

Keep the old key, publication prefix and server settings for as long as you need rollback access. To return to an earlier release after rotation, restore its URL, key and any pinned release hash together, then restart the server. The rollback command operates within the configured publication prefix.

Message Check
Resource release authentication failed The publisher and server must use the key that created the selected release. Check the CDN URL and any pinned release before replacing files.
Changing resource encryption requires a fresh resources.path or --output path Select a new packing output folder after changing encryption.
Changing the resource key requires a fresh resources.path or --output path Select a new packing output folder for the new key.
An existing resource package is missing its private packing cache Restore the matching cache backup or repack into a fresh output folder.