Pages:
Author

Topic: Safet - A wallet made in JAVA (WIP - Testing purposes only, so far) - page 2. (Read 295 times)

legendary
Activity: 1526
Merit: 6442
bitcoincleanup.com / bitmixlist.org
Would you like to open-source the tool in case someone else finds it useful?

The less people reinventing the wheel, especially in cryptography applications, the better - less bugs and vulnerabilities.
jr. member
Activity: 56
Merit: 31
Hello people! I have developed a very simple JAVA application that:

1. generates entropy
2. creates a private key and produces its WIF representation
3. produces a public key
4. produces an address

I sent some sats from my mobile's BlueWallet, straight into the address.

Then I loaded up the WIF private key in Electrum and I saw the incoming transaction.

Finally, I sent the sats back.

Everything I have developed is totally custom and I didn't use many external libraries.

Next steps: Create a HD wallet using a seed phrase. I will create a seed using the entropy and a checksum. Then I will translate the binary seed into a seed phrase etc etc.

Thank you all for the assistance!
legendary
Activity: 952
Merit: 1367
bitcoinj is all you need.

If you want to see how to generate addresses from a given private key or from seed, take a look at some of my projects:
https://github.com/PawelGorny/WifSolver
https://github.com/PawelGorny/lostword
You will find there code for different address types.
And here https://github.com/PawelGorny/NodeWatcher you will find a very simple example of creating and broadcasting transaction.
jr. member
Activity: 56
Merit: 31
Thank you very much! I am trying to develop it using bitcoinj now. I will test it using Electrum once I have implemented it.
hero member
Activity: 868
Merit: 5808
not your keys, not your coins!
So far, I think the process is that the seed phrase is hashed (I don't know what function is used) and it produces a private key which is attached to the public key based on ECDSA. Is that correct?
Very roughly, yes. However, the seed phrase is just a mnemonic representation of the 64-byte binary seed. Private keys are generated from that seed and not from the seed phrase.
The HMAC of the seed gives you a master private key from which you generate child private keys through hashing it with a counter.
Generating addresses from private keys is another step that is a bit more complicated than your description. You can't 'attach' keys to each other; just generate one from another based on a fixed set of rules (since those are deterministic, it basically makes the keys inherently 'attached').

It's all explained very well on learnmeabitcoin.

I want to write the code from scratch, probably in java. Do you have any good tutorials or libraries I could use? Maybe bitcoinj?
Either you use a library, or you write it yourself. If you don't care about learning how it works, you can just use bitcoinj. You may be able to learn something by reading their code and reimplementing it yourself, but a good theoretical foundation is good to have.

Sorry if I am asking quite a lot here, but googling these questions didn't actually help. I thought this place is the best for development questions.
My advice is browsing these pages:
https://learnmeabitcoin.com/
https://en.bitcoin.it/wiki/Main_Page

As well as searching Bitcointalk using ninjastic.space with appropriate filters and search terms.
https://ninjastic.space/search

If you haven't read the https://bitcoinbook.info/ yet, you can read the relevant chapters online:
Chapter 4 (Keys, Addresses): https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch04.asciidoc
Chapter 5 (Wallets): https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch05.asciidoc
jr. member
Activity: 56
Merit: 31

This is a Work In Progress and I made it just for fun and because I wanted to educate myself in Bitcoin Wallets! Every key or address in this thread must be ignored! I just provide them to showcase how the program works! DON'T USE ANY OF THEM!



UPDATE: 2023, Jan 10th

Hello friends! So I have developed a non-deterministic wallet in JAVA, using as less external libraries as possible (obviously I used some code from other libraries).

So here is the repo link: https://bitbucket.org/vampobit/safet/src/main/

The program creates a non-deterministic wallet generating entropy * using:
  • Java's SecureRandom = 208
  • User's input = 48 bits of entropy

a runtime example is:

Code:
-------------------------
| Generating Entropy |
-------------------------
Please enter a random sequence of characters from the keyboard:
let's see how this goes... vampobit
Using user input to generate 48 bits of entropy.
Using SecureRandom to generate 204 bits of entropy.
---------------------
| Generated Keys |
---------------------
Private Key: b49bd68e4f1bd220e90871031860009b0b44654268cb1e4dcdca93743fc7961e
Private Key (WIF): L3Gnp62mS3PsmtQ3AEZveuYWywkucv787krXEXj9xDcuJAQjC4pC
Public Key: 02a16995de6cd203c0459a841752fad6941a65ca43a0cbf629f3413d64db7fb24c
Legacy Address: 15zHNp2irZGBpd4NzJ8JypsahRDyjpoa52

My latest additions have been:
  • generating QR Codes for private key and for legacy address
  • removing the initial entropy I used to get using time thanks to ETFbitcoin's indication

I have tested everything both on Test Net and the Main Net and it works pretty good (the QR codes too).

Please let me know what you think!!!!



Hello everyone! First of all, I may make mistakes in the following post, so forgive my possible ignorance. I need your help.

I want to
  • learn theoretically how a wallet works. What algorithms are used etc. It is a little opaque to me.
  • develop a simple wallet generator in JAVA


So far, I think the process is that the seed phrase is hashed (I don't know what function is used) and it produces a private key which is attached to the public key based on ECDSA. Is that correct?

I want to write the code from scratch, probably in java. Do you have any good tutorials or libraries I could use? Maybe bitcoinj?

Sorry if I am asking quite a lot here, but googling these questions didn't actually help. I thought this place is the best for development questions.
Pages:
Jump to: