Your pseudocode is close, but not quite right. This is correct:.
bool pk_script(dat1, dat2, sig1, sig2) {
if (sha256(dat1) == hash1 &&
sha256(dat2) == hash2 &&
size(dat1) == 32 or 33 &&
size(dat2) == 32 or 33) {
return size(dat1) == size(dat2)
} else {
return checksig(sig1, pk1) && checksig(sig2, pk2);
}
}
BasicallyThe script has two parties involved in it is looking for. If either party has two hash preimages that match, they can sign for the provided hashestransaction and arespend the same lengthcoins. Or both parties can spend the coins if both of either 32 or 33 bytesthem sign for the transaction.
So presumably each party generates a secret value which is their hash preimage. If some condition is violated, or it needs two signatures that matchthen one party might be forced to give up their hash preimage to the provided two publicother party thus allowing the other party to spend all of the coins associated with the output.
But there could also be a cooperative spend where both of them sign for the transaction. This is actually similar to what the Lightning Network does for commitment transactions.
Instead of using this script, they could have done a 2-of-2 multisig and revealed the other person's private key just for the case with the revealed hash preimage. However this may not be ideal because revealing private keys could compromise other private keys.