Bitcoin Forum
June 23, 2024, 10:47:38 AM *
News: Voting for pizza day contest
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Standard P2SH encoding for standard transactions  (Read 825 times)
TierNolan (OP)
Legendary
*
Offline Offline

Activity: 1232
Merit: 1084


View Profile
April 28, 2014, 03:12:22 PM
 #1

Has something like this been considered?

A standard receive scriptPubKey is of the form

To scan for transactions, you need to compute the hash of the public key and scan for that.

With P2SH, there is no reason that you can't do that too

You scan for a P2SH transaction which pays to

Hash160(OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG)

For each public key, the software would need to scan for 4 encodings, P2SH and normal and compressed/decompressed keys.

This would allow payments to P2SH to be supported much more effectively.

P2SH addresses have a big advantage that they can be verified while only looking at the sigScript.  Each element in the UTXO set just needs to be a hash160 value.

1LxbG5cKXzTwZg9mjL3gaRE835uNQEteWF
jl2012
Legendary
*
Offline Offline

Activity: 1792
Merit: 1097


View Profile
April 28, 2014, 03:46:51 PM
 #2

Has something like this been considered?

A standard receive scriptPubKey is of the form

To scan for transactions, you need to compute the hash of the public key and scan for that.

With P2SH, there is no reason that you can't do that too

You scan for a P2SH transaction which pays to

Hash160(OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG)

For each public key, the software would need to scan for 4 encodings, P2SH and normal and compressed/decompressed keys.

This would allow payments to P2SH to be supported much more effectively.

P2SH addresses have a big advantage that they can be verified while only looking at the sigScript.  Each element in the UTXO set just needs to be a hash160 value.

it wastes block space.

just Hash160 (<pubkey> OP_CHECKSIG) is enough

Donation address: 374iXxS4BuqFHsEwwxUuH3nvJ69Y7Hqur3 (Bitcoin ONLY)
LRDGENPLYrcTRssGoZrsCT1hngaH3BVkM4 (LTC)
PGP: D3CC 1772 8600 5BB8 FF67 3294 C524 2A1A B393 6517
TierNolan (OP)
Legendary
*
Offline Offline

Activity: 1232
Merit: 1084


View Profile
April 28, 2014, 03:48:51 PM
 #3

it wastes block space.

just Hash160 (<pubkey> OP_CHECKSIG) is enough

Right (ahem).

I assume the general principle has been thought of though?  You get all the benefits of a standard transaction, but with P2SH.

1LxbG5cKXzTwZg9mjL3gaRE835uNQEteWF
jl2012
Legendary
*
Offline Offline

Activity: 1792
Merit: 1097


View Profile
April 28, 2014, 04:24:54 PM
 #4

it wastes block space.

just Hash160 (<pubkey> OP_CHECKSIG) is enough

Right (ahem).

I assume the general principle has been thought of though?  You get all the benefits of a standard transaction, but with P2SH.

It is already a standard type, just no one uses it.

Donation address: 374iXxS4BuqFHsEwwxUuH3nvJ69Y7Hqur3 (Bitcoin ONLY)
LRDGENPLYrcTRssGoZrsCT1hngaH3BVkM4 (LTC)
PGP: D3CC 1772 8600 5BB8 FF67 3294 C524 2A1A B393 6517
TierNolan (OP)
Legendary
*
Offline Offline

Activity: 1232
Merit: 1084


View Profile
April 28, 2014, 04:51:48 PM
 #5

It is already a standard type, just no one uses it.

I mean that the reference client could send to P2SH of that form.

1LxbG5cKXzTwZg9mjL3gaRE835uNQEteWF
justusranvier
Legendary
*
Offline Offline

Activity: 1400
Merit: 1009



View Profile
April 28, 2014, 04:58:48 PM
 #6

I think all transactions should use P2SH for encoding transaction outputs.

The network doesn't need to exactly how an output will be redeemed at the time it's created, so exposing this information early accomplishes nothing good.
TierNolan (OP)
Legendary
*
Offline Offline

Activity: 1232
Merit: 1084


View Profile
April 28, 2014, 05:35:06 PM
 #7

I think all transactions should use P2SH for encoding transaction outputs.

The network doesn't need to exactly how an output will be redeemed at the time it's created, so exposing this information early accomplishes nothing good.

In addition, it allows static checking of a block.  You can verify a block without seeing any other blocks.  You just have to make sure the output actually exists though.

1LxbG5cKXzTwZg9mjL3gaRE835uNQEteWF
etotheipi
Legendary
*
expert
Offline Offline

Activity: 1428
Merit: 1093


Core Armory Developer


View Profile WWW
April 28, 2014, 05:47:37 PM
 #8

It's not a totally unreasonable softfork.  The type is already standard & valid, and there's benefits to having 100% of transactions using the same template, moves the bulk of the data to prunable TxIns, and makes TxIn scripts self-identifying. 

Though probably not worth the effort, and would be much more worth if we were creating a new blockchain with that rule enforced from the beginning.  There's still 20 GB of blockchain that don't have that change, so the more-complex rules have to stay in the code to handle arbitrary, non-self-identifying TxIns for the first 20 GB.

Founder and CEO of Armory Technologies, Inc.
Armory Bitcoin Wallet: Bringing cold storage to the average user!
Only use Armory software signed by the Armory Offline Signing Key (0x98832223)

Please donate to the Armory project by clicking here!    (or donate directly via 1QBDLYTDFHHZAABYSKGKPWKLSXZWCCJQBX -- yes, it's a real address!)
justusranvier
Legendary
*
Offline Offline

Activity: 1400
Merit: 1009



View Profile
April 28, 2014, 06:16:29 PM
 #9

moves the bulk of the data to prunable TxIns
Speaking of that, is every redemption of a P2SH output considered standard?
etotheipi
Legendary
*
expert
Offline Offline

Activity: 1428
Merit: 1093


Core Armory Developer


View Profile WWW
April 28, 2014, 06:34:51 PM
 #10

moves the bulk of the data to prunable TxIns
Speaking of that, is every redemption of a P2SH output considered standard?

The P2SH subscript provided in the redemption TxIn must be standard, though for multisig it's slightly different rules.  It's by script size, not (M,N).  As such it seems you could do M-of-15 compressed keys, or M-of-7 uncompressed keys, as an upper limit on mainnet.

Any scripts that would be non-standard to put into a TxOut should be non-standard when you put them in a TxIn to redeem them.  This was actually one of the motiviations for P2SH:  I am giving you a script and declaring that money sent to that script absolves you of whatever debt you are trying to cover.  It should be my problem, not yours if I want you to send to some crazy script.  So it the standardness rules still apply, it just shifts the burden on getting the non-standard script mined to the person who actually controls the money.

Founder and CEO of Armory Technologies, Inc.
Armory Bitcoin Wallet: Bringing cold storage to the average user!
Only use Armory software signed by the Armory Offline Signing Key (0x98832223)

Please donate to the Armory project by clicking here!    (or donate directly via 1QBDLYTDFHHZAABYSKGKPWKLSXZWCCJQBX -- yes, it's a real address!)
TierNolan (OP)
Legendary
*
Offline Offline

Activity: 1232
Merit: 1084


View Profile
April 28, 2014, 06:48:55 PM
 #11

It's not a totally unreasonable softfork.  The type is already standard & valid, and there's benefits to having 100% of transactions using the same template, moves the bulk of the data to prunable TxIns, and makes TxIn scripts self-identifying.  

It would help with the "ultimate blockchain compression" kind of thing.

At the moment, the UTXO set has to be stored as a map tx-out -> script.  

With mandatory P2SH, you could save a hash for each output and done (20 bytes).  In fact, you could just save part of the hash (8-10 bytes).

Quote
Though probably not worth the effort, and would be much more worth if we were creating a new blockchain with that rule enforced from the beginning.  There's still 20 GB of blockchain that don't have that change, so the more-complex rules have to stay in the code to handle arbitrary, non-self-identifying TxIns for the first 20 GB.

It is a fixed cost.  You can get around it for legacy transactions anyway.

Define a new "expanded" block and "expanded" transaction.

For an expanded transaction, you append all the non-P2SH input scripts.

An expanded block contains expanded transactions to cover non-P2SH transactions.  If it is all P2SH transactions, then the block is the same as now.

For maximum security, the appended info would also need to include the paths to the merkle root.

However, since the client would already be tracking the UTXO set (as hashes) that isn't required.

The switch-over could be

After block N, all transaction outputs must be either OP_RETURN <40 bytes>, P2SH or P2SH-v2 (without the 500 byte limit)

Legacy outputs from blocks <= N still operate as per normal.  

After block N + 25000 (6 months), spending them requires that the spender provide the extended transaction format.

1LxbG5cKXzTwZg9mjL3gaRE835uNQEteWF
TierNolan (OP)
Legendary
*
Offline Offline

Activity: 1232
Merit: 1084


View Profile
April 28, 2014, 06:55:42 PM
 #12

The P2SH subscript provided in the redemption TxIn must be standard, though for multisig it's slightly different rules.  It's by script size, not (M,N).  As such it seems you could do M-of-15 compressed keys, or M-of-7 uncompressed keys, as an upper limit on mainnet.

All P2SH scripts are limited to 500 bytes.  If P2SH was to be made mandatory, that would have to be dropped.

Quote
Any scripts that would be non-standard to put into a TxOut should be non-standard when you put them in a TxIn to redeem them.  This was actually one of the motiviations for P2SH:  I am giving you a script and declaring that money sent to that script absolves you of whatever debt you are trying to cover.  It should be my problem, not yours if I want you to send to some crazy script.  So it the standardness rules still apply, it just shifts the burden on getting the non-standard script mined to the person who actually controls the money.

I think weaker rules would be better here, since you aren't spamming the blockchain until you prove that you can spend the output.  The tx-out -> script map is kept compact.

GMaxwell proposed a system for namecoin to prevent info from being added to the blockchain (like the OP_RETURN system bitcoin has).

You use Hash(x | Hash(script)).  The x value is only stored for a while.  Once a block is buried 100 blocks into the blockchain, it counts as valid, even if x is missing.

This means you have to tell miners what x you used.  It is 'attached' to the transaction, but not part of it.  Once a block is buried more than 100 blocks deep, x can be discarded.

1LxbG5cKXzTwZg9mjL3gaRE835uNQEteWF
justusranvier
Legendary
*
Offline Offline

Activity: 1400
Merit: 1009



View Profile
April 28, 2014, 08:42:54 PM
 #13

The P2SH subscript provided in the redemption TxIn must be standard
I don't see what justification there is to enforce standard templates when redeeming P2SH outputs, because no matter how what is in the input script it's all prunable.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!