<p>They are the same. I'd say the <code>signedByBeneficiary</code> way is more idiomatic.</p>

CC BY-SA 4.0
2022-02-01T10:23:21.997Z
2022-02-01T10:23:21.997Z
Sjoerd Visscher
<p>Spoiler, so don't look if you haven't done the homework yet.</p>
<p>In the solution file Solution2.hs we have</p>
<pre><code>checkSig :: Bool
checkSig = unPaymentPubKeyHash pkh `elem` txInfoSignatories info
</code></pre>
<p>while in the file from the lecture Vesting.hs we have the same check implemented as</p>
<pre><code>signedByBeneficiary :: Bool
signedByBeneficiary = txSignedBy info $ unPaymentPubKeyHash $ beneficiary dat
</code></pre>
<p>I get the same behavior in the playground with the two implementations in Solution2.hs, and moreover looking at the implementation of txSignedBy</p>
<pre><code>{-# INLINABLE txSignedBy #-}
-- | Check if a transaction was signed by the given public key.
txSignedBy :: TxInfo -&gt; PubKeyHash -&gt; Bool
txSignedBy TxInfo{txInfoSignatories} k = case find ((==) k) txInfoSignatories of
    Just _  -&gt; True
    Nothing -&gt; False
</code></pre>
<p>I don't see a difference. Maybe my tests in the playground aren't good enough, but is there an example of different behavior?</p>

<plutus-pioneer-program>
Homework2.hs: checking that the beneficiary signed the transaction
# Homework2.hs: checking that the beneficiary signed the transaction

(Asked by: username_0 on 2022-02-01)

Spoiler, so don't look if you haven't done the homework yet.
In the solution file Solution2.hs we have
checkSig :: Bool
checkSig = unPaymentPubKeyHash pkh `elem` txInfoSignatories info

while in the file from the lecture Vesting.hs we have the same check implemented as
signedByBeneficiary :: Bool
signedByBeneficiary = txSignedBy info $ unPaymentPubKeyHash $ beneficiary dat

I get the same behavior in the playground with the two implementations in Solution2.hs, and moreover looking at the implementation of txSignedBy
{-# INLINABLE txSignedBy #-}
-- | Check if a transaction was signed by the given public key.
txSignedBy :: TxInfo -> PubKeyHash -> Bool
txSignedBy TxInfo{txInfoSignatories} k = case find ((==) k) txInfoSignatories of
    Just _  -> True
    Nothing -> False

I don't see a difference. Maybe my tests in the playground aren't good enough, but is there an example of different behavior?

**Tags:** plutus-pioneer-program

---

## 1 answers

### Answer by username_1 on 2022-02-01. Score: 1 | Accepted answer

They are the same. I'd say the `signedByBeneficiary` way is more idiomatic.


---

