<p>I think PlutusTx.Builtins has what you need:</p>
<pre><code>{-# INLINABLE verifySignature #-}
-- | Verify that the signature is a signature of the message by the public key.
verifySignature :: BuiltinByteString -&gt; BuiltinByteString -&gt; BuiltinByteString -&gt; Bool
</code></pre>
<p>You can use verifySignature on-chain. If you do it on chain, then your signature and the PubKeyHash should be either some wrappers around <code>BuiltinByteString</code> or directly <code>BuiltinByteString</code>. Either way, there should be no problem getting the types needed for <code>verifySignature</code>.</p>

CC BY-SA 4.0
2021-12-07T19:24:40.787Z
2021-12-07T20:47:02.153Z
2021-12-07T20:47:02.153Z
Jey
<p>There is also an oracle for signature verification <a href="https://github.com/input-output-hk/plutus-apps/blob/804a84bd15074902cce9096ef98721675566c003/plutus-contract/src/Plutus/Contract/Oracle.hs?_pjax=%23js-repo-pjax-container%2C%20div%5Bitemtype%3D%22http%3A%2F%2Fschema.org%2FSoftwareSourceCode%22%5D%20main%2C%20%5Bdata-pjax-container%5D#L13" rel="nofollow noreferrer">here</a></p>

CC BY-SA 4.0
2021-12-08T11:40:59.947Z
2021-12-08T11:40:59.947Z
Stanislav Zhdanovich
<p>I am looking for a function with a type like this:</p>
<pre><code>verifySignature :: Datum -&gt; Signature -&gt; PubKey -&gt; Bool
</code></pre>
<p>which is also INLINABLE to use it inside validator.</p>
<p>I know that we can check if the whole transaction is signed by some pub key with this <a href="https://github.com/input-output-hk/plutus/blob/b778f9abbe172177b579badf83b899ee05fda2e0/plutus-ledger-api/src/Plutus/V1/Ledger/Contexts.hs#L233" rel="nofollow noreferrer">function</a>, but this should be an arbitrary message signature, not transaction signature.</p>

CC BY-SA 4.0
2021-12-07T13:36:32.933Z
N.B. I want to store signed proof off-chain, so putting this Datum inside some output and singing it is not an option
Stanislav Zhdanovich
<plutus><validator>
Can we check signatures of arbitrary data in plutus validators?
# Can we check signatures of arbitrary data in plutus validators?

(Asked by: username_0 on 2021-12-07)

I am looking for a function with a type like this:
verifySignature :: Datum -> Signature -> PubKey -> Bool

which is also INLINABLE to use it inside validator.
I know that we can check if the whole transaction is signed by some pub key with this function, but this should be an arbitrary message signature, not transaction signature.

**Tags:** plutus, validator
> **Comments:**
> **username_0**: N.B. I want to store signed proof off-chain, so putting this Datum inside some output and singing it is not an option  

---

## 2 answers

### Answer by username_1 on 2021-12-07. Score: 4 | Accepted answer

I think PlutusTx.Builtins has what you need:
{-# INLINABLE verifySignature #-}
-- | Verify that the signature is a signature of the message by the public key.
verifySignature :: BuiltinByteString -> BuiltinByteString -> BuiltinByteString -> Bool

You can use verifySignature on-chain. If you do it on chain, then your signature and the PubKeyHash should be either some wrappers around BuiltinByteString or directly BuiltinByteString. Either way, there should be no problem getting the types needed for verifySignature.


---

### Answer by username_0 on 2021-12-08. Score: 3

There is also an oracle for signature verification [here](https://github.com/input-output-hk/plutus-apps/blob/804a84bd15074902cce9096ef98721675566c003/plutus-contract/src/Plutus/Contract/Oracle.hs?_pjax=%23js-repo-pjax-container%2C%20div%5Bitemtype%3D%22http%3A%2F%2Fschema.org%2FSoftwareSourceCode%22%5D%20main%2C%20%5Bdata-pjax-container%5D#L13)


---

