Bitcoin Forum
May 03, 2024, 11:22:48 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Is it possible to simulate bitcoin address using C#?  (Read 179 times)
Maus0728 (OP)
Legendary
*
Offline Offline

Activity: 1904
Merit: 1558


Bitcoin Casino Est. 2013


View Profile
September 05, 2020, 12:56:19 PM
Merited by DdmrDdmr (2), OmegaStarScream (1), webtricks (1)
 #1

Hey greetings,

I've been slowly reading the book of Andreas Antonopolous and currently reading chapter 4 - keys addresses and recently came across the thread created by @webtricks about How Bitcoin Addresses are generated? Understand the Math behind Bitcoin.

Is it possible to create a similar bitcoin address generation using C# programming language in visual studio from a console? I came across with this idea because I am currently enrolled in an online class and it happens that we're using C# programming language in our subject and also have the willingness to learn how these bitcoin addresses are generated from scratch.

What are the requirements to create similar programming just like what webtricks did before in his project? Any recommended readings?

███▄▀██▄▄
░░▄████▄▀████ ▄▄▄
░░████▄▄▄▄░░█▀▀
███ ██████▄▄▀█▌
░▄░░███▀████
░▐█░░███░██▄▄
░░▄▀░████▄▄▄▀█
░█░▄███▀████ ▐█
▀▄▄███▀▄██▄
░░▄██▌░░██▀
░▐█▀████ ▀██
░░█▌██████ ▀▀██▄
░░▀███
▄▄██▀▄███
▄▄▄████▀▄████▄░░
▀▀█░░▄▄▄▄████░░
▐█▀▄▄█████████
████▀███░░▄░
▄▄██░███░░█▌░
█▀▄▄▄████░▀▄░░
█▌████▀███▄░█░
▄██▄▀███▄▄▀
▀██░░▐██▄░░
██▀████▀█▌░
▄██▀▀██████▐█░░
███▀░░
1714778568
Hero Member
*
Offline Offline

Posts: 1714778568

View Profile Personal Message (Offline)

Ignore
1714778568
Reply with quote  #2

1714778568
Report to moderator
The grue lurks in the darkest places of the earth. Its favorite diet is adventurers, but its insatiable appetite is tempered by its fear of light. No grue has ever been seen by the light of day, and few have survived its fearsome jaws to tell the tale.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714778568
Hero Member
*
Offline Offline

Posts: 1714778568

View Profile Personal Message (Offline)

Ignore
1714778568
Reply with quote  #2

1714778568
Report to moderator
1714778568
Hero Member
*
Offline Offline

Posts: 1714778568

View Profile Personal Message (Offline)

Ignore
1714778568
Reply with quote  #2

1714778568
Report to moderator
1714778568
Hero Member
*
Offline Offline

Posts: 1714778568

View Profile Personal Message (Offline)

Ignore
1714778568
Reply with quote  #2

1714778568
Report to moderator
hatshepsut93
Legendary
*
Offline Offline

Activity: 2968
Merit: 2145



View Profile
September 05, 2020, 01:06:49 PM
Merited by pooya87 (1), DdmrDdmr (1)
 #2

"Simulate" is not the right word here, you are asking how to generate a real Bitcoin address in C#. You can use any programming language available, they are all capable of doing this task.

Generating Bitcoin address requires cryptographic hash function utilities and elliptic curve utilities, though webtrics implemented some elliptic curve functions from scratch in his example. Generally, it's a bad practice to implement something that has already been done and is freely available in forms of libraries, unless done for educational purposes.

So, the simple approach would be to import all the functions that you need, and just assemble your wallet generation function with them.

You can also look for existing C# implementations of it, for example here.

.BEST.CHANGE..███████████████
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
███████████████
..BUY/ SELL CRYPTO..
OmegaStarScream
Staff
Legendary
*
Offline Offline

Activity: 3472
Merit: 6115



View Profile
September 05, 2020, 01:10:51 PM
Merited by DdmrDdmr (2), webtricks (1)
 #3

Take a look at NBitcoin's[1] library, you can either call it[2] or check the source code to see how is it done from scratch.

[1] https://github.com/MetacoSA/NBitcoin
[2] https://programmingblockchain.gitbook.io/programmingblockchain/bitcoin_transfer/bitcoin_address

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
Maus0728 (OP)
Legendary
*
Offline Offline

Activity: 1904
Merit: 1558


Bitcoin Casino Est. 2013


View Profile
September 05, 2020, 01:29:24 PM
 #4

WOW! Thank you @hatshepsut93 and @OmegaStarScream for recommending some resources. This can significantly help boost my learning curve between the use of C# as well as learning the algorithm involved in this bitcoin generation address.

I'll ask questions here if there are any issues I encountered throughout the process.  Smiley

███▄▀██▄▄
░░▄████▄▀████ ▄▄▄
░░████▄▄▄▄░░█▀▀
███ ██████▄▄▀█▌
░▄░░███▀████
░▐█░░███░██▄▄
░░▄▀░████▄▄▄▀█
░█░▄███▀████ ▐█
▀▄▄███▀▄██▄
░░▄██▌░░██▀
░▐█▀████ ▀██
░░█▌██████ ▀▀██▄
░░▀███
▄▄██▀▄███
▄▄▄████▀▄████▄░░
▀▀█░░▄▄▄▄████░░
▐█▀▄▄█████████
████▀███░░▄░
▄▄██░███░░█▌░
█▀▄▄▄████░▀▄░░
█▌████▀███▄░█░
▄██▄▀███▄▄▀
▀██░░▐██▄░░
██▀████▀█▌░
▄██▀▀██████▐█░░
███▀░░
tbct_mt2
Hero Member
*****
Offline Offline

Activity: 2310
Merit: 835


View Profile WWW
September 05, 2020, 03:39:37 PM
 #5

To get a bitcoin address, you need to have a public key. To have a public key, you need to have a private key. You can not find them in the backward steps.

Private key (Eliptic Curve Multiplication) - Publick Key (Hash Function) - Address
k - K - A (irreversible)
And K = k * G

What you ask is the reverse math of the formula and it is impossible.

You can see the explanation for Eliptic Curve at https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch04.asciidoc#elliptic_curve

https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch04.asciidoc
pooya87
Legendary
*
Offline Offline

Activity: 3444
Merit: 10536



View Profile
September 06, 2020, 05:01:16 AM
Merited by aliashraf (1)
 #6

What are the requirements to create similar programming just like what webtricks did before in his project? Any recommended readings?

the topic you shared already contains good information for you to read. also if you want to experiment you can "translate" the code in that topic to c# which isn't really that hard to begin with. if you use .Net Framework then you'll have access to RIPEMD160 and SHA256 and the ECC code is in that topic. BigInt becomes BigInteger (found in System.Numerics) and the points such as G have to be defined as a "struct" that contains 2 BigIntegers (x and y).
if you use .Net Core then you won't have RIPEMD160 anymore but you can copy it from any crypto library or even .Net Framework source code itself (link)

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!