Bitcoin Forum
April 25, 2024, 06:51:12 AM *
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 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 »
441  Bitcoin / Development & Technical Discussion / Need mathematical proof for CH and MAJ functions in SHA256 on: May 04, 2019, 06:41:18 AM
The SHA256 implementation that bitcoin-core is using has a different set of functions for CH and MAJ operations done in this hash function. While they both are nice little optimizations for skipping 1 bitwise operation, I can't figure out the mathematical proof for them being the same.

For reference:
Code:
CH = (x & y) | ((~x) & z)
CH_alt = z ^ (x & (y ^ z))
Code:
MAJ = (x & y) ^ (x & z) ^ (y & z)
MAJ_alt = (x & y) | (z & (x | y))

CH and MAJ are the functions from FIPS 180-3 while CH_alt and MAJ_alt are from bitcoin-core source code
442  Bitcoin / Hardware wallets / Re: 19 out of 24 words of BIP39 passphrase (brute-force last 5?) on: April 30, 2019, 04:02:21 AM
I dug up my old hacky script (find_missing_seed_word.py) that allows you to specify the words you know and put an 'x' in for missing words. On my system it seems to be able to "find" valid seeds (not even generating keys etc) at a rate of around 1,000,000 in 7-8 minutes... Granted, it probably isn't the most optimised script (it has file writes for logging etc) as my python skills are pretty poor, but it should be "ballpark"

If all you do is check if a set of words is a valid BIP-39 seed then it should not take more than half a minute* for 1 million keys not 7-8 minutes even without optimization. You are basically doing a SHA256 on a 264 bit input (entropy) so it is only 1 rounds of block mixing under the hood.
* The value is based on my test on 1 CPU core on a corei3 CPU with c# code of my own writing. With some SHA256 optimization, with parallelization (using all the cores) and some other optimization of the code the time can be reduced to less than 5 seconds for 1 million variations.
443  Bitcoin / Development & Technical Discussion / Re: Data routing for money, rather than payment routing for money. on: April 30, 2019, 03:39:32 AM
Is there a way of delivering the data over a simple p2p network - in a decentralised way - much like LN  (where you are guaranteed payment for your work - hence more likely to offer your services) ?

The problem is when you are adding the payment option in this design. First you have to decide whether this is a simple file sharing between peers (like Torrent) or is it a file selling between a content creator and his customers.
In either case I don't see any reason why you need a middle man (router) like LN since the file is only held and stored by the owner and nowhere else and he is already uploading it every time someone wants it.

If it is file sharing them it is just a matter of knowing the IP address of the one with the file and connecting to it. Basically P2P Torrent network instead of being a semi-P2P Torrent network (eliminating trackers).
If it is file selling it is the same as before but you only need a way to ensure payment, a multi signature scheme might work here.
444  Bitcoin / Development & Technical Discussion / Re: How to create a Bech32 (bc1) address with PHP standalone? on: April 25, 2019, 07:16:00 PM
Ok. So, what would be the Bech32 (bc1) address derived from the following?
Private Key(Hex): C070A5ECF7138485E5FBC3561BC43D0C3C6052397768B1A7CB996444E8CB917D
Public Key(Compressed): 0228B2993B17F77EB967F3761F72B6B35E4B5C229D5208771F4C9154C42CE7CC13
You can use https://segwitaddress.org/bech32/ to test things on the web (it only accepts WIFs which you can convert from hex using bitaddress.org) or use any wallet that supports importing keys and Bech32 addresses.
This would be the resulting address:
Code:
bc1qemht6dcq0cxkam9z7f9lyqwztqtr5c7zszu2f9

Fantastic guide. Do you know any PHP code, which does this?
No, but a search on GitHub returns one result: https://github.com/Bit-Wasp/bech32 (use at your own risk)
445  Bitcoin / Development & Technical Discussion / Re: How to create a Bech32 (bc1) address with PHP standalone? on: April 25, 2019, 03:14:24 AM
Can these addresses be derived from legacy private key?
There is no such thing as "legacy private key". There has always been 1 type of private key, which is a number from 1 to curve's n-1.

Any step by step instruction similar to this, will be of great help.
https://bitcointalk.org/index.php?topic=4992632.0
Step 0 for you would be to get the public key from private key as you would any other time (private key * G).
446  Bitcoin / Development & Technical Discussion / Re: How are BIP173 test vectors "valid"? on: April 24, 2019, 04:12:05 PM
Bech32 encoding is relaxed about padding,

That is the part missing from the bip...
447  Bitcoin / Development & Technical Discussion / How are BIP173 test vectors "valid"? on: April 24, 2019, 01:40:57 PM
There are 7 test vectors at the top of the list that are supposed to be "valid Bech32" but I can't see how they are valid.
These have no data since the bytes after the separator is the 6 byte checksum:
A12UEL5L
a12uel5l
an83characterlonghumanreadablepartthatcontainsthenumber1andtheexcludedcharacter sbio1tt5tgs
?1ezyfcl


These have data but none of them are properly padded! They all have leftover non-zero bites (3 or 5)!
abcdef1qpzry9x8gf2tvdw0s3jn54khce6mua7lmqqqxw
11qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq qqqc8247j
split1checkupstagehandshakeupstreamerranterredcaperred2y9e3w


I can get the first group being valid since that is just encoding of empty data (which is not SegWit address and just encoding) but the second group doesn't make sense, shouldn't the data be properly padded in those too?
448  Bitcoin / Development & Technical Discussion / Re: Is the "data" after OP_RETURN strictly a script? on: April 09, 2019, 12:10:18 PM

Thanks but I was hoping for a bit more than just what you could find on Google. For example most validation stuff seems to be happening in validation.cpp but I can't find anything related to my question and I always have a hard time reading c++ code so I don't even know if I'm in the right place or not!
449  Bitcoin / Development & Technical Discussion / Is the "data" after OP_RETURN strictly a script? on: April 09, 2019, 10:16:16 AM
(1) I can't figure out whether the data in OP_RETURN can be an arbitrary data with any format or or should it be formatted properly as a script. So when reading the transaction would it fail if it is not a proper script or ignored?
For example can the PubkeyScript be the following:
Code:
6a20
or should the "data" which is 0x20 here also be correctly formatted like this:
Code:
6a0120
The difference between the two is that the first one, if read as a script, tells you push 0x20 byte data but has no data afterwards. The second one, if read as a script, tells you to push 0x01 byte and is followed by a single byte (0x20).

(2) If it is being interpreted as a proper script, can it contain any script code or are there limitations? (I do realize the script won't run since it is OP_RETURN!).
Is this example valid? (contains OP_DUP and OP_SHA1 after the PUSHDATA):
Code:
6a012076a7

(3) Also is there anywhere I could see all the changes to OP_RETURN rules, any historical limits including but not limited to size?
450  Bitcoin / Development & Technical Discussion / [script] I'm confused about negative zero! on: April 02, 2019, 02:49:44 PM
All these numbers we are pushing on the stack are integers (Int32 or Int64 where there is an overflow chance). right?
There is no negative zero defined for integers! The negative zero in IEEE 754 is defined for floating point numbers (float and decimal)!
So what these lines are doing with [0, 0, 0, 0x80] is actually interpreting a completely different value (-2147483648) as so called negative zero by mistake.

What am I missing here?
451  Bitcoin / Electrum / Re: Needs android: safe ish way of using gole electrum from your desktop on: April 01, 2019, 05:35:30 PM
It isn't that hard either. I just never knew how scripts worked when I started that project and never gotten around to upgrade it until now.
As for the size, there are certain small changed that can help create a smaller QR code. For example making the hex uppercase would make a big difference. Or you can do what Electrum does and use the Base-43 encoding on it before you turn it into QR.
Base-43 is exactly the same as Base-58 but with these character:
Code:
0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ$*+-./:
452  Bitcoin / Electrum / Re: Needs android: safe ish way of using gole electrum from your desktop on: April 01, 2019, 01:18:59 PM
Funny thing is that I created my BitcoinTransactionTool project for the same reasons on top of other things. Basically you are looking for a way to make an unsigned transaction and give it to your cold storage for signing.
I haven't had time to work on it anymore ever since I made it and Electrum has changed a lot, but I'll probably fix its bugs and release the new version this month if I can get the script part of my library finished Tongue
Feel free to take a look at the code to get the idea (you can find it in my signature).
453  Bitcoin / Bitcoin Technical Support / Re: How does one derive a SegWit address from a legacy address? [0.001 BTC Reward!] on: April 01, 2019, 01:11:00 PM
This part is false.
G is not exactly a "constant" and is not derived from the curve. G is one of the point on the curve that we have chosen as the "generator" of the curve. And that means multiplying any value from 1 to order of G yields another point (not a string of characters!!) on the curve which would be your public key. And that is the basic of asymmetric cryptography.
So, you do say that they are not constant. But from what I have read in Mastering Bitcoin Book, the author says that "G is a constant point and they are always same for all keys in bitcoin."

Well, I said "not exactly" so it is somewhat correct and when I said "false" I mostly meant the second part of what I quoted.
But basically when you are talking about elliptic curves in general, G is simply a point on the curve. In a specific curve like secp256k1 which bitcoin uses, there is only one G that is used as a standard for that curve.
454  Bitcoin / Bitcoin Technical Support / Re: How does one derive a SegWit address from a legacy address? [0.001 BTC Reward!] on: March 29, 2019, 03:50:48 PM
I have a question: since a legacy address corresponds to several SegWit addresses, how does your program know which one to get? I specifically need a way to derive 3H2miXstFo3jRFfz5ekcdZJNMfGSYHeNvB from the 1XXX address. Is this doable?

As far as I understand the algorithm, there is only one possible P2SH-P2WPKH with current and only witness program version and that's what this code is giving you.
455  Bitcoin / Development & Technical Discussion / Re: What are the variable types of "sizes" inside signatures? on: March 29, 2019, 03:17:51 PM
Both of those are OP_PUSHDATAs with size 72.

In any script, if a length is specified in order to push data, it's an OP_PUSHDATA, not a compact size int.

Thanks but now this no longer makes sense: https://bitcoincore.org/en/segwit_wallet_dev/#transaction-serialization
"Each witness field starts with a compactSize integer to indicate the number of stack items for the corresponding txin"

Additionally there is fd0102 value indicating the size of the public key script in the SegWit transaction which is in fact a CompactInt not an OP_PushData which should have been 4d0102 indicating length of 513 bytes (which is available in the legacy transaction as an OP_PushData). Note that these transactions were created by Electrum and are already in (TestNet) blocks.
456  Bitcoin / Bitcoin Technical Support / Re: How does one derive a SegWit address from a legacy address? [0.001 BTC Reward!] on: March 29, 2019, 03:11:22 PM
I've added the files I mentioned above with a release which you don't have to use if you compile it yourself.
I've also added a bunch of comments in the main function to clarify what is happening. The rest of the code is also fully documented (since I copied them over from my main library project) so the functions purposes should be clear enough.
457  Bitcoin / Bitcoin Technical Support / Re: How does one derive a SegWit address from a legacy address? [0.001 BTC Reward!] on: March 29, 2019, 02:46:17 PM
That would be a massive help! If you can code up something that links the two addresses, or point me towards an online resource that does the job, it would be amazing. You'll get the reward as well, if you care for that sort of thing  Tongue Bless you!

Here you go. https://github.com/Coding-Enthusiast/AddrConverter (going to add ReadMe, License and release in a minute)
And don't worry about "reward".
458  Bitcoin / Bitcoin Technical Support / Re: How does one derive a SegWit address from a legacy address? [0.001 BTC Reward!] on: March 29, 2019, 01:57:45 PM
Thanks. So I'm trying to figure out how to do the first method, but I'm not sure which app or website to input the steps in. I tried it in Bitcoin Core and coinb.in; didn't seem to work. Please do excuse my ineptitude.

Well those applications all have the code to do all these stuff but they don't usually expose the functions through any kind of CLI because it is not used. You'll have to write something yourself. I can put together something for you in c# for the first part only (not the public key recovery) if you like.
459  Bitcoin / Bitcoin Technical Support / Re: How does one derive a SegWit address from a legacy address? [0.001 BTC Reward!] on: March 29, 2019, 01:35:25 PM
how to link the 1XXX address to the 3XXX address without me having to retrieve the Ledger from its stored location.

Things you can not do:
- Get the 1xxx address from 3xxx address
Things you can do:
- Get the 3xxx address from the 1xxx address1
- Get either 1xxx or 3xxx or basically anything else if you have published a signature with a message that you signed (this includes transactions that were spent from that key)!2

Here are the steps for (1)
1. Having the address starting with 1, perform a Base58check_decode on it to get the byte array remove the first byte as it is the version byte. The next 20 bytes are the hash160 (you can also open the address in blockchain.com explorer and it shows you the hash160 result!)
2. Write the "witness script" for the current version of SegWit which is
Code:
0x00 0x14 <hash160>
3. Perform HASH160 hash on the result of step 2
Code:
RIPEMD160(SHA256(<witness script>))
4. Append the P2SH version byte (=0x05) to the beginning of the result of step 3 and perform a Base58Check_encode on the result
Code:
Base58.EncodeWithCheckSum(0x05 || <hash160>)
=> now you have your P2SH-P2WPKH address that starts with 3.

Here are the steps for (2):
1. Decode your signature (base-64) and throw away the first byte. Then your first 32 bytes are your r value in little-endian order and the second one is s.
2. Append the default message to  your message (Bitcoin Signed Message:\n) with its length. Compute double SHA256 of it. This is the "message".
3. Recover your public key by knowing (r,s) and message. (I haven't released my library yet to add that as a reference but you should be able to find  this option in any library such as OpenSSL that has ECDSA capabilities)
4. Perform HASH160 on the compressed public key as bytes.
5. Feed it to step 2 of above.

This is the reference but in my opinion it is very vague: https://bitcoincore.org/en/segwit_wallet_dev/
460  Bitcoin / Bitcoin Technical Support / Re: How does one derive a SegWit address from a legacy address? on: March 29, 2019, 01:00:07 PM
Just curious, is there any documentation as to how you just did that?
Standards for Efficient Cryptography SEC 1: Elliptic Curve Cryptography
Section 4.1.6 Public Key Recovery Operation (Page 47)

That's pretty cool, thanks.

So I've been Googling around. Using validateaddress in Bitcoin Core gives me "scriptPubKey": "a914a84658b58e2bd0e62bfb1905dfcc19415bf99ff387" when I submit the address 3H2miXstFo3jRFfz5ekcdZJNMfGSYHeNvB. I wonder if this has any relation to the public key or the 1XXX address.
I honestly don't know. I still have not been able to figure out how this particular type of address is derived from keys.
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 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 »
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!