> For the complete documentation index, see [llms.txt](https://hub.bsvblockchain.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hub.bsvblockchain.org/wiki/bitcoin-script-and-opcodes/script/op-codeseparator.md).

# OP CODESEPARATOR

OP\_CODESEPARATOR was originally designed to be inserted between the ScriptPubKey and ScriptSig by the script evaluation engine. When OP\_CHECKSIG is called in the ScriptPubKey, it will remove everything before OP\_CODESEPARATOR. In the default case, the entire ScriptSig will be removed as the ScriptSig containing the signature cannot be signed by the signature. There is no rule to prevent users from inserting OP\_CODESEPARATOR into the ScriptPubKey however OP\_CODESEPARATOR will only be effective if it is read by OP\_CHECKSIG in the same ScriptPubKey. OP\_CHECKSIG will read back to the closest OP\_CODESEPARATOR before it and remove all message contents before that.

1. Example Based on the understanding above, we can construct the following ScriptPubKey: `OP_CODESEPARATOR OP_CHECKSIGVERIFY OP_CODESEPARATOR OP_CHECKSIGVERIFY OP_CODESEPARATOR OP_CHECKSIG` To unlock this ScriptPubKey, we can use the following ScriptSig: Note that the first OP\_CHECKSIG will verify on the following message: `OP_CHECKSIGVERIFY OP_CODESEPARATOR OP_CHECKSIGVERIFY OP_CODESEPARATOR OP_CHECKSIG` The second OP\_CHECKSIG will verify on the following message: `OP_CHECKSIGVERIFY OP_CODESEPARATOR OP_CHECKSIG` i.e. the message hash used to create the signature excludes the first OP\_CHECKSIGVERIFY and the OP\_CODESEPARATOR inserted by the script evaluation engine. The third OP\_CHECKSIG will verify on the following message: `OP_CHECKSIG` i.e. the message hash used to create the signature excludes the first and second instances of OP\_CHECKSIGVERIFY and OP\_CODESEPARATOR. If someone changes the order of the signature in the ScriptSig, the verification of the signature will fail.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hub.bsvblockchain.org/wiki/bitcoin-script-and-opcodes/script/op-codeseparator.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
