Recent

Author Topic: Bitcoin Address Generator in Pascal?  (Read 5711 times)

Rekumkacz

  • New Member
  • *
  • Posts: 21
Bitcoin Address Generator in Pascal?
« on: November 23, 2017, 08:31:27 am »
Hello
I have been writing the Bitcoin Address Generator for about a week. I am using the DCPCrypt package, but the computation functions do not work correctly.
Has anyone already done this before?

tudi_x

  • Hero Member
  • *****
  • Posts: 532
Re: Bitcoin Address Generator in Pascal?
« Reply #1 on: November 23, 2017, 08:55:45 am »
hi,
could you share your analysis and code example on how you concluded the results are wrong?
Lazarus 2.0.2 64b on Debian LXDE 10

Thaddy

  • Hero Member
  • *****
  • Posts: 14203
  • Probably until I exterminate Putin.
Re: Bitcoin Address Generator in Pascal?
« Reply #2 on: November 23, 2017, 09:35:33 am »
Indeed, an example would be appreciated.
As I recall dcpcrypt was not fully standards compliant (except for the hashes) but that knowledge is several years old.(7+) and that may have changed in the mean time.
Specialize a type, not a var.

Rekumkacz

  • New Member
  • *
  • Posts: 21
Re: Bitcoin Address Generator in Pascal?
« Reply #3 on: November 23, 2017, 09:39:58 am »
I got stuck on the SHA256
Code: Pascal  [Select][+][-]
  1. var
  2.   soutput,sinput,s:string;
  3.   i:integer;
  4.   Hasher: TDCP_sha256;
  5.   binput: array[0..31] of byte;
  6.   boutput: array[0..31] of byte;
  7. begin
  8. //in    445C7A8007A93D8733188288BB320A8FE2DEBD2AE1B47F0F50BC10BAE845C094
  9. //sha256
  10. //out D61967F63C7DD183914A4AE452C9F6AD5D462CE3D277798075B107615C1A8A30
  11.   for i:= 0 to 31 do boutput[i]:=0;
  12.   sinput:='445C7A8007A93D8733188288BB320A8FE2DEBD2AE1B47F0F50BC10BAE845C094';
  13.   soutput:='';
  14.  
  15.   //Convert String to byte array
  16.   for i := 0 to (length(sinput) div 2)-1 do
  17.     boutput[i]:= StrToInt('$'+copy(sinput,i*2+1,2));
  18.  
  19.   Hasher := TDCP_sha256.Create(nil);
  20.   Hasher.Init;
  21.   Hasher.Update(binput[0], Length(binput));
  22.   Hasher.Final(boutput[0]);
  23.  
  24.   for i:= 0 to 31 do s:=s+IntToHex(boutput[i],2);
  25.   log('[out]:'+s);
  26. end;

[out]: F9C3696B5FF2DBDD46E8D83E3D7F6CB9AD52685A983F5EAAD3BE9D80F0BBC39E
should D61967F63C7DD183914A4AE452C9F6AD5D462CE3D277798075B107615C1A8A30

sam707

  • Guest
Re: Bitcoin Address Generator in Pascal?
« Reply #4 on: November 23, 2017, 10:43:01 am »
have a cool inspirationatatition  :D
https://github.com/PascalCoin/PascalCoin
« Last Edit: November 23, 2017, 10:45:16 am by sam707 »

Rekumkacz

  • New Member
  • *
  • Posts: 21
Re: Bitcoin Address Generator in Pascal?
« Reply #5 on: November 23, 2017, 12:53:17 pm »
 >:( before:
Quote
  //Convert String to byte array
  for i := 0 to (length(sinput) div 2)-1 do
   boutput:= StrToInt('$'+copy(sinput,i*2+1,2));
after:
Quote
  //Convert String to byte array
  for i := 0 to (length(sinput) div 2)-1 do
    binput:= StrToInt('$'+copy(sinput,i*2+1,2));

https://www.youtube.com/watch?v=PH0DvEuKf_s

Rekumkacz

  • New Member
  • *
  • Posts: 21
Re: Bitcoin Address Generator in Pascal?
« Reply #6 on: November 26, 2017, 10:01:30 pm »
I have done  7 of 9 steps to done this and surprise i am stuck
i have a string of hex 00C8EE61137A4FDA1B770135E56C1320FD823126D57752D495 and i can't handle the base58

How can i do this or divide this by 58?

Progress of work
Code: Pascal  [Select][+][-]
  1. [-]:0 - Private ECDSA Key
  2. [-]:1 - Public ECDSA Key
  3. [+]:2 - SHA-256 hash of 1
  4. [+]:3 - RIPEMD-160 Hash of 2
  5. [+]:4 - Adding network bytes to 3
  6. [+]:5 - SHA-256 hash of 4
  7. [+]:6 - SHA-256 hash of 5
  8. [+]:7 - First four bytes of 6
  9. [+]:8 - Adding 7 at the end of 4
  10. [-]:9 - Base58 encoding of 8

 

TinyPortal © 2005-2018