Bitcoin/public point to address: Difference between revisions

Added Seed7 example
(Add Nim version)
(Added Seed7 example)
Line 743:
<pre>
6UwLL9Risc3QfPqBUvKofHmBQ7wMtjvM
</pre>
 
=={{header|Seed7}}==
The Seed7 library [http://seed7.sourceforge.net/libraries/msgdigest.htm msgdigest.s7i] defines
the functions [http://seed7.sourceforge.net/libraries/msgdigest.htm#ripemd160(in_var_string) ripemd160] and
[http://seed7.sourceforge.net/libraries/msgdigest.htm#sha256(in_var_string) sha256].
The Seed7 library [http://seed7.sourceforge.net/libraries/encoding.htm encoding.s7i] defines
the function [http://seed7.sourceforge.net/libraries/encoding.htm#toBase58(in_string) toBase58],
which encodes a string with the Base58 encoding used by Bitcoin. No external library is needed.
 
<lang seed7>$ include "seed7_05.s7i";
include "bytedata.s7i";
include "msgdigest.s7i";
include "encoding.s7i";
 
const func string: publicPointToAddress (in string: x, in string: y) is func
result
var string: address is "";
begin
address := "\4;" & hex2Bytes(x) & hex2Bytes(y);
address := "\0;" & ripemd160(sha256(address));
address &:= sha256(sha256(address))[.. 4];
address := toBase58(address);
end func;
 
const proc: main is func
begin
writeln(publicPointToAddress("50863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B2352",
"2CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6"));
end func;</lang>
 
{{out}}
<pre>
16UwLL9Risc3QfPqBUvKofHmBQ7wMtjvM
</pre>