Author

Topic: Why are pubkeys used in HTLCs instead of pubkey hashes? (Read 122 times)

sr. member
Activity: 257
Merit: 343
Wow, I'm an idiot.
that doesn't make you an idiot - au contraire, mon ami!  Cheesy Wink
With a P2PKH you have roughly 227 bytes per tx, but when you use the full public key (compressed or uncompressed), it get's a bit longer. A good summary was here: https://bitcoin.stackexchange.com/questions/1195/how-to-calculate-transaction-size-before-sending-legacy-non-segwit-p2pkh-p2sh
And yes, multisig and CSV/CLTV or any smart contracts increase the size. And then of course segwit, decreasing size :-)
member
Activity: 98
Merit: 26
Wow, I'm an idiot.

Happens to all of us. As I was falling asleep last night, I realized that I've been consistently thinking that the private key space for secp256k1 is 2129 when it is actually 2256-2129, a vastly larger number, close to 2255. Duh.
newbie
Activity: 13
Merit: 4
Wow, I'm an idiot.

P2PKH transactions are not actually smaller than P2PK transactions (I swear to god it was in the wiki somewhere, but I can't find it now for the life of me). While the redeem script is smaller, the full public key now has to be included in the input script, making it much larger. And here I was thinking I made some magical space-saving discovery Grin
newbie
Activity: 13
Merit: 4
Every resource I've looked at seems to suggest that the HTLCs used by LN are roughly of the form

Code:
HASH160 EQUAL
IF
    
ELSE
    "24h" CHECKSEQUENCEVERIFY DROP
    
ENDIF
CHECKSIG

Why was this was chosen instead of a variant based on the hash of the public key, similar to the standard P2PKH script? Something like

Code:
HASH160 EQUAL
IF
    DUP HASH160
ELSE
    "24h" CHECKSEQUENCEVERIFY DROP
    DUP HASH160
ENDIF
EQUALVERIFY
CHECKSIG

I'm sure that this could be expressed more elegantly, but whatever. If my arithmetic is on, doing so would shave off 19 bytes per script (64 bytes for two pubkeys vs 45 bytes for the two hashes and 5 extra opcodes).

So what's the catch? Am I missing something important in the script? Any insight would be appreciated.
Jump to: