Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,16 @@
USING: byte-arrays checksums checksums.sha io.binary kernel math
math.parser sequences ;
IN: rosetta-code.bitcoin.validation
CONSTANT: ALPHABET "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
: base58>bigint ( str -- n )
[ ALPHABET index ]
[ [ 58 * ] [ + ] bi* ] map-reduce ;
: base58> ( str -- bytes ) base58>bigint 25 >be ;
: btc-checksum ( bytes -- checksum-bytes )
21 head 2 [ sha-256 checksum-bytes ] times 4 head ;
: btc-valid? ( str -- ? ) base58> [ btc-checksum ] [ 4 tail* ] bi = ;