Bitcoin Forum
May 27, 2024, 04:06:48 AM *
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: 1918
Merit: 1577


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?

███▄▀██▄▄
░░▄████▄▀████ ▄▄▄
░░████▄▄▄▄░░█▀▀
███ ██████▄▄▀█▌
░▄░░███▀████
░▐█░░███░██▄▄
░░▄▀░████▄▄▄▀█
░█░▄███▀████ ▐█
▀▄▄███▀▄██▄
░░▄██▌░░██▀
░▐█▀████ ▀██
░░█▌██████ ▀▀██▄
░░▀███
▄▄██▀▄███
▄▄▄████▀▄████▄░░
▀▀█░░▄▄▄▄████░░
▐█▀▄▄█████████
████▀███░░▄░
▄▄██░███░░█▌░
█▀▄▄▄████░▀▄░░
█▌████▀███▄░█░
▄██▄▀███▄▄▀
▀██░░▐██▄░░
██▀████▀█▌░
▄██▀▀██████▐█░░
███▀░░
hatshepsut93
Legendary
*
Offline Offline

Activity: 2982
Merit: 2147


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.
OmegaStarScream
Staff
Legendary
*
Offline Offline

Activity: 3486
Merit: 6150



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: 1918
Merit: 1577


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: 2338
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

R


▀▀▀▀▀▀▀██████▄▄
████████████████
▀▀▀▀█████▀▀▀█████
████████▌███▐████
▄▄▄▄█████▄▄▄█████
████████████████
▄▄▄▄▄▄▄██████▀▀
LLBIT
  CRYPTO   
FUTURES
 1,000x 
LEVERAGE
COMPETITIVE
    FEES    
 INSTANT 
EXECUTION
.
   TRADE NOW   
pooya87
Legendary
*
Offline Offline

Activity: 3458
Merit: 10593



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!