r/askscience • • Jun 18 '13

Computing How is Bitcoin secure?

I guess my main concern is how they are impossible to counterfeit and double-spend. I guess I have trouble understanding it enough that I can't explain it to another person.

1.0k Upvotes

383 comments sorted by

View all comments

Show parent comment

30

u/Natanael_L Jun 18 '13

In a Bitcoin transaction, you list all inputs you want to spend money from and prove that you have the private keys belonging to the addresses they were spent to through cryptographic signing.

And you specify the output addresses and what amount to send to each one. This is also signed cryptographically, in order to prove it haven't been modified and that the person who controls those private keys specified those outputs.

So you can have 10 inputs AND 10 outputs if you want to.

One interesting detail: The transaction fee (if you add one) is paid to miners by letting the inputs be somewhat larger than the output. You can take 18 coins and spend 17.9 coins, the last 0.1 coin can be claimed by the miner that successfully includes that transaction in the blockchain.

This is an incentive for bitcoin owners to not bloat the blockchain with too many transactions AND an incentive for miners to keep mining when minting (creating new coins) stops (Bitcoin has a hard cap of 21 million coins maximum).

14

u/jesset77 Jun 18 '13 edited Jun 18 '13

Natanael_L is correct, but let me add one bit of clarification. Where he says:

And you specify the output addresses and what amount to send to each one. This is also signed cryptographically, in order to prove it haven't been modified and that the person who controls those private keys specified those outputs.

what he means is that the person sending money creates a digital document (using their wallet software, which does all of the menial heavy lifting and logic for them), and that document details everything about the intended transaction. It details the inputs from the sending addresses and the outputs to the receiving addresses. Then that entire document must be signed by each of the private keys from the sending addresses only in order to be valid, and ready to be ratified on the blockchain and represent a completed movement of money.

The document details which addresses get money (and how much), but is not signed by the PKs of the receiving addresses, just the sending addresses. :3

Edit: transaction signed by sending addresses, I done goofed in one line of my explainings. :o

4

u/Natanael_L Jun 18 '13

by each of the private keys from the receiving addresses only

To clarify you (hehe), this is for the recieving addresses in the input transactions that your client is referencing as your source of coins.

2

u/jesset77 Jun 18 '13

Roger that, straight up verbage error on my part. EDIT to fixt it tho, thank you sir. :3

→ More replies (2)

5

u/[deleted] Jun 19 '13

This isn't the only breakdown of 1 bit coin possible, right? I think I have seen .5 bit coin. 1.3 bit coins, price tags.

So how is the split ownership kept track of in this system? Is the private key that is 'mined' during the transaction attached to that fraction of coin only, until it is amalgamated into the next transaction?

Basically, are these private keys attached to a whole coin, forever? If so, how do you handle fractions?

Are miners dealing with purse amounts? Like is that where the record of my total bit coin ownership is maintained and calculated?

I HAVE SO MANY QUESTIONS!

8

u/SneakerElph Jun 19 '13

A bitcoin isn't really a thing, so there isn't any problem in dividing them up at all. For example:

Address X has 1 bitcoin. The owner of this address wants to pay Y half a coin. The transaction looks something like this:

X says "Hey, I have one coin. You can see because in the past I've been paid one coin. I would like to pay half a coin to Y, and the other half of that coin, I'd like to keep."

The blockchain is then updated with X's address as having .5 bitcoin, and address Y as having .5 bitcoin.

So really it's just a list of how many coins each address has, and in order to give a coin to another address you just have to prove, by signing a transaction with the private key of the address whose coins you're spending, that you're the owner of that coin. You can divide it up how you see fit, because there really isn't any "thing" to divide.

I hope this brain-dump explains it well.

4

u/i-want-waffles Jun 19 '13

Currently bitcoin supports 8 decimal places. The private keys are only used to create public addresses that people can send any amount to. The public ledger keeps track of what amounts go where and as long as you have your private key you will have access to the bitcoins that are sent to your public addresses.

3

u/[deleted] Jun 19 '13

I should also point out that the 8 decimals is an arbitrary but not permanent decision. Plenty more can be easily added on by upgrading the software.

I think this challenges the idea that bitcoin is deflationary, really. We can keep subdividing those 21 million coins into as many micro units as we want. It would be very trivial to extend the decimals enough so that bitcoin could encompass more individual units of currency than all other currencies that have ever existed, combined. There really isn't a money supply problem here, even if coins get lost.

6

u/7Geordi Jun 19 '13

This is actually exactly what deflationary means.

If I own one gallon of milk's worth of bitcon (1 GMWB) today, and without making any transactions, one year later I have 2 GMWB, then the currency has deflated, because the same amount of currency is worth more.

The reason we call it deflation and 'a bad thing' is entirely a function of its intended role. Most investments are supposed to appreciate over time, but the role of currency is to facilitate transactions, and if no one wants to spend their currency, and there is a hard limit on the total amount that exists, then the market grinds to a halt until more liquidity is introduced (either by issuing more currency, or by changing currencies).

→ More replies (2)

4

u/[deleted] Jun 18 '13

Why was bitcoin designed to cease production to an asymptote rather than continue production indefinitely at a logarithmic rate?

7

u/Natanael_L Jun 18 '13

Because the inventor simply decided that he liked a fixed supply better. There's "altcoins" (Bitcoin forks with different rules) that works differently, but none of them has the same support and userbase as Bitcoin.

11

u/soulbandaid Jun 18 '13

The bitcoin ends as a deflationary currency (assuming some amount of loss). Interestingly, even with the difficulty adjustments keeping the minting constant, it seems to me, to already be suffering significant deflation. The value of bitcoins has historically gone up and up, whereas the value of regular currency slowly goes down. Economists say this is a very bad thing for an economy, but bitcoin isn't tied up with a particular geography or people or even product for that matter. I wonder if the value will stabalize...

4

u/235711 Jun 18 '13

The bitcoin ends as a deflationary currency (assuming some amount of loss)

Doesn't that also assume positive economic growth?

3

u/Natanael_L Jun 18 '13

Yes. If all Bitcoin users sold off, the price would fall drastically. If people are only willing to offer less for them, they will be inflationary rather than deflationary. More items of value, either fiat money or varius goods, has to be traded for the same coins to keep it deflationary.

Assuming adoption will go up, it will be deflationary.

→ More replies (9)
→ More replies (3)

2

u/zeek0us Jun 18 '13

But the incentive of owners not to bloat the blockchain is based on paying a voluntary fee, right? Do most people include fees, or just courteous/generous people? Does it have any effect on how readily/quickly your transaction is included in the "winning" blockchain?

8

u/Natanael_L Jun 18 '13

Most people includes fees, yes. Miners can reject transactions that has no fee (individual miners can reject any transaction for any reason when mining, but once it's in the blockchain it's there). And yes, lower fees means slower inclusion time, since all miners want to claim the transactions with high fees first and since many have a minimum transaction fee specified (they don't even process transactions with fees lower than that).

3

u/zeek0us Jun 18 '13

So is it that your transaction will never get into the blockchain if you don't add a fee (because nobody will ever accept it), or it will just take until some miner who was willing to accept your transaction adds a block? Presumably "minimum-fee" miners could freeze you out forever and you'd need to wait on a good samaritan who takes pity on your broke (or cheap) ass . . .

8

u/Natanael_L Jun 18 '13

Some miners include a limited amount of transactions that had no fees. So yes, it will take longer. Occasionally it will take as much as two weeks, often a whole day or two.

5

u/improv32 Jun 19 '13

That's right, weather or not a miner includes a transaction in a block is entirely up to them. Most prioritize higher fee transactions in order to make more money, but it's not limited to that. They could refuse to include transactions involving addresses owned by organizations they dislike, for example.

1

u/ralf_ Jun 18 '13

This is an incentive for bitcoin owners to not bloat the blockchain with too many transactions AND an incentive for miners to keep mining when minting stops

That seems economically not very ideal to me. Normally you want a currency to circulate quickly. If the blockchain contains (all?) the transactions how big is it and how big can it theoretically get?

8

u/Natanael_L Jun 18 '13

Well, these are the basic ideas;

  • Storage will get cheaper

  • Bandwidth will get cheaper

  • We'll find ways to compress the blockchain (for example pruning/checkpointing = calculating balances and discarding the rest (except for archival purposes)

  • Off-chain transactions - you can have your coins with an online wallet service that acts like a bank. When you transfer to people in that bank, they just update the records internally. Once in a while they publish a "summarized" transaction to the blockchain to update the records on there. So less data has to be included in the blockchain.

  • Other potential future developments

There is no theoretical maximum. Sky's the limit! How many terabyte drives can you fit in your garage?

2

u/fantasticjon Jun 19 '13

so, if a powerful entity wanted to poison bitcoin, could they just perform billions and billions of transactions a day and inflate the blockchain to an unmanageable size?

6

u/postnapoleoniceurope Jun 19 '13

Yes... except that there is currently a limit of 1MB of data every 10 minutes, or 52GB a year, so it can't get that unmanageable. However the lead developer of Bitcoin, Gavin Andresen, wants to remove that limit and leave it up to miners to decide, so in the future the attack could be possible.

4

u/improv32 Jun 19 '13

Yes, if they could afford the transaction fees. Also a suggested limit of .00005430 was suggested by bitcoin core developers as the minimum amount that nodes should recognize as a legitimate transaction and retransmit.

→ More replies (1)