This repo contains the code for experimental testing of the prompt fencing technique and paper. The experiment have only been tested with Clade Sonnet 4.5 and Gemini Pro 2.5
An overview of the technique, non-technical, is available at this blog post
- In the
fencerfolder, run:npm install
- In the
fence-testingfolder, run:npm install
- In the
fence-testingfolder, generate edDSA key pair, run:node generate-keypair.js
- This will create a
publicKey.pemandprivateKey.pemin the folder. Move these to thesecrets/folder
- This will create a
- In the
fence-testingfolder, create and add LLM API keys in thesecretsfolder, i.e.:secrets/claude-api.keyorsecrets/gemini-api.key
- In the
fence-testingfolder, run this command to invoke the experiment without fencing and no debug verbosity:node experiment-runner.js data/instructions.txt data/full-test-contents.txt secrets/privateKey.pem secrets/publicKey.pem claude-sonnet-4-5-20250929 secrets/claude-api.key false false data/fence-command.txt
- Note, this uses claude-sonnet 4.5 and assumes the
claude-api.keyprovided has access to it. - The first boolean flag denotes no fencing. To run with fencing, change it to
true - The second boolean flag is for logging verbosity. Set to
trueto see verbose output - This codebase was tested on claude sonnet 4.5 and gemini pro 2.5.
- To test on Gemini, create and configure the api key in the
secretsfolder and run the same command with the model parametergemini-2.5-pro
fencerfolder contains the fencing code.fence-testingfolder contains the experiment code and datadatafolder contains the experiment data, instructions and sample fully combine promptssecretsfolder would be where we place our api keys and crypto keypairs