Welcome, Guest. Please login or register.

Author Topic: Is there an easy way to get my public key?  (Read 63 times)

0 Members and 1 Guest are viewing this topic.

Offline rlh

  • Fresh Nxter
  • *
  • Posts: 13
    • View Profile
Is there an easy way to get my public key?
« on: December 16, 2013, 07:29:57 PM »
I'm trying to right some simple tools to work with Nxt, in C#.  This is basically an exercise in learning about the coin, more than providing any specific tools.

Anyway, I'm having a tough time generating an account number, and I know that I'm essentially executing SHA256(Curve25519(SHA256(privateKey))), just from within .Net.  However, when I convert the first 8 bytes of the resulting byte array (from the final SHA256 call,) my outputted address is not the address that's calculated from the Nxt client.

I'm not sure where the breakdown is, but it would be helpful if I could get the public key that is outputted from the Curve function.  Can I acquire this information from the client?

Offline rlh

  • Fresh Nxter
  • *
  • Posts: 13
    • View Profile
Re: Is there an easy way to get my public key?
« Reply #1 on: December 16, 2013, 07:55:28 PM »
Actually, let me add another request.  Can I please get the following outputted values for the secret phrase "test".


- First past, SHA256.
- Curve25519 Output of first SHA hash (this is the public key, correct?)
- The SHA256 has of the curve hash.
- Which bytes of the second SHA hash are used as the 8 bytes of a long (or is it a ulong)?

Offline ben

  • Nxter
  • **
  • Posts: 65
    • View Profile
Re: Is there an easy way to get my public key?
« Reply #2 on: December 16, 2013, 08:38:20 PM »
enter passphrase:
test

passphrase -> SHA-256 = SECRET KEY:
9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08

SHA-256 -> curve25519 = PUBLIC KEY:
d9d5c57971eefb085e3abaf7a5a4a6cdb8185f30105583cdb09ad8f61886ec65

PUBLIC KEY -> SHA-256:
0b1a06e36bd14d3bf185f861619c711d68f93feb76e3df6d45d45005f6c72944

convert lower 8 bytes to long long = ACCOUNT ID:
4273301882745002507


DONT FORGET after first SHA-256 and BEFORE doing curve...modify:
digest[0] &= 248;
digest[31] &= 127;
digest[31] |= 64;


if you are a c developer:
-> you are working on unsigned char array..
to get the id you cast it:
Quote
unsigned char digest[SHA256_HASH_SIZE];
typedef unsigned __int64 ufelem;
longint = *((ufelem*) digest);
----
THANK YOU for donating some NXT @   8707785682971074378
for keeping my well-known-node up and running

Offline rlh

  • Fresh Nxter
  • *
  • Posts: 13
    • View Profile
Re: Is there an easy way to get my public key?
« Reply #3 on: December 16, 2013, 08:41:21 PM »
DONT FORGET after first SHA-256 and BEFORE doing curve...modify:
digest[0] &= 248;
digest[31] &= 127;
digest[31] |= 64;

Ahhh... I didn't know that was taking place.  Let me add that to my code.  What is that for, anyway?

Offline ben

  • Nxter
  • **
  • Posts: 65
    • View Profile
Re: Is there an easy way to get my public key?
« Reply #4 on: December 16, 2013, 08:44:04 PM »
are you using curve25519-donna implementation?

if yes you have to do the trick
----
THANK YOU for donating some NXT @   8707785682971074378
for keeping my well-known-node up and running

Offline rlh

  • Fresh Nxter
  • *
  • Posts: 13
    • View Profile
Re: Is there an easy way to get my public key?
« Reply #5 on: December 16, 2013, 08:56:19 PM »
Yes, I was using Donna.  This fixed my issues.  I assume if I write anything in C# that uses Curve, I will have to apply this "trick".  I've not read much on this hashing algorithm.  Is this a bug with Donna?

Offline ben

  • Nxter
  • **
  • Posts: 65
    • View Profile
Re: Is there an easy way to get my public key?
« Reply #6 on: December 16, 2013, 09:11:19 PM »
no its no bug....

when you look at curve-donna README you see that you ecplicitly
have to use this....
----
THANK YOU for donating some NXT @   8707785682971074378
for keeping my well-known-node up and running

Offline rlh

  • Fresh Nxter
  • *
  • Posts: 13
    • View Profile
Re: Is there an easy way to get my public key?
« Reply #7 on: December 16, 2013, 11:48:49 PM »
I see.  Well, thanks again.  I missed that.  I wanted to play around with a bit of address creation during my lunch break.  An hour isn't a lot of time so I tend to skip reading documentation and just dive right in.

FYI, I just found address 262845192447 in about 30 minutes on a 6 year old PC.  8) 

This is fun.

Online Come-from-Beyond

  • Senior Nxter
  • ****
  • Posts: 305
    • View Profile
Re: Is there an easy way to get my public key?
« Reply #8 on: December 16, 2013, 11:51:57 PM »
FYI, I just found address 262845192447 in about 30 minutes on a 6 year old PC.  8) 

Still too long. Try to find one with 9 decimal places. :)

Offline rlh

  • Fresh Nxter
  • *
  • Posts: 13
    • View Profile
Re: Is there an easy way to get my public key?
« Reply #9 on: December 16, 2013, 11:58:53 PM »
Nice!

Yeah, it's my hope to find an address that is under 4 bytes long.  Again, this was just a bit of prelim testing and about 1 hours worth of work.  Half of that time was figuring out how to generate the address in the first place.

Did you use a custom tool to generate that 9-digit address?  I found the vanity generator, but I wanted to write my own in C# just for the experience.  My current tool takes a pass-phrase and appends random digits to the end of it.  It exports a list of progressive max and min addresses.  I'd also like to have a hex address in the neighborhood of "FFFF FFFF .... .... .... .... .... ....".

Speaking of, is there any reason why we couldn't modify the client to take hex-values for payment addresses.  Ultimately, I'd like to do some vanity searches for addresses that begin with "d1ce...".  That would be pointless, though, unless people can see that prefix in the address.

Online starik69

  • Fresh Nxter
  • *
  • Posts: 34
    • View Profile
Re: Is there an easy way to get my public key?
« Reply #10 on: Today at 12:22:33 AM »
Did you use a custom tool to generate that 9-digit address?
I used vanitygen_64.exe from BTT for several hours. Result in the signature :)
NXT 648774468

Online Come-from-Beyond

  • Senior Nxter
  • ****
  • Posts: 305
    • View Profile
Re: Is there an easy way to get my public key?
« Reply #11 on: Today at 06:10:54 AM »
Did you use a custom tool to generate that 9-digit address?

Vanity gen.