Bitcoin Forum
May 24, 2024, 05:36: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 »
81  Bitcoin / Development & Technical Discussion / Re: What's the reason for not being strict about Taproot witness program size? on: May 30, 2021, 02:34:26 PM
But isn't that about the "spending" script put in the witness not the pubkey script where the program is?
82  Bitcoin / Development & Technical Discussion / What's the reason for not being strict about Taproot witness program size? on: May 30, 2021, 11:28:17 AM
Witness version 0 is strict and will fail if the program size is not 20 or 32 bytes but witness version 1 will simply assume the program is undefined and passes on verification. What's the rational for keeping this loose?
https://github.com/bitcoin/bitcoin/blob/55a156fca08713b020aafef91f40df8ce4bc3cae/src/script/interpreter.cpp#L1878
Code:
if (witversion == 0) 
{
  if (program.size() == WITNESS_V0_SCRIPTHASH_SIZE){}
  else if (program.size() == WITNESS_V0_KEYHASH_SIZE){}
  else { set_error (...) }
}
else if (witversion == 1 && program.size() == WITNESS_V1_TAPROOT_SIZE && !is_p2sh)
{...}
else
   return true;
83  Bitcoin / Development & Technical Discussion / Re: [C#] Trying to implement EC Multiplication in pure code on: May 23, 2021, 11:01:00 AM
I don't know how to turn this PublicKey to string. Obviously, ToPublicKey().ToString() didn't work.
Assuming you are using the PublicKey class provided here you have to call the ToByteArray() method and then encode the bytes however you want. byte[] has a special extension method to convert to hexadecimal called ToBase16().

BTW if you want to get public key of a private key it is best to use the PrivateKey class directly since it makes sure you have a valid key.
Code:
var key = new PrivateKey(rng_or_wif_or_bytes_or_int);
string compPubHex = key.ToPublicKey().ToByteArray(true).ToBase16();
key.Dispose();

Also, how do I get rid of Autarkysoft.Bitcoin.Cryptography.Asymmetric.EllipticCurve each time I want to include a part from EllipticCurveCalculator to my main c# script? I'm imported lots of usings, but it seems that it always needs the namespace:
I'm not sure what you are asking here. Each .cs file has to have the using directives before you can use the types in that namespace. This is not something you can get rid of.
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/using-directive
84  Bitcoin / Development & Technical Discussion / Re: [C#] Trying to implement EC Multiplication in pure code on: May 23, 2021, 03:54:02 AM
but I am not sure that I understand these terms. I do have understood theoretically how ECC works, but in its maths, it seems impossible to make any sense.
Unless this is just for educational purposes you shouldn't do it. Use a library like libsecp256k1 with a wrapper in C#.

That being said, it'd really satisfy me if there's an already written code (just like in learnmeabitcoin) in C#.
Bitcoin.Net has an EllipticCurve namespace which is a very simple implementation of ECC.
Private key to public key code would be MultiplyByG(BigInteger k) method.
Keep in mind that this is minimally tested using NIST Cryptographic Algorithm Validation Program since I plan to completely replace it before releasing version 1.0.

If you want to see a more efficient implementation based on libsec256k1 check out the ECC namespace in FinderOuter.
85  Bitcoin / Project Development / Re: Denovo (v 0.1.0) and Bitcoin.Net (v 0.12.0) on: May 21, 2021, 01:35:37 PM
What part of ElectrumMnemonic.cs does it convert the entropy to phrase?
After you instantiate a new instance using one of the constructors, you can call the public method called ToMnemonic() to get the string of words.

But if you want to see how the entropy is being converted you have to look at the private method called SetWordsFromEntropy(byte[] entropy) which is basically brute forcing the entropy to get one that corresponds to the required seed type.

What should I import to make the new script read from ElectrumMnemonic.cs? I've imported these, but it can't find the “type or namespace”.
ElectrumMnemonic class is found under Autarkysoft.Bitcoin.ImprovementProposals namespace. Also if you click on that little dropdown in your screenshot intellisense should give you the correct suggestion.

Just to say that there's a mistake here: GetMnemonicType?
Thanks.
86  Bitcoin / Project Development / Re: The FinderOuter, a bitcoin recovery tool (v0.10.0 2021-05-05) on: May 05, 2021, 05:59:04 AM
Version 0.10.0 is released.
https://github.com/Coding-Enthusiast/FinderOuter/releases/tag/v0.10.0.0
See changelog for details.
BigInteger Be Gone!
This release introduced a new code for Elliptic Curve Cryptography that also solves issue #9. 
Effectively this brings a ton of optimization to almost all options, mainly the mnemonic recovery and
Base16 rcovery. But also any option that required an ICompareService that used ECC. 
By getting rid of the old ECC code and BigInteger this also solves the pressure on garbage collector
and lets FinderOuter utilize the entire CPU power during parallelism. 
Speed gain in this release is usually around 200% compared to previous releases. 
Good news is that this is the initial step for more optimization! For example the current ECC implementation
uses radix 226 and contstant time operations, changing to radix 252 and using variable time operations, etc
will improve the speed more. 

Some additional changes:
  • Path recovery can now accept any extended keys (xprv, ypub, zprv, ?pub, ...)
  • It is now possible to recover a WIF missing up to 11 characters from the end
  • Reports generated by MissingEncoding option are improved
  • Various code improvements and tests
  • From this version we are also releasing binaries for 3 operating systems (Linux, Windows and MacOs all x64)
87  Bitcoin / Development & Technical Discussion / Re: Shouldn't DNS seeds avoid returning pruned nodes? on: May 03, 2021, 01:54:04 AM
Though I also should have mentioned, you shouldn't sync from just the DNSseed results, you should learn addresses from them.   Syncing just from them results in more uneven distributions of load.  Bitcoin Core works pretty hard to not contact dnsseeds at all and usually only does on first run or after being offline for a long time.
That's what I was doing, but my list was old since I hadn't worked on it for over a month and I was checking 200+ IPs with a socket that has a 30 second connection timeout. So I had to do a manual reset and fall back to DNS seeds.
Plus for some reason the couple of nodes (from DNS) seed I connected to didn't reply to my GetAddr message.
88  Bitcoin / Development & Technical Discussion / Re: Shouldn't DNS seeds avoid returning pruned nodes? on: May 02, 2021, 12:55:26 PM
Could you please elaborate?
A nifty way to do so is to append the desired strings[1] as a subdomain to query. For example, nslookup x9.dnsseed.bluematt.me.

This will work if the DNS seeder supports service bits filtering[2].


[1] https://github.com/sipa/bitcoin-seeder/blob/a09d2870d1b7f4dd3c1753bbf4fd0bc3690b7ef9/main.cpp#L165
[2] https://github.com/bitcoin/bitcoin/blob/7cb0bcb6811070786937fb5cc0af82cf4ef21ff0/src/chainparams.cpp#L121
Thanks for the info, it is useful. But unfortunately this seems to return nodes that have these flags not nodes that have only these flags which means it still returns a node with NODE_NETWORK_LIMITED flag if it has the specified flag too.
89  Bitcoin / Development & Technical Discussion / Re: Shouldn't DNS seeds avoid returning pruned nodes? on: May 02, 2021, 09:09:09 AM
You can request which service flags you want from the seeds.
Could you please elaborate?
90  Bitcoin / Development & Technical Discussion / Shouldn't DNS seeds avoid returning pruned nodes? on: May 02, 2021, 07:31:09 AM
Considering the fact that nodes mainly dig DNS seeds when they start for the first time why are they returning pruned nodes (NodeNetworkLimited)?
Right now almost all IP addresses returned from DNS seeds are pruned nodes which has made downloading blocks impossible for me.

Another issue I noticed is that some of the addresses they return are not useful at all (I either get timeouts or the connection is refused or there isn't any node at all to connect to).
For example the following list is a handful of invalid IP addresses that seed.bitcoin.sipa.be returns:
Code:
95.116.33.86
15.185.229.194
34.101.110.211
68.104.65.149
52.78.217.89
34.86.209.19
91  Bitcoin / Development & Technical Discussion / Re: Python HEX generator Range based on: April 27, 2021, 07:56:15 AM
Ok, that might seem like a lot for your program, the FinderOuter, but I could check 5.8 billion in seconds.
Then you are more skilled than I.
But please note that the check here is against an address not a public key so algorithms such as Pollard Kangaroos, and Baby Step Giant Step can't work.

just telling how long it would take for you to find it with a slower program?  Who knows...
I'm not just reporting the time, I'm offering an existing solution and in case it wasn't clear the link to FinderOuter is found in my signature.
Announcement: https://bitcointalk.org/index.php?topic=5214021.0
Source code: https://github.com/Coding-Enthusiast/FinderOuter
92  Bitcoin / Development & Technical Discussion / Re: Python HEX generator Range based on: April 27, 2021, 03:59:07 AM
11 characters at the end? Should take seconds, not hours or days.
It depends on whether the key is compressed or uncompressed. For a compressed key you have to check about 22 million while for an uncompressed key the number is 5.8 billion.
            // Numbers are approximates, values usually are ±1
            //         Uncompressed ;     Compressed
            // 1-5 ->             1 ;              1
            // 6   ->             9 ;              1
            // 7   ->           514 ;              3
            // 8   ->        29,817 ;            117
            // 9   ->     1,729,387 ;          6,756
            // 10  ->   100,304,420 ;        391,815
            // 11  -> 5,817,656,406 ;     22,725,222
            // 12  ->               ;  1,318,062,780


For the first case it takes about 2 minutes to check all the keys using FinderOuter
93  Bitcoin / Project Development / Re: [C#][Github] SharpPusher, broadcast BTC, BCC(BCH) transactions to the network on: April 23, 2021, 11:41:38 PM
Compiled binaries for version 0.11.0 was released and can be found here: https://github.com/Coding-Enthusiast/SharpPusher/releases/tag/0.11.0.0
They are available for Linux, OSX and windows all x64. If you need any other OS you'll have to compile the code yourself.
All of these releases are published as a self contained app which means you won't need to download anything extra including the .net framework since it is already included in the package. That also makes them portable too.

PS. There is a small change where a new checkbox is added to allow users to locally evaluate the transaction without broadcasting it. It will deserialize the transaction hex and evaluates all its scripts without executing them.
94  Bitcoin / Project Development / Re: The FinderOuter, a bitcoin recovery tool (v0.9.0 2021-04-05) on: April 23, 2021, 05:22:54 PM
I am getting the following error when loading FinderOuter in VS2019:

Code:
error  : The project file cannot be opened. Unable to locate the .NET SDK. Check that it is installed and that the version specified in global.json (if any) matches the installed version.

I'm clueless, because I already have .NET SDK and tools installed. Any ideas?
This is a Visual Studio related problem. Refer to SO: https://stackoverflow.com/questions/65209536/microsoft-visual-studio-2019-the-project-file-cannot-be-opened-unable-to-locat
95  Bitcoin / Project Development / Re: Denovo(v0.1.0)Bitcoin.Net(v0.12.0) on: April 23, 2021, 06:27:34 AM
Version 0.8.0 released.
  • Improvments mainly in ReplyManager and Blockchain for handling communication and header verification
  • Target stuct is improved to handle edge cases in compliance with consensus rules
  • IConsensus has a couple of new properties and methods
  • Multiple new Constants are added
  • NodeStatus properties are pure properties and new method is used to signal disconnect instead
  • Block headers are now processed directly through IBlockchain instead of IClientSettings
  • Client can now store and report its own IP address after receiving Version messages
  • Client is now capable of downloading, verifying and storing the entire block headers
  • Client's communication is based on INode's protocol version
  • Added a new word list: Portuguese (affects BIP-39, ElectrumMnemonic but not defined for BIP85)
  • Various bug fixes, tests and some improvements
Version 0.9.0 released.
  • Major changes in P2PNetwork namespace involving initial connection
  • Introduce ClientTime to get/set client time using other peers
  • Block headers now store their hash locally with an option to recalculate hash
  • Fix some issues in Node class when it got disconnected
  • Fix some issues in NodePool class with locks
  • Introduce BlockchainState and respective events to be raised when it changes
  • Peers are selected based on BlockchainState and their service flags, all handled by ClientSettings
  • Introduce a new timer for each peer to disconnect them when they are not responding to requests (this is important when syncing)
  • Improve the initial handshake to send "settings" messages based on protocol version of the peer
  • Add some new constants
  • Various optimization, tests and small improvements
(IStorage will be completely removed in next release)
Version 0.10.0 released
Implemented initial block synchronization code in Blockchain and respective classes
  • IUtxoDatabase and IFileManager have new methods
  • Add a new UTXO class
  • Mandatory ClientSettings properties are read only and can only be set in its constructor, the rest can be set using the respective property setter
  • To reduce memory usage some properties are placed in ClientSettings and are accessed from all threads (by different node instances)
  • RandomNonceGenerator is thread safe now
  • (I)Storage is entirely removed
  • Hash and HMAC functions are all sealed
  • IHashFunction and its IsDouble property are obsolete and will be removed in next release.
    Use the new ComputeHashTwice method instead1
  • Various bug fixes, tests and improvements
1 The interface and the idea for the IsDouble property is a leftover from before the library became Bitcoin.Net and was supposed to be Cryptocurrency.Net instead.
New Denovo feature
Encrypt and decrypt messages using Elliptic Curve Integrated Encryption Scheme (ECIES).
Encoding of the input or the output can be anything from the list of options that are available:


Version 0.11.0 released.
  • New BIP: Bech32m format for v1+ witness addresses (BIP-350)
  • All encoders are static now and have a TryDecode method
  • Validity check by encoders is 2 methods now: IsValid (checks characters) and IsValidWithChecksum (checks both) unless the encoding doesn't have encode without checksum like Bech32
  • IHashFunction is removed
  • IsDouble is removed
  • Almost every class in Cryptography namespace is sealed now
  • Various improvements, additional tests, bug fixes and small XML doc fixes
Version 0.12.0 released.
  • Add new SizeCounter class used by IDeserializable objects to compute the size of the object without serializing it first
  • FastStream class is now using the same initial capacity instead of increasing small ones to DefaultCapacity
  • New Experimental idea: Better mnemonic
  • New BIPs: 44 and 49 (BIP-32 related derivation paths and version bytes used in Base58 encoding)
  • Transaction class is modified to store size and hash and allow manual update
  • Various tests, some small code improvements, bug fixes and optimization
96  Bitcoin / Development & Technical Discussion / Re: Need help with Python Scrict Private Key Search on: April 21, 2021, 10:53:14 AM
Looks great, i have win 10, does it run on it ?
Yes, FinderOuter can run on all operating systems.
You have to compile the source code yourself for Windows, although I suggest always dealing with private keys on an air-gap machine.
Steps are explained in ReadMe file on GitHub.
Remember to use release configuration:
Code:
dotnet build --c Release
97  Bitcoin / Development & Technical Discussion / Re: Need help with Python Scrict Private Key Search on: April 21, 2021, 06:09:41 AM
Like i say the PK with the 5 at the start has 42 Characters left,
The PK with the L5 has 43 characters left.
Check out my project, The FinderOuter.
In "Missing Base58" option enter the characters you have and replace the remaining missing characters with '*' and click Find button.
Look at examples 3 and 4 for more information.


The optimized method works for up to 11 missing chars at the end of a compressed key and up to 9 for uncompressed. Since you are missing 9 for both it works for you. I'll optimize it soon to support more.
98  Bitcoin / Development & Technical Discussion / [Experimental-2] Better mnemonic on: April 13, 2021, 06:56:38 AM
We're trying to address some of the problems and shortcoming with the existing mnemonic algorithms namely BIP-39 and Electrum. The idea is to add the information that the wallet needs to derive child keys to final string that the user writes down and more importantly we see mnemonic as a simple encoding and avoid modifying the entropy when deriving the BIP-32 seed (see #4).

The C# implementation can be found here: https://github.com/Autarkysoft/Denovo/blob/master/Src/Autarkysoft.Bitcoin/Experimental/BetterMnemonic.cs
Like any experimental class under Experimental namespace this is a rough idea and the code is untested.

Code:
4 bit version | 4 bit depth | 32 bit index * depth | CompactInt entropy length | entropy | checksum (pad)

1. Scalability
To make the algorithm scalable a small 4 bit version is added to the beginning of the encoding. This way we can have different definitions using the same scheme.

2. Derivation path/script type
In order to let the wallet know which BIP-32 derivation path to use, that path has to be encoded into the mnemonic. This path could also act as the script (address) type of the child keys. For instance m/84'/0'/0'/0 is for P2WPKH addresses.
The downside is increasing the length of the final mnemonic. This could be mitigated by introducing version 2 where instead of encoding the entire path a 4 bit integer is used to indicate the predefined paths. 16 hard-coded paths can be defined this way and for anything new next version could be used.
version 1: 4-bit version | 4 bit derivation path depth | each index as 32-bit unsigned integers
version 2: 4-bit version | 4 bit hard-coded path

BIP-39 doesn't have this feature.
Electrum has a partial solution by first increasing the entropy size from 128 to 132 bits then brute forcing a version that indicates the derivation paths and script types

3. Creation time
This can be useful for the full nodes to avoid re-scanning the entire blockchain when the user imports their mnemonic. The creation time (as a LockTime object) can quickly tell the client from when in the history to begin the scan. For example a mnemonic created today doesn't have to scan the 300 GB of existing history.
Since this is LockTime as used in transactions (instead of simple DateTime) it could be used by both online and offline clients generating the mnemonic as the online synced client knows the block height and can use that and the offline (cold storage) can use the DateTime (values as Unix timestamp and above 500,000,000).

The rest is implementation detail, for example the wallet UI can show the LockTime (block height or DateTime) and still give the user the option to do a full rescan.

4. No modification of the initial entropy
This is the main and biggest difference. Both BIP-39[2] and Electrum[3] are modifying the mnemonic:
A. Modifying by normalization
BIP-39 uses a Unicode normalization with full compatibility decomposition (form KD) but Electrum takes a step further and modifies the input mnemonic more by removing accents, changing Chinese words, removing spaces for word lists other than English, etc. Then the byte array representation of the string is used to derive the keys.
This can create incompatibility between different implementations and lead to losses specially for any word list other than English.

If the words are only used to look up index of each word in the word list to get the entropy out and nothing else, this problem is eliminated.
In other words if user enters a word like "aliener" instead of "aliéner" (from French word list) it still can be searched inside the word list and if the search fails (due to bad normalization) the import process fails right away instead of going ahead. While normalizing this word can give different values:
Code:
0x616c6965cc816e6572  No normalization
0x616c6965cc816e6572  NFKD
0x616c69656e6572      Electrum
0x616c69656e6572      No accent
The problem is more palpable when using Japanese word list for example (the start of the difference is marked by ^, also note the lengths):
Code:
そつう れきだい ほんやく わかす りくつ ばいか ろせん やちん そつう れきだい ほんやく わかめ
e3819de381a4e38186e38080e3828ce3818de381a0e38184e38080e381bbe38293e38284e3818fe38080e3828fe3818be38199e38080e3828ae3818fe381a4e38080e381b0e38184e3818be38080e3828de3819be38293e38080e38284e381a1e38293e38080e3819de381a4e38186e38080e3828ce3818de381a0e38184e38080e381bbe38293e38284e3818fe38080e3828fe3818be38281
e3819de381a4e38186e3828ce3818de3819fe38184e381bbe38293e38284e3818fe3828fe3818be38199e3828ae3818fe381a4e381afe38184e3818be3828de3819be38293e38284e381a1e38293e3819de381a4e38186e3828ce3818de3819fe38184e381bbe38293e38284e3818fe3828fe3818be38281
e3819de381a4e3818620e3828ce3818de3819fe38299e3818420e381bbe38293e38284e3818f20e3828fe3818be3819920e3828ae3818fe381a420e381afe38299e38184e3818b20e3828de3819be3829320e38284e381a1e3829320e3819de381a4e3818620e3828ce3818de3819fe38299e3818420e381bbe38293e38284e3818f20e3828fe3818be38281
                  ^

B. Use the UTF-8 decoded bytes of the mnemonic instead of the entropy
When creating a mnemonic a random entropy with a good distribution of bits is chosen. For example in a 12 word mnemonic the entropy is an octet string with length of 16 (ie. 128 bits). Each octet can have a value between 0 and 255 inclusive which is 256 different values.
When this is converted to 12 words using English word list then UT8 decoded to be used to derive BIP-32 seed, it is a longer octet string but each octet can only have a value between 97 and 122 inclusive which is only 26 different values.
In other words a big bias is introduced in the input of PBKDF2 while the initial entropy had no bias at all (assuming it was chosen using a strong RNG).

By using the entropy itself we can eliminate this bias and also avoid the normalization bugs that could occur in different implementations while greatly simplifying the implementation.

Downside
The only disadvantage of this proposal is the longer mnemonic. For example a 12-word BIP-39/Electrum mnemonic would turn into a 26-word version 1 BetterMnemonic using BIP-84 derivation path (without locktime) or 14-word version 2+ (without locktime).

[1] Experimental-1: https://bitcointalk.org/index.php?topic=5245712.0
[2] https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki#from-mnemonic-to-seed
[3] https://github.com/spesmilo/electrum/blob/392a648de5f6edf2e06620763bf0685854d0d56d/electrum/mnemonic.py
99  Bitcoin / Project Development / Re: [C#][Github] SharpPusher, broadcast BTC, BCC(BCH) transactions to the network on: April 11, 2021, 09:09:30 AM
Does it really make your project runnable on every operating system?
Yes. Unlike .net framework the .net is no longer windows specific and can be used for any operating system. The UI is also designed that way to render everything based on the platform that is used.

Does it require .NET 5 or it has it already installed? I've noticed an annoying bug on .NET 5's installation. For example, I had to install .NET 5 on another machine (because it required it) and once I did, it showed me the same message again ("You need to install .NET 5 to run this"). This sours some people and they'll give up the software before they even try it.
There are two ways we can publish a .net application framework-dependent and self-contained, the former requires installing .net and the later doesn't but it is slightly bigger.
I have been releasing my other project (FinderOuter) as a self-contained executable for 64-bit Linux OS. It doesn't need any additional download or install, you just get the binaries and run them. The screenshot is from it running on Ubuntu 20.04.
100  Bitcoin / Project Development / Re: [C#][Github] SharpPusher, broadcast BTC, BCC(BCH) transactions to the network on: April 10, 2021, 12:43:36 PM
I haven't ever done this. Shouldn't this button be enabled?
You are comparing master with master on the same repository, so there is nothing to create a PR with. You have to change the branch. There is a button on top saying "compare across forks".
An easier way is to just fork the project and push changes to your own repository then inside that repository you will see a PR button that you can use.
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!