user6316: A user provides me with his wallet pub key as BultinByteString (or Haskell string, fine either way). From that, I need to get the PubKeyHash, but I am not sure how to hash it or if I need to hash it at all.
Then, I need to use it in the PubKeyHash in Ledger.Constraints.MustBeSignedBy in my state machine. Kinda like that:
Constraints.mustBeSignedBy "35dedd2982a03cf39e7dce03c839994ffdec2ec6b04f1cf2d40e61a3"

or
Constraints.mustBeSignedBy PubKeyHash { getPubKeyHash = "35dedd2982a03cf39e7dce03c839994ffdec2ec6b04f1cf2d40e61a3" }

The problem is when I put some PubKeyHash in the constraint (like above), the compiler spits out 5000 long error starting with:
GHC Core to PLC plugin: E042:Error: Unsupported feature: Use of fromString on type other than builtin strings or bytestrings: Plutus.V1.Ledger.Crypto.PubKeyHash
Context: Compiling expr: Data.String.fromString
                           @ Plutus.V1.Ledger.Crypto.PubKeyHash
                           Plutus.V1.Ledger.Crypto.$fIsStringPubKeyHash
                           (GHC.CString.unpackCString#
                              "a2c20c77887ace1cd986193e4e75babd8993cfd56995cd5cfce609c2"#)

Can the string be translated into the PubKeyHash? Can it be somehow fixed? Is it me, or is it a Plutus bug?
Edit:
Tried new code:
Constraints.mustBeSignedBy $ pubKeyHash (PubKey {
                            getPubKey = LedgerBytes { 
                                    getLedgerBytes = "35dedd2982a03cf39e7dce03c839994ffdec2ec6b04f1cf2d40e61a3" 
                                }
                        })

Got new error:
 GHC Core to PLC plugin: E042:Error: Unsupported feature: Type constructor: GHC.Prim.Char#
Context: Compiling type: GHC.Prim.Char#
Context: Compiling data constructor type: GHC.Types.C#
Context: Compiling type: GHC.Types.Char
Context: Compiling type: GHC.Base.String
Context: Compiling type: GHC.Base.String
                         -> Plutus.V1.Ledger.Bytes.LedgerBytes
Context: Compiling definition of: Plutus.V1.Ledger.Bytes.$fIsStringLedgerBytes_$cfromString
Context: Compiling expr: Plutus.V1.Ledger.Bytes.$fIsStringLedgerBytes_$cfromString
Context: Compiling expr: Plutus.V1.Ledger.Bytes.$fIsStringLedgerBytes_$cfromString
...


user6113: It's an issue with Plutus core. Even though PubKeyHash is part of IsString type class, we can't use OverloadedStrings mechanism in on-chain code for certain types. Basically, the problem is this:

Unfortunately, due to the technical reasons plutus plugin doesn't
support OverloadedStrings with newtypes.

Please, check this issue.
https://github.com/input-output-hk/plutus/issues/4404
Same thing apply for PubKeyHash and LedgerBytes.
A solution might be to have a parameterized validator script with PubKeyHash. This way, you can build PubkeyHash offchain using OverloadedStrings and pass it to the validator.

6316: <p>A user provides me with his wallet pub key as BultinByteString (or Haskell string, fine either way). From that, I need to get the PubKeyHash, but I am not sure how to hash it or if I need to hash it at all.</p>
<p>Then, I need to use it in the PubKeyHash in Ledger.Constraints.MustBeSignedBy in my state machine. Kinda like that:</p>
<pre><code>Constraints.mustBeSignedBy &quot;35dedd2982a03cf39e7dce03c839994ffdec2ec6b04f1cf2d40e61a3&quot;
</code></pre>
<p>or</p>
<pre><code>Constraints.mustBeSignedBy PubKeyHash { getPubKeyHash = &quot;35dedd2982a03cf39e7dce03c839994ffdec2ec6b04f1cf2d40e61a3&quot; }
</code></pre>
<p>The problem is when I put some PubKeyHash in the constraint (like above), the compiler spits out 5000 long error starting with:</p>
<pre><code>GHC Core to PLC plugin: E042:Error: Unsupported feature: Use of fromString on type other than builtin strings or bytestrings: Plutus.V1.Ledger.Crypto.PubKeyHash
Context: Compiling expr: Data.String.fromString
                           @ Plutus.V1.Ledger.Crypto.PubKeyHash
                           Plutus.V1.Ledger.Crypto.$fIsStringPubKeyHash
                           (GHC.CString.unpackCString#
                              &quot;a2c20c77887ace1cd986193e4e75babd8993cfd56995cd5cfce609c2&quot;#)
</code></pre>
<p>Can the string be translated into the PubKeyHash? Can it be somehow fixed? Is it me, or is it a Plutus bug?</p>
<p><em>Edit:</em></p>
<p>Tried new code:</p>
<pre><code>Constraints.mustBeSignedBy $ pubKeyHash (PubKey {
                            getPubKey = LedgerBytes { 
                                    getLedgerBytes = &quot;35dedd2982a03cf39e7dce03c839994ffdec2ec6b04f1cf2d40e61a3&quot; 
                                }
                        })
</code></pre>
<p>Got new error:</p>
<pre><code> GHC Core to PLC plugin: E042:Error: Unsupported feature: Type constructor: GHC.Prim.Char#
Context: Compiling type: GHC.Prim.Char#
Context: Compiling data constructor type: GHC.Types.C#
Context: Compiling type: GHC.Types.Char
Context: Compiling type: GHC.Base.String
Context: Compiling type: GHC.Base.String
                         -&gt; Plutus.V1.Ledger.Bytes.LedgerBytes
Context: Compiling definition of: Plutus.V1.Ledger.Bytes.$fIsStringLedgerBytes_$cfromString
Context: Compiling expr: Plutus.V1.Ledger.Bytes.$fIsStringLedgerBytes_$cfromString
Context: Compiling expr: Plutus.V1.Ledger.Bytes.$fIsStringLedgerBytes_$cfromString
...
</code></pre>
 6113: <p>It's an issue with Plutus core. Even though <strong>PubKeyHash</strong> is part of <strong>IsString</strong> type class, we can't use OverloadedStrings mechanism in on-chain code for certain types. Basically, the problem is this:</p>
<blockquote>
<p>Unfortunately, due to the technical reasons plutus plugin doesn't
support OverloadedStrings with newtypes.</p>
</blockquote>
<p>Please, check this issue.</p>
<p><a href="https://github.com/input-output-hk/plutus/issues/4404" rel="nofollow noreferrer">https://github.com/input-output-hk/plutus/issues/4404</a></p>
<p>Same thing apply for <code>PubKeyHash</code> and <code>LedgerBytes</code>.</p>
<p>A solution might be to have a parameterized validator script with <code>PubKeyHash</code>. This way, you can build <code>PubkeyHash</code> offchain using <strong>OverloadedStrings</strong> and pass it to the validator.</p>
