Re: [bitcoin-dev] Compressed Bitcoin Transactions
Hi Jonas, As it turns out, most of our size savings come from eliminating unneeded hashes and public keys, which get recovered on decompression. gzip actually expands transactions due to the way it attempts to compress pseudorandom data, my numbers show a legacy transaction of 222 bytes being expanded to 267 bytes. gzip can possibly shrink the 4-byte integers which have only a couple typical values, and can eliminate some of the "boilerplate" in the tx format, but that's pretty much it at the expense of expanding the signatures, public keys, and hashes. And your absolutely right this would have to be done at the application layer in a V2-P2P encrypted traffic system. Thanks- Tom. ___ bitcoin-dev mailing list bitcoin-dev@lists.linuxfoundation.org https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev
Re: [bitcoin-dev] Compressed Bitcoin Transactions
One point to add here is that, while V1 non-encrypted p2p traffic could be compressed on a different OSI layer in theory, v2 encrypted traffic – due to its pseudorandom nature – will likely have no size savings and thus need to be compressed on the application layer with a proposal like this. Would be nice to see size comparison of this compression proposal vs LZO/gzip compression of legacy transaction encoding. A possible advantage of this proposal is that it could save more space with less CPU impact, which might be important for block propagation. Previous discussion about compressing blocks before sending them: https://github.com/bitcoin/bitcoin/pull/6973 /jonas > Am 16.01.2024 um 18:08 schrieb Tom Briar via bitcoin-dev > : > > Hi, > > In addition to the use cases listed in the schema, such as steganography, > satellite, and radio broadcast, an application can be made for Peer-to-peer > communication between Bitcoin nodes. Except when compressing the Txid/Vout, > which is optional, Transactions can gain up to 30% size savings while still > being completely reversible. Furthermore, in a BIP-324 world, these savings > are nontrivial. > > BIP-324: https://github.com/bitcoin/bips/blob/master/bip-0324.mediawiki > Compressed Transaction Schema: compressed_transactions.md > > Thanks- > Tom. > ___ > bitcoin-dev mailing list > bitcoin-dev@lists.linuxfoundation.org > https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev ___ bitcoin-dev mailing list bitcoin-dev@lists.linuxfoundation.org https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev
Re: [bitcoin-dev] Compressed Bitcoin Transactions
Hi, In addition to the use cases listed in the schema, such as steganography, satellite, and radio broadcast, an application can be made for Peer-to-peer communication between Bitcoin nodes. Except when compressing the Txid/Vout, which is optional, Transactions can gain up to 30% size savings while still being completely reversible. Furthermore, in a BIP-324 world, these savings are nontrivial. BIP-324: https://github.com/bitcoin/bips/blob/master/bip-0324.mediawiki Compressed Transaction Schema: compressed_transactions.md Thanks- Tom. ___ bitcoin-dev mailing list bitcoin-dev@lists.linuxfoundation.org https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev
Re: [bitcoin-dev] Compressed Bitcoin Transactions
Hi, After reviewing all the feedback and writing a reference implementation, I have linked the updated schema and a Draft PR for a reference Implementation to Bitcoin Core. Some of the major changes consist of: Removing the grinding of the nLocktime in favor of a relative block height, which all of the Compressed Inputs use. And the use of a second kind of Variable Integer. Compressed Transaction Schema: compressed_transactions.md Reference Impl/Draft PR: https://github.com/bitcoin/bitcoin/pull/29134 Thanks- Tom. === begin compressed_transactions.md === # Compressed Transaction Schema By (Tom Briar) and (Andrew Poelstra) ## 1. Abstract With this Transaction Compression Schema we use several methods to compress transactions, including dropping data and recovering it on decompression by grinding until we obtain valid signatures. The bulk of our size savings come from replacing the prevout of each input by a block height and index. This requires the decompression to have access to the blockchain, and also means that compression is ineffective for transactions that spend unconfirmed or insufficiently confirmed outputs. Even without compression, Taproot keyspends are very small: as witness data they include only a single 64/65-byte signature and do not repeat the public key or any other metadata. By using pubkey recovery, we obtain Taproot-like compression for legacy and Segwit transactions. The main applications for this schema are for steganography, satellite/radio broadcast, and other low bandwidth channels with a high CPU availability on decompression. We assume users have some ability to shape their transactions to improve their compressibility, and therefore give special treatment to certain transaction forms. This schema is easily reversible except for compressing the Txid/Vout input pairs(Method 4). Compressing the input Txid/Vout is optional, and without it still gleans 50% of the total compression. This allows for the additional use case of P2P communication. ## 2. Methods The four main methods to achieve a lower transactions size are: 1. packing transaction metadata before the transaction and each of its inputs and outputs to determine the structure of the following data. 2. replacing 32-bit numeric values with either variable-length integers (VarInts) or compact-integers (CompactSizes). 3. using compressed signatures and public key recovery upon decompression. 4. replacing the 36-byte txid/vout pair with a blockheight and output index. Method 4 will cause the compressed transaction to be undecompressable if a block reorg occurs at or before the block it's included in. Therefore, we'll only compress the Txid if the transaction input is at least one hundred blocks old. ## 3 Schema ### 3.1 Primitives | Name | Width | Description | |--|---|-| | CompactSize | 1-5 Bytes | For 0-253, encode the value directly in one byte. For 254-65535, encode 254 followed by 2 little-endian bytes. For 65536-(2^32-1), encode 255 followed by 4 little-endian bytes. | | CompactSize flag | 2 Bits| 1, 2 or 3 indicate literal values. 0 indicates that the value will be encoded in a later CompactInt. | | VarInt | 1+ Bytes | 7-bit little-endian encoding, with each 7-bit word encoded in a byte. The highest bit of each byte is 1 if more bytes follow, and 0 for the last byte. | | VLP-Bytestream | 2+ Bytes | A VarInt Length Prefixed Bytestream. Has a VarInt prefixed to determine the length. | ### 3.2 General Schema | Name | Width | Description | ||-|-| | Transaction Metadata | 1 Byte| Information on the structure of the transaction. See Section 3.3. | | Version| 0-5 Bytes | An optional CompactSize containing the transactions version. | | Input Count| 0-5 Bytes | An optional CompactSize containing the transactions input count. | | Output Count | 0-5 Bytes | An optional CompactSize containing the transactions output count. | | LockTime | 0-5 Bytes | An optional CompactSize containing the transaction LockTime if its non zero. | | Minimum Blockheight| 1-5 Bytes | A VarInt containing the Minimum Blockheight of which the transaction locktime and input blockheights are given as offsets. | | Input Metadata+Output Metadata | 1+ Bytes | A Encoding containing metadata on all the inputs and then all the outputs of the transaction. For each input see Section 3.4, for each output see Section 3.5. | | Input Data | 66+ Bytes | See Section 3.6 for each input. | | Output Data| 3+ Bytes | See Section 3.7 for each output. | For the four CompactSize listed above we could use a more compact bit encoding for these but they are already a fall back for the bit encoding of the
Re: [bitcoin-dev] Compressed Bitcoin Transactions
Thanks Tom. It looks like you posted a text-scrape of the rendered markdown, which is hard to read. For posterity here is the full text. Best Andrew === begin compressed_transactions.md === # Compressed Transaction Schema By (Tom Briar) and (Andrew Poelstra) ## 1. Abstract With this Transaction Compression Schema we use several methods to compress transactions, including dropping data and recovering it on decompression by grinding until we obtain valid signatures. The bulk of our size savings come from replacing the prevout of each input by a block height and index. This requires the decompression to have access to the blockchain, and also means that compression is ineffective for transactions that spend unconfirmed or insufficiently confirmed outputs. Even without compression, Taproot keyspends are very small: as witness data they include only a single 64/65-byte signature and do not repeat the public key or any other metadata. By using pubkey recovery, we obtain Taproot-like compression for legacy and Segwit transactions. The main applications for this schema are for steganography, satellite/radio broadcast, and other low bandwidth channels with a high CPU availability on decompression. We assume users have some ability to shape their transactions to improve their compressibility, and therefore give special treatment to certain transaction forms. This schema is easily reversible except for compressing the Txid/Vout input pairs(Method 4). Compressing the input Txid/Vout is optional, and without it still gleans 50% of the total compression. This allows for the additional use case of P2P communication. ## 2. Methods The four main methods to achieve a lower transactions size are: 1. packing transaction metadata before the transaction and each of its inputs and outputs to determine the structure of the following data. 2. replacing 32-bit numeric values with either variable-length integers (VarInts) or compact-integers (CompactSizes). 3. using compressed signatures and public key recovery upon decompression. 4. replacing the 36-byte txid/vout pair with a blockheight and output index. Method 4 will cause the compressed transaction to be undecompressable if a block reorg occurs at or before the block it's included in. Therefore, we'll only compress the Txid if the transaction input is at least one hundred blocks old. ## 3 Schema ### 3.1 Primitives | Name | Width | Description | |--|---|-| | CompactSize | 1-5 Bytes | For 0-253, encode the value directly in one byte. For 254-65535, encode 254 followed by 2 little-endian bytes. For 65536-(2^32-1), encode 255 followed by 4 little-endian bytes. | | CompactSize flag | 2 Bits| 1, 2 or 3 indicate literal values. 0 indicates that the value will be encoded in a later CompactInt. | | VarInt | 1+ Bytes | 7-bit little-endian encoding, with each 7-bit word encoded in a byte. The highest bit of each byte is 1 if more bytes follow, and 0 for the last byte. | | VLP-Bytestream | 2+ Bytes | A VarInt Length Prefixed Bytestream. Has a VarInt prefixed to determine the length. | ### 3.2 General Schema | Name | Width | Description | ||-|-| | Transaction Metadata | 1 Byte| Information on the structure of the transaction. See Section 3.3. | | Version| 0-5 Bytes | An optional CompactSize containing the transactions version. | | Input Count| 0-5 Bytes | An optional CompactSize containing the transactions input count. | | Output Count | 0-5 Bytes | An optional CompactSize containing the transactions output count. | | LockTime | 0-5 Bytes | An optional CompactSize containing the transaction LockTime if its non zero. | | Minimum Blockheight| 1-5 Bytes | A VarInt containing the Minimum Blockheight of which the transaction locktime and input blockheights are given as offsets. | | Input Metadata+Output Metadata | 1+ Bytes | A Encoding containing metadata on all the inputs and then all the outputs of the transaction. For each input see Section 3.4, for each output see Section 3.5. | | Input Data | 66+ Bytes | See Section 3.6 for each input. | | Output Data| 3+ Bytes | See Section 3.7 for each output. | For the four CompactSize listed above we could use a more compact bit encoding for these but they are already a fall back for the bit encoding of the Transaction Metadata. ### 3.3 Transaction Metadata | Name | Width | Description | |--||-| | Version | 2 Bits | A CompactSize flag for the transaction version. | | Input Count | 2 Bits | A CompactSize flag for the transaction input count. | | Output Count | 2 Bits | A CompactSize flag for the transaction output count. | | LockTime
Re: [bitcoin-dev] Compressed Bitcoin Transactions
Hi, After reviewing all the feedback and writing a reference implementation, I have linked the updated schema and a Draft PR for a reference Implementation to Bitcoin Core. Some of the major changes consist of: - Removing the grinding of the nLocktime in favor of a relative block height, which all of the Compressed Inputs use. - And the use of a second kind of Variable Integer. Compressed Transaction Schema: [compressed_transactions.md](https://github.com/TomBriar/bitcoin/blob/2023-05--tx-compression/doc/compressed_transactions.md) Reference Impl/Draft PR: https://github.com/bitcoin/bitcoin/pull/29134 Thanks-Tom. Text of Compressed_Transactions.md: Compressed Transaction Schema By (Tom Briar) and (Andrew Poelstra) https://github.com/TomBriar/bitcoin/blob/2023-05--tx-compression/doc/compressed_transactions.md#1-abstract1. Abstract With this Transaction Compression Schema we use several methods to compress transactions, including dropping data and recovering it on decompression by grinding until we obtain valid signatures. The bulk of our size savings come from replacing the prevout of each input by a block height and index. This requires the decompression to have access to the blockchain, and also means that compression is ineffective for transactions that spend unconfirmed or insufficiently confirmed outputs. Even without compression, Taproot keyspends are very small: as witness data they include only a single 64/65-byte signature and do not repeat the public key or any other metadata. By using pubkey recovery, we obtain Taproot-like compression for legacy and Segwit transactions. The main applications for this schema are for steganography, satellite/radio broadcast, and other low bandwidth channels with a high CPU availability on decompression. We assume users have some ability to shape their transactions to improve their compressibility, and therefore give special treatment to certain transaction forms. This schema is easily reversible except when compressing the Txid/Vout input pairs(Method 4). Compressing the input Txid/Vout is optional, and without it still gleans 50% of the total compression. This allows for the additional use case of P2P communication. https://github.com/TomBriar/bitcoin/blob/2023-05--tx-compression/doc/compressed_transactions.md#2-methods2. Methods The four main methods to achieve a lower transactions size are: - packing transaction metadata before the transaction and each of its inputs and outputs to determine the structure of the following data. - replacing 32-bit numeric values with either variable-length integers (VarInts) or compact-integers (CompactSizes). - using compressed signatures and public key recovery upon decompression. - replacing the 36-byte txid/vout pair with a blockheight and output index. Method 4 will cause the compressed transaction to be undecompressable if a block reorg occurs at or before the block it's included in. Therefore, we'll only compress the Txid if the transaction input is at least one hundred blocks old. https://github.com/TomBriar/bitcoin/blob/2023-05--tx-compression/doc/compressed_transactions.md#3-schema3 Schema https://github.com/TomBriar/bitcoin/blob/2023-05--tx-compression/doc/compressed_transactions.md#31-primitives3.1 Primitives NameWidth Description CompactSize 1-5 Bytes For 0-253, encode the value directly in one byte. For 254-65535, encode 254 followed by 2 little-endian bytes. For 65536-(2^32-1), encode 255 followed by 4 little-endian bytes. CompactSize flag2 Bits 1, 2 or 3 indicate literal values. 0 indicates that the value will be encoded in a later CompactInt. VarInt 1+ Bytes7-bit little-endian encoding, with each 7-bit word encoded in a byte. The highest bit of each byte is 1 if more bytes follow, and 0 for the last byte. VLP-Bytestream 2+ BytesA VarInt Length Prefixed Bytestream. Has a VarInt prefixed to determine the length. https://github.com/TomBriar/bitcoin/blob/2023-05--tx-compression/doc/compressed_transactions.md#32-general-schema3.2 General Schema NameWidth Description Transaction Metadata1 Byte Information on the structure of the transaction. See Section 3.3. Version 0-5 Bytes An optional CompactSize containing the transactions version. Input Count 0-5 Bytes An optional CompactSize containing the transactions input count. Output Count0-5 Bytes An optional CompactSize containing the transactions output count. LockTime0-5 Bytes An optional CompactSize containing the transaction LockTime if its non zero. Minimum Blockheight 1-5 Bytes A VarInt containing the Minimum Blockheight of which the transaction locktime and input blockheights are given as offsets. Input Metadata+Output Metadata 1+ BytesA Encoding containing metadata on all the inputs and then all the outputs of the transaction. For each input see Section 3.4, for each output see Section
Re: [bitcoin-dev] Compressed Bitcoin Transactions
Hi Peter, Currently, if we’re given a lock time that is non zero, we drop the 16 most significant bits and grind through until we have a valid signature. Therefore I am hesitant to add more fields to grind through, because it can get out of hand in decompression time really quickly. That said our ideal use case for transaction compression is small high security transactions, I doubt they will need a lock time in most cases. Perhaps we should drop grinding the lock time in favor of grinding the block height. Either way assuming both parties agree on the block height(which is a must right now) having a single block height for the transaction might save us several bytes. I’m working on adding an ideal transaction spec to the doc right now. Thanks!- Tom. On Tue, Sep 5, 2023 at 12:00 PM, Peter Todd via bitcoin-dev <[bitcoin-dev@lists.linuxfoundation.org](mailto:On Tue, Sep 5, 2023 at 12:00 PM, Peter Todd via bitcoin-dev < wrote: > On Fri, Sep 01, 2023 at 01:56:18PM +, Andrew Poelstra via bitcoin-dev > wrote: >> We can swag what the space savings would be: there are 122MM utxos right >> now, which is a bit under 2^27. So assuming a uniform distribution of >> prefixes we'd need to specify 28 bits to identify a UTXO. To contrast, >> to identify a blockheight we need 20 bits and then maybe 12 more bits to >> specify a TXO within a block. Plus whatever varint overhead we have. >> (I've been working on this project but busy with family stuff and don't >> remember exactly where we landed on the varints for this. I think we >> agreed that there was room for improvement but didn't want to hold up >> posting the rest of the concept because of it.) > > Since most transactions spend txouts that are similar in height to each other, > you could save further bits by specifying a reference height and then encoding > the exact txout with a delta. > > If you're sending multiple txins or multiple transactions in a single packet, > you could achieve this by starting the packet with the reference block height. > > If your application tends to send just a single transaction, you could use a > reference height that is a function of the current time. Since sender and > receiver might not agree on the exact time, you could try slightly difference > reference heights via bruteforcing until the transaction signatures validate. > > -- > https://petertodd.org 'peter'[:-1]@petertodd.org > ___ > bitcoin-dev mailing list > bitcoin-dev@lists.linuxfoundation.org > https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev___ bitcoin-dev mailing list bitcoin-dev@lists.linuxfoundation.org https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev
Re: [bitcoin-dev] Compressed Bitcoin Transactions
On Fri, Sep 01, 2023 at 01:56:18PM +, Andrew Poelstra via bitcoin-dev wrote: > We can swag what the space savings would be: there are 122MM utxos right > now, which is a bit under 2^27. So assuming a uniform distribution of > prefixes we'd need to specify 28 bits to identify a UTXO. To contrast, > to identify a blockheight we need 20 bits and then maybe 12 more bits to > specify a TXO within a block. Plus whatever varint overhead we have. > (I've been working on this project but busy with family stuff and don't > remember exactly where we landed on the varints for this. I think we > agreed that there was room for improvement but didn't want to hold up > posting the rest of the concept because of it.) Since most transactions spend txouts that are similar in height to each other, you could save further bits by specifying a reference height and then encoding the exact txout with a delta. If you're sending multiple txins or multiple transactions in a single packet, you could achieve this by starting the packet with the reference block height. If your application tends to send just a single transaction, you could use a reference height that is a function of the current time. Since sender and receiver might not agree on the exact time, you could try slightly difference reference heights via bruteforcing until the transaction signatures validate. -- https://petertodd.org 'peter'[:-1]@petertodd.org signature.asc Description: PGP signature ___ bitcoin-dev mailing list bitcoin-dev@lists.linuxfoundation.org https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev
Re: [bitcoin-dev] Compressed Bitcoin Transactions
Hi Jonas, I’m working to get numbers based on both historical data and from fuzz tests but I’m in the middle of updating the code to match the doc, I should have it finished before the end of the week. We estimate that 100 blocks is safe from reorg, that is the same policyfor spending coin base transactions, in the PR I add a compressrawtransaction RPC endpoint that has that limit built in and will warn the user that the TxIdis uncompresssed due to it not being old enough. That said I’ll add it into the doc in case anyone adds onto it. Thanks for the feedback!- Tom. On Fri, Sep 1, 2023 at 10:56 AM, Jonas Schnelli <[d...@jonasschnelli.ch](mailto:On Fri, Sep 1, 2023 at 10:56 AM, Jonas Schnelli < wrote: > Hi Tom > >> I've been working on a way to compress bitcoin transactions for transmission >> through steganography, satellite broadcasting, > > Interesting. Some size numbers (vs plain, vs gzip) would be nice. > > Maybe add a definition to your BIP that makes clear when NOT to use > height/index due to risk of reorgs (similar to BIP136). > > /j___ bitcoin-dev mailing list bitcoin-dev@lists.linuxfoundation.org https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev
Re: [bitcoin-dev] Compressed Bitcoin Transactions
Hi Tom > I've been working on a way to compress bitcoin transactions for transmission > through steganography, satellite broadcasting, Interesting. Some size numbers (vs plain, vs gzip) would be nice. Maybe add a definition to your BIP that makes clear when NOT to use height/index due to risk of reorgs (similar to BIP136). /j ___ bitcoin-dev mailing list bitcoin-dev@lists.linuxfoundation.org https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev
Re: [bitcoin-dev] Compressed Bitcoin Transactions
Hi Fabian, Yes as Andrew said, creating a prefix tree is going to take up more space then simply the block height and then an index for the UTXO in the block. We removed the vout from the encoding by doing almost exactly what you said per block where it’s a flattened index over all the transactions and their outputs. Andrews numbers on the required bits is accurate with 19 for the block height and 12 for the flattened index on average, although I suppose we can significantly reduce the number of bits required by the block height by having a bit indicate weather the block height is over 50 or something similar. Thanks- Tom. On Fri, Sep 1, 2023 at 7:56 AM, Andrew Poelstra <[apoels...@wpsoftware.net](mailto:On Fri, Sep 1, 2023 at 7:56 AM, Andrew Poelstra < wrote: > Hi Fabian, > > We did consider indexing all txos -- even, amusingly, by using ordinals -- > but decided that the extra index requirements for the decompressor (which > otherwise just requires a bit of extra CPU cycles but nothing beyond a > normal Core node). > > A while ago we looked into putting the whole UTXOset into a trie so that > we could do prefix lookups. I think we discarded this idea for the same > reason, and because it could lead to surprising behavior for users since > a compressed tx might get invalidated by some UTXO showing up whose > prefix is too close to one of its inputs. Where "prefix" likely means > some special-purpose hash of the prevout that users will never otherwise > encounter. > > We were also a bit put off by the data structure complexity since the > UTXO set no longer fits in RAM so it takes nontrivial effort to > implement a new index :) plus it drops our chances of getting code into > Core by a very large factor. > > We can swag what the space savings would be: there are 122MM utxos right > now, which is a bit under 2^27. So assuming a uniform distribution of > prefixes we'd need to specify 28 bits to identify a UTXO. To contrast, > to identify a blockheight we need 20 bits and then maybe 12 more bits to > specify a TXO within a block. Plus whatever varint overhead we have. > (I've been working on this project but busy with family stuff and don't > remember exactly where we landed on the varints for this. I think we > agreed that there was room for improvement but didn't want to hold up > posting the rest of the concept because of it.) > > The TL;DR is that we probably save a little less than a byte per input, > on average, which is not trivial but probably not worth the decreased > UX and greatly increased implementation complexity. > > Best > Andrew > > On Fri, Sep 01, 2023 at 10:24:54AM +, Fabian via bitcoin-dev wrote: >> Hi Tom, >> >> without having gone into the details yet, thanks for the great effort you >> have put into this research and implementation already! >> >> > The bulk of our size savings come from replacing the prevout of each input >> > by a block height and index. >> >> Have you also considered using just an index from a sorted UTXO set instead? >> The potential additional space saving might be minor but this would make the >> scheme compatible with pruning. I had this on my list as a future research >> topic but didn't get around to it yet. >> >> Thanks, >> Fabian >> --- Original Message --- >> On Thursday, August 31st, 2023 at 11:30 PM, Tom Briar via bitcoin-dev >> wrote: >> >> > Hey everyone, >> > >> > I've been working on a way to compress bitcoin transactions for >> > transmission throughsteganography, satellite broadcasting, >> > and other low bandwidth channels with high CPU availability on >> > decompression. >> > >> > [compressed_transactions.md](https://github.com/TomBriar/bitcoin/blob/2023-05--tx-compression/doc/compressed_transactions.md) >> > >> > In the document I describe a compression schema that's tailored for the >> > most common transactions single parties are likely to make. >> > In every case it falls back such that no transaction will become malformed >> > or corrupted. >> > Here's a PR for implementing this schema. >> > >> > [2023 05 tx compression](https://github.com/TomBriar/bitcoin/pull/3) >> > Thanks- >> > Tom. > >> ___ >> bitcoin-dev mailing list >> bitcoin-dev@lists.linuxfoundation.org >> https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev > > -- > Andrew Poelstra > Director of Research, Blockstream > Email: apoelstra at wpsoftware.net > Web: https://www.wpsoftware.net/andrew > > The sun is always shining in space > -Justin Lewis-Webster___ bitcoin-dev mailing list bitcoin-dev@lists.linuxfoundation.org https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev
Re: [bitcoin-dev] Compressed Bitcoin Transactions
Hi Fabian, We did consider indexing all txos -- even, amusingly, by using ordinals -- but decided that the extra index requirements for the decompressor (which otherwise just requires a bit of extra CPU cycles but nothing beyond a normal Core node). A while ago we looked into putting the whole UTXOset into a trie so that we could do prefix lookups. I think we discarded this idea for the same reason, and because it could lead to surprising behavior for users since a compressed tx might get invalidated by some UTXO showing up whose prefix is too close to one of its inputs. Where "prefix" likely means some special-purpose hash of the prevout that users will never otherwise encounter. We were also a bit put off by the data structure complexity since the UTXO set no longer fits in RAM so it takes nontrivial effort to implement a new index :) plus it drops our chances of getting code into Core by a very large factor. We can swag what the space savings would be: there are 122MM utxos right now, which is a bit under 2^27. So assuming a uniform distribution of prefixes we'd need to specify 28 bits to identify a UTXO. To contrast, to identify a blockheight we need 20 bits and then maybe 12 more bits to specify a TXO within a block. Plus whatever varint overhead we have. (I've been working on this project but busy with family stuff and don't remember exactly where we landed on the varints for this. I think we agreed that there was room for improvement but didn't want to hold up posting the rest of the concept because of it.) The TL;DR is that we probably save a little less than a byte per input, on average, which is not trivial but probably not worth the decreased UX and greatly increased implementation complexity. Best Andrew On Fri, Sep 01, 2023 at 10:24:54AM +, Fabian via bitcoin-dev wrote: > Hi Tom, > > without having gone into the details yet, thanks for the great effort you > have put into this research and implementation already! > > > The bulk of our size savings come from replacing the prevout of each input > > by a block height and index. > > Have you also considered using just an index from a sorted UTXO set instead? > The potential additional space saving might be minor but this would make the > scheme compatible with pruning. I had this on my list as a future research > topic but didn't get around to it yet. > > Thanks, > Fabian > --- Original Message --- > On Thursday, August 31st, 2023 at 11:30 PM, Tom Briar via bitcoin-dev > wrote: > > > Hey everyone, > > > > I've been working on a way to compress bitcoin transactions for > > transmission throughsteganography, satellite broadcasting, > > and other low bandwidth channels with high CPU availability on > > decompression. > > > > [compressed_transactions.md](https://github.com/TomBriar/bitcoin/blob/2023-05--tx-compression/doc/compressed_transactions.md) > > > > In the document I describe a compression schema that's tailored for the > > most common transactions single parties are likely to make. > > In every case it falls back such that no transaction will become malformed > > or corrupted. > > Here's a PR for implementing this schema. > > > > [2023 05 tx compression](https://github.com/TomBriar/bitcoin/pull/3) > > Thanks- > > Tom. > ___ > bitcoin-dev mailing list > bitcoin-dev@lists.linuxfoundation.org > https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev -- Andrew Poelstra Director of Research, Blockstream Email: apoelstra at wpsoftware.net Web: https://www.wpsoftware.net/andrew The sun is always shining in space -Justin Lewis-Webster signature.asc Description: PGP signature ___ bitcoin-dev mailing list bitcoin-dev@lists.linuxfoundation.org https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev
Re: [bitcoin-dev] Compressed Bitcoin Transactions
Hi Tom, I realized I simplified my message a bit too much. Of course an index of the UTXO set would also need a height, so I rather meant some kind of composite reference I guess. An index alone might be enough if a height has been pre-agreed which could still be compatible with the use-cases you might have in mind, this might be very interesting in combination with assumeutxo. Otherwise a short hash could be used but then I also think your current scheme might be more space efficient than this. Fabian --- Original Message --- On Friday, September 1st, 2023 at 12:24 PM, Fabian wrote: > Hi Tom, > > without having gone into the details yet, thanks for the great effort you > have put into this research and implementation already! > >> The bulk of our size savings come from replacing the prevout of each input >> by a block height and index. > > Have you also considered using just an index from a sorted UTXO set instead? > The potential additional space saving might be minor but this would make the > scheme compatible with pruning. I had this on my list as a future research > topic but didn't get around to it yet. > > Thanks, > Fabian > --- Original Message --- > On Thursday, August 31st, 2023 at 11:30 PM, Tom Briar via bitcoin-dev > wrote: > >> Hey everyone, >> >> I've been working on a way to compress bitcoin transactions for transmission >> throughsteganography, satellite broadcasting, >> and other low bandwidth channels with high CPU availability on decompression. >> >> [compressed_transactions.md](https://github.com/TomBriar/bitcoin/blob/2023-05--tx-compression/doc/compressed_transactions.md) >> >> In the document I describe a compression schema that's tailored for the most >> common transactions single parties are likely to make. >> In every case it falls back such that no transaction will become malformed >> or corrupted. >> Here's a PR for implementing this schema. >> >> [2023 05 tx compression](https://github.com/TomBriar/bitcoin/pull/3) >> Thanks- >> Tom.___ bitcoin-dev mailing list bitcoin-dev@lists.linuxfoundation.org https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev
Re: [bitcoin-dev] Compressed Bitcoin Transactions
Hi Tom, without having gone into the details yet, thanks for the great effort you have put into this research and implementation already! > The bulk of our size savings come from replacing the prevout of each input by > a block height and index. Have you also considered using just an index from a sorted UTXO set instead? The potential additional space saving might be minor but this would make the scheme compatible with pruning. I had this on my list as a future research topic but didn't get around to it yet. Thanks, Fabian --- Original Message --- On Thursday, August 31st, 2023 at 11:30 PM, Tom Briar via bitcoin-dev wrote: > Hey everyone, > > I've been working on a way to compress bitcoin transactions for transmission > throughsteganography, satellite broadcasting, > and other low bandwidth channels with high CPU availability on decompression. > > [compressed_transactions.md](https://github.com/TomBriar/bitcoin/blob/2023-05--tx-compression/doc/compressed_transactions.md) > > In the document I describe a compression schema that's tailored for the most > common transactions single parties are likely to make. > In every case it falls back such that no transaction will become malformed or > corrupted. > Here's a PR for implementing this schema. > > [2023 05 tx compression](https://github.com/TomBriar/bitcoin/pull/3) > Thanks- > Tom.___ bitcoin-dev mailing list bitcoin-dev@lists.linuxfoundation.org https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev
Re: [bitcoin-dev] Compressed Bitcoin Transactions
On Thu, Aug 31, 2023 at 09:30:16PM +, Tom Briar via bitcoin-dev wrote: > Hey everyone, > > I've been working on a way to compress bitcoin transactions for transmission > throughsteganography, satellite broadcasting, > and other low bandwidth channels with high CPU availability on decompression. > > [compressed_transactions.md](https://github.com/TomBriar/bitcoin/blob/2023-05--tx-compression/doc/compressed_transactions.md) > > In the document I describe a compression schema that's tailored for the most > common transactions single parties are likely to make. > In every case it falls back such that no transaction will become malformed or > corrupted. > Here's a PR for implementing this schema. > > [2023 05 tx compression](https://github.com/TomBriar/bitcoin/pull/3) Hey Tom, Thank you for posting this. Could you put together a chart with some size numbers so we can get a picture of how strong this compression is? I understand that because this is targeted at stego/satellite applications where the user is expected to "shape" their transaction, that you won't get great numbers if you just look at the historical chain or try to analyze "average" transactions. But it would be great to post a chart with uncompressed/compressed sizes for "optimum" transactions. At the very least, a 2-in-2-out wpkh transaction, and a 2-in-2-out Taproot transaction. Since the scheme includes explicit support for p2sh-wpkh and p2pkh it would also be great to see numbers for those, though they're less common and less interesting. Cheers Andrew -- Andrew Poelstra Director of Research, Blockstream Email: apoelstra at wpsoftware.net Web: https://www.wpsoftware.net/andrew The sun is always shining in space -Justin Lewis-Webster signature.asc Description: PGP signature ___ bitcoin-dev mailing list bitcoin-dev@lists.linuxfoundation.org https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev
[bitcoin-dev] Compressed Bitcoin Transactions
Hey everyone, I've been working on a way to compress bitcoin transactions for transmission throughsteganography, satellite broadcasting, and other low bandwidth channels with high CPU availability on decompression. [compressed_transactions.md](https://github.com/TomBriar/bitcoin/blob/2023-05--tx-compression/doc/compressed_transactions.md) In the document I describe a compression schema that's tailored for the most common transactions single parties are likely to make. In every case it falls back such that no transaction will become malformed or corrupted. Here's a PR for implementing this schema. [2023 05 tx compression](https://github.com/TomBriar/bitcoin/pull/3) Thanks- Tom.___ bitcoin-dev mailing list bitcoin-dev@lists.linuxfoundation.org https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev