Bitcoin/public point to address: Difference between revisions

Use the .polymod method
m (→‎{{header|Perl 6}}: 'flat' needed before reduce)
(Use the .polymod method)
Line 335:
>;
 
sub encode(Int UInt $n ) {
[R~] BASE58[ $n.polymod: <58 BASE58xx * ??]
BASE58[$n] !!
encode($n div 58) ~ BASE58[$n % 58]
}
 
sub public_point_to_address(Int UInt $x is copy, IntUInt $y is copy) {
my @bytes; = (
for 1 |$y..polymod( 32256 {xx push32 @bytes)[^32], $y# %ignore 256;the $yextraneous div= 25633rd }modulus
for 1 .. 32 { push @bytes, |$x %.polymod( 256; $xxx div=32 256 })[^32],
);
my $hash = rmd160 sha256 Blob.new: 4, @bytes.reverse;
my $checksum = sha256(sha256 Blob.new: 0, $hash.list).subbuf: 0, 4;
Anonymous user