Newshot

Make your LLM accept only signed prompts

Original text(via HN AI)

A couple weeks ago, some genius had the idea of integrating a RISC-V processor into a local LLM model. Other people quickly modify the idea to do totally pointless but awesome things.

While my mind was blown by the idea, I feel like this could have practical real world use. I am not particular creative, so my idea is can we integrate a security processor into a LLM?

https://github.com/moonlightelite/secproc

https://huggingface.co/timlauHF/Qwen3.5-4B-signed-input-demo

Problems with LLM input

Current LLM has a huge problem- there is no verification for its input and its output. A LLM, without external guardrails and steering, would happily accept any input and work on it.

Imagine a pipeline with a different LLM at each stage. The system could be a serialization of tasks. Each stage depends on the output from the previous stage. For example, the might be a chatbot that interacts with the customer, and generates a set of advertising campaign material such as image, video, and audio. In this pipeline, you would need a text LLM for the chatbot, an intention extractor LLM from the chat log, an ad campaign planner LLM (with an assortment of tools it can call to gather data from), and domain specific multimedia LLMs that might specialize in image, video or audio creative generation.

The LLM in each stage of the pipeline would accept text input, transform it, then hand the output to the next stage of the pipeline, without any verification.

What if the message is tampered with during transit? What if someone tries to do a prompt injection to the input?

The problem is the provenance of the input. How do we prove that the input prompt is from the intended sender, and that the prompt has not been tampered with.

Signing a input prompt

Everyone knows what a cryptographic signature is, but I have not seen anyone combining it with LLM. May I present you on something I cooked up in Claude over a weekend-

https://github.com/moonlightelite/secproc

# secproc: an Ed25519 verifier inside an LLM’s weightssecproc makes a language model refuse to act on any message that does not carry a valid Ed25519 signature from a trusted key. Ed25519 is a public-key signature scheme. The sender signs with asecret key, and anyone with the matching public key can check the signature.The check does not live in a prompt, a system message or a wrapper around the model. Instead, a small CPU is compiled into the model’s weights, and the model’s layers simulate it. It is a RISC-V CPU (RISC-V is an open standard for CPU instructions). This CPU runs a real signature verifier: Monocypher’s Ed25519, set to the strict form of the Ed25519 standard, RFC 8032. (Monocypher is a small C cryptography library.) A decider, also built into the weights, decides what the model may say next. It can force the output to a refusal.The model reads its input as tokens (small pieces of text, each with a number ID). The signed part of the input is called the signed region. It sits between two marker tokens. The result is either signature valid→prompt is processed or signature invalid→prompt is discarded.

secproc: an Ed25519 verifier inside an LLM’s weights

secproc makes a language model refuse to act on any message that does not carry a valid Ed25519 signature from a trusted key. Ed25519 is a public-key signature scheme. The sender signs with asecret key, and anyone with the matching public key can check the signature.

The check does not live in a prompt, a system message or a wrapper around the model. Instead, a small CPU is compiled into the model’s weights, and the model’s layers simulate it. It is a RISC-V CPU (RISC-V is an open standard for CPU instructions). This CPU runs a real signature verifier: Monocypher’s Ed25519, set to the strict form of the Ed25519 standard, RFC 8032. (Monocypher is a small C cryptography library.) A decider, also built into the weights, decides what the model may say next. It can force the output to a refusal.

The model reads its input as tokens (small pieces of text, each with a number ID). The signed part of the input is called the signed region. It sits between two marker tokens. The result is either signature valid→prompt is processed or signature invalid→prompt is discarded.

What you need to run

https://github.com/moonlightelite/secproc/blob/main/docs/quickstart.md

  • The Ed25519 verifier integrated Qwen 3.5 LLM from Hugging Face
  • A patched version of llama.cpp to allow loading of the RISC-V firmware into the LLM
  • (Optional) A CUDA-supported GPU, but I also managed to run the stack on a Apple M1 and a normal 12-cores X86 CPU. Prepare to wait a while though for the computation to complete.

The secproc prototype has 2 modes- a stub mode and a real Ed25519 mode.

  • The stub file is the test version. It checks a short checksum and not a real signature, so it is not secure. It finishes in about a minute, even on a CPU.
  • The Ed25519 file checks a real Ed25519 signature. That is a stream of 6.3 million tokens. It takes about 2 minutes on a fast NVIDIA GPU, about 3 hours on a Mac, and hours on a CPU.

Performance

Time to check one real Ed25519 signature (a stream of 6.3 million tokens):

  • NVIDIA RTX PRO 6000 (PCIe x16), both files on the GPUAbout 2 minutes (119 to 127 s, about 50,000 tokens/s) 22.5 GiB of VRAM usage

NVIDIA RTX PRO 6000 (PCIe x16), both files on the GPU

  • About 2 minutes (119 to 127 s, about 50,000 tokens/s)
  • 22.5 GiB of VRAM usage
  • Apple M1 Pro, 32 GB, everything on Metal About 3 hours (projected, 555 tokens/s) 17.3 GiB

Apple M1 Pro, 32 GB, everything on Metal

  • About 3 hours (projected, 555 tokens/s)
  • Linux CPU, 12 cores, 12 threads About 3.7 hours (projected, 466 tokens/s)17.3 GiB

Linux CPU, 12 cores, 12 threads

  • About 3.7 hours (projected, 466 tokens/s)

The compact files are about 2 to 3 times faster than the full ones on every platform. A longer prompt adds only a little: each extra prompt token adds about 1,000 tokens to the 6.2 million. The Mac numbers vary a lot from run to run, because macOS background work shares the GPU.

Security Consideration

Since the public key is within the LLM, an attacker with access to the model file can extract the key from the LLM file. Once the attacker has the key, he can create his own forged LLM and integrate his key into the model.

This is doubly important if you plan on signing the output as well with a private key- again if the attacker has access to the model file, he can retrieve the private key from the model file.

This means that access to the model file itself should be guarded- at the very least, the hash of the LLM model file should be verified with a trusted authority before the user can trust the LLM. Also there is probably some consideration with timing attacks to use side channels to guess the private key.

For the prototype I decided to hardcode the public key into the model, however it is entirely possible to provide the public key during the model’s initialization. This would allow the model to change acceptable keys on the fly. At the same time, the LLM computation stack would become more complex, so I did not build this.

Final thoughts

I find the idea of integrating a security processor into a LLM to be very fascinating. Right now LLMs are just giant blobs of transformers that as long as you have the model file, you can use the LLM to do work for you. There is nothing that can provide the CIA Triad for both the user and the LLM. A security processor would go a long way to solve some of the security issues.

I liken the situation to a game console- as long as the attacker has access to the physical device, the attacker can do a lot. However, eventually people manage to tighten the security postures on game consoles, and it becomes harder and harder for attackers to gain access to the underlying hardware. Would LLM go the same route? Will one day a company will sell a proprietary LLM-in-a-box solution that would only accept signed inputs (after you pay the company for subscription) and output signed output? Let’s hope not.

The text above was extracted automatically from the source page and may miss images, tables or code blocks. The original is authoritative.

Published by HN AI
This site only summarises and aggregates; copyright stays with the original author. Headlines and summaries follow the source — where they differ, the original wins.
Read the original ↗