Bitcoin Forum
May 08, 2024, 01:11:26 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: « 1 2 3 4 5 6 7 [8] 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 »
141  Bitcoin / Development & Technical Discussion / Re: An easy way to remember a bitcoin address on: March 08, 2015, 07:58:44 AM
Since you make the 'reference' transaction, you can make one that has a low number of txo. Let's say your txo index has to be < 4. 2 bits are enough to encode that offset. You want 20 bits of checksum so txo index and checksum fit in 22 bits or 2 words.

The block height is encoded with a continuation bit and either 20 or 31 bits for a total of either 21 bits if height < 2^20 (~1 million) or 32 bits if above but lower than (2^31). Add the version bit and it comes exactly to either 2 or 3 words.

TxIndex is simply encoded as words.

Recap:
# first part
- version bit: always 0
- length indicator
    - if 0: use 2 words
    - if 1: use 3 words
- block height

# 2nd part - always 2 words
- txo index: 2 bits
- checksum: 20 bits

# remaining words
- tx index

For any reference tx below index 2048 before height 2^20, it is guaranteed to be 5 words. The format is pretty constant and doesn't rely on txcount or the number of txo in the reference tx. Moreover, generation and parsing is straight forward.

142  Bitcoin / Development & Technical Discussion / Re: An easy way to remember a bitcoin address on: March 07, 2015, 05:29:14 PM
I'm not sure how to prove but it looks quite obvious.

y is a function of y1 and y2
y1 is a function of blockHeight
y2 is a function of w, x, c
Since blockHeight, w, x, c are all known value, there is only one possible value for y

Again, z is a function of z1 and z2
z1 is a function of blockHeight and txIndex
z2 is a function of w, x, y, c
If these values are all known, there is only one possible value for z
(Obviously, you can't determine z before y is determined)

Maybe someone can try to find a counter-example

I keep forgetting that it goes back to the beginning. Then there is no problem.
143  Bitcoin / Development & Technical Discussion / Re: An easy way to remember a bitcoin address on: March 07, 2015, 03:15:55 PM
Yeah, you end up using y1 and z1. The only time it's not the case is when txindex is small enough and utxo index = 0. If that's the intent, it's better to call it out explicitly and formulate a direct method (without loops). It'd be easier to prove that it's uniquely decodable. I think it's not worth the trouble and I'd discard that special case.

I think there are few possible situations.

Using y1 and z1: having enough space to fully encode txindex and outputindex (i don't call it UTXO index because I don't care whether it is spent or not.)

Using y1 and z2: having enough space to fully encode txindex, but not enough for outputindex. Here z2 could be anything from 0 to infinity

Using y2 and z=0: having not enough space to fully encode txindex, and outputindex is 0

So yes, if y=y2 is used, z must be 0.

That makes sense. The 2nd case implies that outputindex is small enough - so we are not talking about a large range actually. With 3 different paths, you need to prove that there is no overlap. Basically, proving the unicity of the encoded value.

Edit: What I mean is this: http://en.wikipedia.org/wiki/Variable-length_code - Uniquely decodable codes
144  Bitcoin / Development & Technical Discussion / Re: An easy way to remember a bitcoin address on: March 07, 2015, 02:28:29 PM
Yeah, you end up using y1 and z1. The only time it's not the case is when txindex is small enough and utxo index = 0. If that's the intent, it's better to call it out explicitly and formulate a direct method (without loops). It'd be easier to prove that it's uniquely decodable. I think it's not worth the trouble and I'd discard that special case.
145  Bitcoin / Development & Technical Discussion / Re: An easy way to remember a bitcoin address on: March 07, 2015, 01:57:58 PM
Right, I changed that to match your value but there is no need for it. Use tx output = 1 then. The point is that w gets incremented after y was chosen based on w=1.

See my BIP above. After increasing w, you should go back to step 3. In your example, you only go back to step 4
Well, I have a hard time seeing what you are implementing. I thought you meant to go to step 4 because if I have to go to step 3 the case isn't that useful.

If in step 3, y = y2 because you have enough bits left then you use them all. Next in step 4, there won't be any left. So unless utxo index = 0, you will have to increase w and go back to the beginning. What's the idea behind this case then?

This is different than what I think you meant in English.

Quote
In English:

If there is enough space, I'll use y1 bit to encode TxIndex. Otherwise, I'll use y2, given that it's enough to encode my interested tx. Otherwise, we need more words
If there is enough space after y is fixed, I'll use z1 bit to encode OutputIndex. Otherwise, I'll use z2, given that it's enough to encode my interested output. Otherwise, we need more words

146  Bitcoin / Development & Technical Discussion / Re: An easy way to remember a bitcoin address on: March 07, 2015, 11:19:39 AM
Right, I changed that to match your value but there is no need for it. Use tx output = 1 then. The point is that w gets incremented after y was chosen based on w=1.
147  Bitcoin / Development & Technical Discussion / Re: An easy way to remember a bitcoin address on: March 07, 2015, 10:23:06 AM
(It looks better in markdown)

Using the same values for `x=3`, `c=4` and the blockchain:
I want to encode a tx at index 3, output index = 0
My tx index is 11b. `y3=2` and `z3=1`
Now I go through the encoding steps.
- `w = ceil(3+2+0+4+1)/11 = 1`
- There are 40 tx, so `y1=6`
- `y2=11-1-3-4 = 3`
- `y=min(3,6)=3`
- `y3>y`? no. don't increase `w` but use 3 bits. txindex is encoded as `011`.

Next phase. Let's say there are 2 outputs in that tx.
- `z1=1`
- `z2=11-1-3-4-4 = 0`
- `z=min(1,0) = 0`
- `z3>z` ? yes. increase w. `w=2` and retry
- `z2=22-1-3-4-4 = 11`
- `z=min(1,22)=1`
- `z3>z` ? no. use `z=1`. utxo index is encoded as `0`.
- checksum takes `22-1-3-3-1 = 14` bits

My result is
`1010110xxxx-xxxxxxxxxx0`

Yours is
`10101100110-00110101010`

The beginning is the same. Let's say the checksum is 0110-xxxxxxxxxx
I get `1010110110-xxxxxxxxxx0`

The decoder will think the txindex is yours and fail to validate.
In fact, my address will fail for any value of the checksum because the decoder will look at a different tx than mine.



148  Bitcoin / Development & Technical Discussion / Re: An easy way to remember a bitcoin address on: March 07, 2015, 08:02:43 AM
You are only decoding to one of the possible pairs.
Just walk through the steps with my example if you don't believe me. I could be wrong, so it's good to have another person check. Better yet, post a reference implementation and anyone can verify.
149  Bitcoin / Development & Technical Discussion / Re: An easy way to remember a bitcoin address on: March 07, 2015, 06:35:47 AM
It's ambiguous because given an encoded value, you don't know where the separation between txindex and outputindex is.

To keep things simple, let's say
- x = c = 0
- w = 1
- and 8 bits per word instead of 11.

if i have 0101 0000, is it
- txindex = 0 and outputindex = 1010000 or
- txindex = 01 and outputindex = 010000 or
- txindex = 010 and outputindex = 10000 or
- txindex = 0101 and outputindex = 0000 etc

the checksum introduces another issue. Since it has variable length, where does it start?
150  Bitcoin / Development & Technical Discussion / Re: SHA256 Scheduler? on: March 07, 2015, 05:26:16 AM
Does Bitcoin just use the standard 64 rounds or does it require less?
It wouldn't be SHA-2 if it used fewer rounds.
151  Bitcoin / Development & Technical Discussion / Re: An easy way to remember a bitcoin address on: March 07, 2015, 05:23:04 AM
It's 54 because 1 is left for the version bit

To formal define:

Definitions:
The address takes w-words
Height will take x bits, where x is fixed.
Checksum will take at least c bits
TxIndex and OutputIndex are counted starting from 0.

We first set w = 1 (we may have a better initial value if x and c are known)
TxIndex will take y bits, where
  • y1 = ceiling(log(tx count in the block, 2))
  • y2 = 11w-1-x-c
  • y3 = ceiling(log(TxIndex of the interested tx + 1, 2)
  • y = max(y3, min(y1, y2))
OutputIndex will take z bits, where
  • z1 = ceiling(log(output count in the tx, 2))
  • z2 = 11w-1-x-y-c
  • z3 = ceiling(log(OutputIndex of the interested output + 1, 2)
  • z = max(z3, min(z1, z2))
Checksum will take 11w-1-x-y-z bits. If 11w-1-x-y-z < c, increase w by 1 and repeat until we find the smallest solution for w.

In English:

If there is enough space, I'll use y1 bit to encode TxIndex. Otherwise, I'll use y2, given that it's enough to encode my interested tx. Otherwise, we need more words
If there is enough space after y is fixed, I'll use z1 bit to encode OutputIndex. Otherwise, I'll use z2, given that it's enough to encode my interested output. Otherwise, we need more words


Hmmm ... The English description doesn't match the pseudo code (a bug?). Moreover, it looks like the intended algorithm has collisions (different pairs of inputs that lead to the same encoded value pre checksum).
152  Bitcoin / Development & Technical Discussion / Re: SHA256 Scheduler? on: March 06, 2015, 03:59:59 PM
Kinda. SHA-2 hasn't been cracked (i.e nothing better than brute force) but versions with a reduced number of rounds have. It's not very important because it's not the full SHA-2 and even there the complexity is still much too high for a practical crack. Of course, if you only perform a few rounds you are dead.
153  Bitcoin / Development & Technical Discussion / Re: SHA256 Scheduler? on: March 06, 2015, 07:59:05 AM
Yes
154  Bitcoin / Development & Technical Discussion / Re: BIP 32 questions on: March 05, 2015, 07:11:25 AM
A computer is generally better at producing random numbers than a human. Methods like shuffling cards, flipping coins, have been shown to be worse than a CRNG. Of course it relies on having access to one. The examples you mentioned just show that popular means little. Two fun facts:
- Casino slot machines use RNG
- Flipping is coin is biased towards the starting state

In any case, it's a matter of being practical too. Flipping a coin 128 times to get a seed is fine. Doing it for every address generated is crazy. I remember a story about the one time pad. During WW2, a team was in charge of making the pads. After a while, they got tired and started reusing them. It didn't take long before the codes were broken.


155  Bitcoin / Development & Technical Discussion / Re: Pushing Partially Signed Transactions to other Bitcoin Clients on: March 04, 2015, 02:29:46 PM
Dealing with unsigned tx is a wallet job and therefore not part of the P2P protocol. There is no standard for their format and wallets serialize them with various degree of information attached. Just putting the raw bytes is usually not deemed secure enough because it gives no indication of the values of the inputs. It's a tough choice that offline wallets have to make.
156  Bitcoin / Development & Technical Discussion / Re: Counting the number of tx in a block without downloading the whole block? on: March 04, 2015, 10:16:45 AM
On a related note, what's the reason why the tx-count in the block header retrieved by getheaders always 0? It seems it would be as easy to return the actual count.
157  Bitcoin / Development & Technical Discussion / Re: SHA256 Scheduler? on: March 03, 2015, 04:36:16 PM
Why does it need to be expanded if the input has already been compressed/padded?

You state that is expands it into an array of 64 x 4 bytes which turns into the message schedule.

From what I'm seeing, the data in the message scheduler is also part of the data you're compressing but it is somehow separate from the "compressor" as labeled in the diagram.
This "Expander", which is part of the message scheduler, takes in "Wt", a chunk of data from the message schedule and "Kt", a predefined constant. I assume I understand this correctly?
These diagrams have to be read as if everything executes in parallel because that's what the hardware will do. Each box contains one word (= 4 bytes) and on the next clock tick, every arrow is 'executed' and it repeats. It's not a description of the algorithm that someone will use to write code but it shows how to do it in hardware. It is better for finding the critical paths, i.e. the paths that take the longest time because they involve more steps.
158  Bitcoin / Development & Technical Discussion / Re: SHA256 Scheduler? on: March 03, 2015, 07:06:24 AM
Yes, the expander part is the message schedule.

- First, the message is padded.
- Hashing starts with a predefined value as the intermediate hash
- then it takes a block of message input (64 bytes) and it expands it to an array of 64 x 4 bytes. It is called the message schedule.
- then it runs 64 times the same bit manipulation function (the compression function) on the intermediate hash value. Each time is called a round and it uses one element of the message schedule `Wt` and one predefined constant `Kt`.
- After 64 rounds are finished, it goes to the next message block.
- Once the message is consumed, the intermediate hash is the result.

Each little rectangle with an arrow in the expander contains one element of Wj. It's basically a buffer of 16 x 4 bytes. The first 16 elements are the same as the input message block.
The rest is defined as Wj = o1(Wj-2) + Wj-7 + o2(Wj-15) + Wj-16. The expander calculates one element of Wj that it feeds into the compression function. In the next round, the buffer shifts and one new Wj gets calculated.
159  Bitcoin / Development & Technical Discussion / Re: An easy way to remember a bitcoin address on: March 02, 2015, 02:57:51 AM
A bip 32 seed is 128 bit long and takes 12 words. How did you figure out to use only 4?
160  Bitcoin / Development & Technical Discussion / Re: An easy way to remember a bitcoin address on: March 02, 2015, 02:27:50 AM
Initially I wanted to encode BlockHeight,TxIndex,TxoutIndex as you said.
If Alice asks to Malicious to resolve BlockHeight,TxIndex,Txout Index and Malicious resolve to address X, then Alice need a proof that Malicious is not lying.
If you use TxIndex, this proof must be the whole block at BlockHeight (which is big) OR the blockheader + list of all transaction id inside. (which is not supported by the bitcoin network)
No, you take the txindex and interpret it as a position in the merkle tree. The tree has all the tx ordered by index as its leaf. It's the same value.
Pages: « 1 2 3 4 5 6 7 [8] 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 »
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!