namecoin / meta

General-Purpose Namecoin Repository
4 stars 3 forks source link

P2SH Name Registration #44

Open JeremyRand opened 7 years ago

JeremyRand commented 7 years ago

It occurred to me that the extra data used in name_new and name_firstupdate transactions doesn't actually need to be publicly viewable, and that we can take advantage of this fact to use P2SH for name registrations. Consider the following changes:

name_new becomes a P2SH output, with the following redeemScript:

OP_NAME_NEW (unsalted hashed name) OP_2DROP (Bitcoin scriptPubKey)

name_firstupdate remains non-P2SH, but has the following scriptPubKey:

OP_NAME_FIRSTUPDATE (name) (value) OP_2DROP OP_DROP (Bitcoin scriptPubKey)

What benefits does this have?

  1. Moves more data into scriptSig and P2SH. a. Leverages SegWit. b. Shrinks the size in bytes of the TXO set.
  2. Unspent name_new outputs look identical to unspent P2SH currency outputs. a. Better privacy. b. Better censorship resistance. c. Better usability, since Alice can create a P2SH address for a name registration, and Bob can fund the name registration by sending coins directly to the P2SH address. (This would make it easy to use Bitsquare to purchase Namecoin names using bitcoins, for example.)
  3. Duplicate name_new front-running attacks are inherently prevented without any special duplicate-checking logic, because the role of the name_new salt is played by the Bitcoin scriptPubKey (which is only valid for whoever holds the private key).

This could be implemented as a hardfork, or as a soft-hard-name fork.

If we wanted to save a few extra bytes, we could also remove the (unsalted hashed name) from the redeemScript serialization in the name_firstupdate scriptSig (but keep it present when calculating the P2SH hash). This works in theory, since the name exists in the name_firstupdate scriptPubKey. However, since this would change how P2SH is validated (in a way that's presumably a hardfork), I don't think it's worth the extra complexity.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/45073916-p2sh-name-registration?utm_campaign=plugin&utm_content=tracker%2F6562918&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F6562918&utm_medium=issues&utm_source=github).
domob1812 commented 7 years ago

That's a very nice idea - I'm totally in favour of keeping this in mind for a future protocol upgrade.

Note that P2SH is actually not yet fully enabled for Namecoin - while the infrastructure is there in code, the softfork is not active. We need to do this by flag-day activation, possibly combined with a scheduled fork for AAA.

ryancdotorg commented 7 years ago

This is a great idea.