I’m looking for a pay-to-nft locking scheme that is secure and fits within cashtoken commitment (40 bytes); For my use I need it to require no more than 32 bytes so I have some bytes left for other states. (So directly storing 32 byte token ID + 8 bytes for commitment is not an option)
I’m specifically looking for one that is secured by any token ID with any commitment. Use case would for example allow a Cauldron pool or Moria loan to be owned by the holder of a specific Bliss ticket or Guru NFT.
First thing that came to mind was something like:
contract P2NFTH(bytes nfthash) {
function unlock() {
require(nfthash == hash256(
tx.inputs[0].tokenCategory
+ tx.inputs[0].nftCommitment));
}
}
However, this this is less secure than P2PKH
P2PKH Security:
- Lock: HASH160(pubkey) (20 bytes).
- Security: 160-bit preimage resistance (2^160 to find a pubkey) + 128-bit ECDSA signature security (2^128 to forge).
- Effective: Layered defense; signature is the practical barrier.
P2NFTH (neither token ID nor commitment fixed):
- Lock: SHA256d(nft-token-id || nft commitment) (32 bytes).
- Security: 128-bit collision resistance (2^128 to grind both components).
- Effective: Single-layer hash; weaker than P2PKH’s combined security.
Summary: P2PKH is stronger overall due to its dual-layer protection (hash + signature) vs. P2NFTH’s single-layer 128-bit collision resistance.
So my question would be two-fold:
- Is this P2NFTH good enough; considering that P2SH32 itself is considered secure?
- Are there any alternatives to that are alternative means to achieve the same with better security?
Notable related scheme:
@bitcoincashautist suggested a pay-to-nft lock that optimizes for input size, but does not include NFT commitment.
https://x.com/bchautist/status/1746882045312114788