user5031: I have a simple validator script that checks if a transaction is signed by a specific public key with the hash: 12f2f3e44e6e310abc78802d7078ec1fd0fa220ff47ad1bdb43397e2
{-# INLINABLE getHolder #-}
getHolder :: PubKeyHash
getHolder = PubKeyHash "12f2f3e44e6e310abc78802d7078ec1fd0fa220ff47ad1bdb43397e2"


{-# INLINABLE mkValidator #-}
mkValidator :: BuiltinData -> BuiltinData -> ScriptContext -> Bool
mkValidator _ _ ctx = txSignedBy (scriptContextTxInfo ctx) getHolder

The validator always fails when attempting to spend an output with the correct key using the CLI, --required-signer is being used. The transaction is never built.

I attempt to log the txInfoSignatories in the validator using the following code:
{-# INLINABLE mkValidator #-}
mkValidator :: BuiltinData -> BuiltinData -> ScriptContext -> Bool
mkValidator _ _ ctx = traceError $ decodeUtf8 $ getPubKeyHash $ P.head signatories
    where
        info :: TxInfo
        info = scriptContextTxInfo ctx

        signatories :: [PubKeyHash]
        signatories = txInfoSignatories info

Even though the decoding function throws an error, I still get the following:
The provided Plutus code called 'error'.
Caused by: [
  (builtin decodeUtf8)
  (con bytestring #12f2f3e44e6e310abc78802d7078ec1fd0fa220ff47ad1bdb43397e2)
]

Which shows that the correct key hash is in the script context, but the way the hash is constructed by the script context is clearly not the same as the one I've made and I'm not sure how to proceed.
Thanks!
EDIT: In fact, this happens to any validator I try to use that compares scriptContextTxInfo with any compile time input I give it. The bytestrings that I hardcode are never seen as equal to the bytestrings in scriptContextTxInfo. The validator traces leave me completely in the dark as my code seems to be identical to other examples that apparently work.

user5071: I've ran into similar issue. You can try to use fromHex function form Ledger.Bytes module, which will return the pubkeyhash as bytes representation.
This answer helped me with this.

5031: <p>I have a simple validator script that checks if a transaction is signed by a specific public key with the hash: <code>12f2f3e44e6e310abc78802d7078ec1fd0fa220ff47ad1bdb43397e2</code></p>
<pre><code>{-# INLINABLE getHolder #-}
getHolder :: PubKeyHash
getHolder = PubKeyHash &quot;12f2f3e44e6e310abc78802d7078ec1fd0fa220ff47ad1bdb43397e2&quot;


{-# INLINABLE mkValidator #-}
mkValidator :: BuiltinData -&gt; BuiltinData -&gt; ScriptContext -&gt; Bool
mkValidator _ _ ctx = txSignedBy (scriptContextTxInfo ctx) getHolder
</code></pre>
<p>The validator always fails when attempting to spend an output with the correct key using the CLI, <code>--required-signer</code> is being used. The transaction is never built.</p>
<hr />
<p>I attempt to log the txInfoSignatories in the validator using the following code:</p>
<pre><code>{-# INLINABLE mkValidator #-}
mkValidator :: BuiltinData -&gt; BuiltinData -&gt; ScriptContext -&gt; Bool
mkValidator _ _ ctx = traceError $ decodeUtf8 $ getPubKeyHash $ P.head signatories
    where
        info :: TxInfo
        info = scriptContextTxInfo ctx

        signatories :: [PubKeyHash]
        signatories = txInfoSignatories info
</code></pre>
<p>Even though the decoding function throws an error, I still get the following:</p>
<pre><code>The provided Plutus code called 'error'.
Caused by: [
  (builtin decodeUtf8)
  (con bytestring #12f2f3e44e6e310abc78802d7078ec1fd0fa220ff47ad1bdb43397e2)
]
</code></pre>
<p>Which shows that the correct key hash is in the script context, but the way the hash is constructed by the script context is clearly not the same as the one I've made and I'm not sure how to proceed.</p>
<p>Thanks!</p>
<p>EDIT: In fact, this happens to any validator I try to use that compares scriptContextTxInfo with any compile time input I give it. The bytestrings that I hardcode are never seen as equal to the bytestrings in scriptContextTxInfo. The validator traces leave me completely in the dark as my code seems to be identical to other examples that apparently work.</p>
 5071: <p>I've ran into similar issue. You can try to use <code>fromHex</code> function form <code>Ledger.Bytes</code> module, which will return the pubkeyhash as bytes representation.</p>
<p>This <a href="https://cardano.stackexchange.com/a/2579/5071">answer</a> helped me with this.</p>
