Bitcoin Forum
June 14, 2024, 07:53:56 AM *
News: Voting for pizza day contest
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Bitcoin / Development & Technical Discussion / Re: Step by step guide to go from public key to a P2WSH Bech32 encoded address on: February 08, 2024, 01:29:32 PM
I think the result is correct, so whats the matter with that added half-byte in step 4? Sorry to be stubborn...
Nothing if your code can add 5 bits to an input that contains 8-bit values and you can handle the subsequent conversions and data interpretation.
But programmatically speaking, when our input is an octet string, anything added is also an octet (8 bit). So you should postpone adding the 5-bit version to when your octet string is converted to 5-bit array.

Hm, I think we're talking past each other... but I don't know how to express myself better...

Step 4 and step 6 are executed in the OP example, the result is correct. You are telling me that step 4 is wrong or should only be done at step 6. Then the result in OP should also be wrong, because there an 0 (halfbyte) is appended in step 4 (in addition to the added version byte in step 6)...

Can anyone else help? Probably nobody else at home here...

Thank you for your efforts pooya87 Kiss

2  Bitcoin / Development & Technical Discussion / Re: Step by step guide to go from public key to a P2WSH Bech32 encoded address on: February 06, 2024, 09:09:20 PM
Quote
What we have in step 4 is still an octet string (the hex) which means each value (2 characters) represents 8 bits. If we add OP_0 (0x00) in this step, we would be adding 8 bits which is wrong because witness versions are 5 bits added when the input's octet string was broken into 5-bit chunks.

If you look at the values in step 5, the first one is 0b00011000 which is 0x18 meaning OP didn't add OP_0 in step 4.
It was instead correctly added in step 6 as 0b00000 when we already have the 5-bit chunks 0b00011 0b00001 etc.
He did not add an OP_0 in step 4 but he sure did add a 0 in the end (4 bits 0000)... in addition to that, he added - as you mention -  the witness version in step 6 (as 00000 here). If you dont do both of that, you wont get the same result. So either both steps are necessary or the code provided (and the resulting adress) is wrong. I think the result is correct, so whats the matter with that added half-byte in step 4? Sorry to be stubborn...
3  Bitcoin / Development & Technical Discussion / Re: Step by step guide to go from public key to a P2WSH Bech32 encoded address on: February 05, 2024, 10:31:54 PM
4. Add OP_0 in back of the step 3
Code:
1863143c14c5166804bd19203356da136c985678cd4d27a1b8c63296049032620
can somebody explain this step, please?
...if anyone is here still....^^
That is a wrong step that OP didn't perform either! It's just written that way. The OP_0 (witness program version) is added in step 6 as a 5-bit integer before computing the Bech32 checksum instead of adding it as an 8-bit integer to the hex/bytes you have in step 4. If you do the later, it will break step 5 where you're splitting your hex into 5-bit chunks.

Thanks for the reply. What do you mean by OP didnt perform either? There seems to be an extra 0, yes. What am I missing?

Strangely enough it only works for me (in many other examples), when i execute this step 4 exactly as written... but I suck at programming and probably I made some mistakes in the latter steps...

In my code the result after step 4 (with the added 4 bits "0000") is
1100001100011000101000011110000010100110001010001011001101000000001001011110100 0110010010000000110011010101101101101000010011011011001001100001010110011110001 1001101010011010010011110100001101110001100011000110010100101100000010010010000 0011001001100010 0000

and after adding the padding 0 and the version number in the beginning it is
['00000', '00011', '00001', '10001', '10001', '01000', '01111', '00000', '10100', '11000', '10100', '01011', '00110', '10000', '00001', '00101', '11101', '00011', '00100', '10000', '00011', '00110', '10101', '10110', '11010', '00010', '01101', '10110', '01001', '10000', '10101', '10011', '11000', '11001', '10101', '00110', '10010', '01111', '01000', '01101', '11000', '11000', '11000', '11001', '01001', '01100', '00001', '00100', '10000', '00110', '01001', '10001', '00000']



4  Bitcoin / Development & Technical Discussion / Re: Step by step guide to go from public key to a P2WSH Bech32 encoded address on: December 30, 2023, 09:52:16 PM


4. Add OP_0 in back of the step 3
Code:
1863143c14c5166804bd19203356da136c985678cd4d27a1b8c63296049032620




can somebody explain this step, please?

...if anyone is here still....^^
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!