Flux supports Ed25519 digital signatures to ensure script integrity.
- Integrity: Detect if scripts have been modified
- Authentication: Verify scripts come from trusted source
- Production Safety: Prevent execution of unauthorized code
flux keygen --output ./keysThis creates:
keys/private.pem- Keep secret, used for signingkeys/public.pem- Distribute with app, used for verification
flux sign script.flux --key keys/private.pem --output script.signed.fluxflux verify script.signed.flux --key keys/public.pemconst publicKey = '''
-----BEGIN PUBLIC KEY-----
MCowBQYDK2VwAyEA...
-----END PUBLIC KEY-----
''';import 'package:flux_vm/flux_vm.dart';
final verifier = FluxScriptVerifier(publicKey: publicKey);
void runSignedScript(String signedContent) {
if (!verifier.verify(signedContent)) {
throw SecurityException('Script signature invalid');
}
// Extract script content (before signature)
final script = verifier.extractContent(signedContent);
final vm = VM();
vm.interpret(script);
}// Original script content
var x = 1;
print(x);
// --- FLUX SIGNATURE ---
// ed25519:ABC123...XYZ789
- Never commit private keys to version control
- Use environment variables or secrets manager
- Rotate keys periodically
- Use separate keys for development and production
// Create a sandboxed VM
final vm = VM();
// Don't register sensitive modules
// vm.registerModule(fileSystemModule); // DON'T
// Limit what scripts can access
vm.registerModule(safeModule);// Validate any values returned from Flux
final result = vm.getGlobal('userInput');
if (result is! String || result.length > 100) {
throw ValidationException('Invalid input');
}| Threat | Mitigation |
|---|---|
| Malicious script execution | Signature verification |
| Script tampering | Ed25519 signatures |
| Resource exhaustion | Execution timeouts (planned) |
| Sensitive data access | Module sandboxing |
| Feature | Debug | Production |
|---|---|---|
| Signature check | Optional | Required |
| Source maps | Included | Stripped |
| Debug symbols | Included | Stripped |
| .flx format | Optional | Recommended |