user6023: In HW 2 of Week 5, we need to write a script that mints a token with empty ByteString.  The minting policy code on the on-chain part (mkPolicy) could ensure that the token name is empty by defining
    checkMintedAmount :: Bool
    checkMintedAmount = case flattenValue (txInfoMint info) of
      [(_, tn, amt)] -> tn == (TokenName emptyByteString) && amt == 1
      _              -> False

I claim that that the weaker constraint
    checkMintedAmount :: Bool
    checkMintedAmount = case flattenValue (txInfoMint info) of
      [(_, _, amt)] -> amt == 1
      _             -> False

is good enough, since the off-chain part of the code will make sure that the token name is the empty string.  I ran the experiment and it seems to work.
Generalizing, it seems that the constraints on the on-chain script can be less stringent than the off-chain constraints if the transaction is going to be initiated by the wallet that owns the UTxO where the script resides.  Is this claim correct?

user565: This question was answered by Lars during the Q&A.
In summary, you can't rely on an attacker using your offchain code. An attacker could write their own off chain code that uses a non empty Token name.
Perhaps if you are sure that you are the only person able to use the minting policy (eg you check that the transaction is signed by a specific user), you could make such assumptions.

6023: <p>In HW 2 of Week 5, we need to write a script that mints a token with empty ByteString.  The minting policy code on the on-chain part (<code>mkPolicy</code>) could ensure that the token name is empty by defining</p>
<pre><code>    checkMintedAmount :: Bool
    checkMintedAmount = case flattenValue (txInfoMint info) of
      [(_, tn, amt)] -&gt; tn == (TokenName emptyByteString) &amp;&amp; amt == 1
      _              -&gt; False
</code></pre>
<p>I claim that that the weaker constraint</p>
<pre><code>    checkMintedAmount :: Bool
    checkMintedAmount = case flattenValue (txInfoMint info) of
      [(_, _, amt)] -&gt; amt == 1
      _             -&gt; False
</code></pre>
<p>is good enough, since the off-chain part of the code will make sure that the token name is the empty string.  I ran the experiment and it seems to work.</p>
<p>Generalizing, it seems that the constraints on the on-chain script can be less stringent than the off-chain constraints if the transaction is going to be initiated by the wallet that owns the UTxO where the script resides.  Is this claim correct?</p>
 565: <p>This question was answered by Lars during the Q&amp;A.</p>
<p>In summary, you can't rely on an attacker using your offchain code. An attacker could write their own off chain code that uses a non empty Token name.</p>
<p>Perhaps if you are sure that you are the only person able to use the minting policy (eg you check that the transaction is signed by a specific user), you could make such assumptions.</p>
