diff --git a/bloom.h b/bloom.h index 02b40fb..de3dce9 100644 --- a/bloom.h +++ b/bloom.h @@ -5,7 +5,7 @@ #include /* 2^32 bits */ -#define BLOOM_SIZE (1024*1024*1024) +#define BLOOM_SIZE (512*1024*1024*2) #define BLOOM_SET_BIT(N) (bloom[(N)>>3] = bloom[(N)>>3] | (1<<((N)&7))) #define BLOOM_GET_BIT(N) ( ( bloom[(N)>>3]>>((N)&7) )&1) @@ -33,6 +33,11 @@ #define BH17(N) (N[2]<<24|N[3]>> 8) #define BH18(N) (N[3]<<24|N[4]>> 8) #define BH19(N) (N[4]<<24|N[0]>> 8) +#define BH20(N) (N[0]<<16|N[1]>>24) +#define BH21(N) (N[1]<<16|N[2]>>24) +#define BH22(N) (N[2]<<16|N[3]>>24) +#define BH23(N) (N[3]<<16|N[4]>>24) +#define BH24(N) (N[4]<<16|N[0]>>24) #define BH20(N) (N[0]<<16|N[1]>>24) #define BH21(N) (N[1]<<16|N[2]>>24) diff --git a/hex2blf.c b/hex2blf.c index c52db6b..7d8309c 100644 --- a/hex2blf.c +++ b/hex2blf.c @@ -19,8 +19,8 @@ #include "bloom.h" #include "hash160.h" -const double k_hashes = 20; -const double m_bits = 4294967296; +const double k_hashes = 25; +const double m_bits = 4294967296*2; int main(int argc, char **argv) { hash160_t hash; diff --git a/scripts/generators/2.py b/scripts/generators/2.py index f99bf3c..bc4e80b 100755 --- a/scripts/generators/2.py +++ b/scripts/generators/2.py @@ -13,4 +13,4 @@ for line in file2.lines(): id_ = line.split()[0] if id_ in ids: - found.append("{} {}".format(ids[id_], line)) + found.append(f"{ids[id_]} {line}") diff --git a/scripts/generators/3.py b/scripts/generators/3.py index f5ef86d..961a6fd 100755 --- a/scripts/generators/3.py +++ b/scripts/generators/3.py @@ -15,32 +15,33 @@ import random -help_message = ''' +help_message = """ Code Phrase Generator -n or --number : Number of sample code phrases given. (Default is 5) -p or --prefix : Uses a prefix word along with a random codeword instead of two codewords. -w or --wordlist : Uses another wordlist to generate code phrases from. -''' +""" -CODEWORDS = open('wordlist.txt', 'r').readlines() +CODEWORDS = open("wordlist.txt", "r").readlines() class Usage(Exception): def __init__(self, msg): self.msg = msg + def generate(prefix=False, number=5): while number > 0: - if prefix == 'TRUE': - word1 = PREFIXES[int(random.uniform(0,len(PREFIXES)))] + if prefix == "TRUE": + word1 = PREFIXES[int(random.uniform(0, len(PREFIXES)))] elif prefix: word1 = prefix else: - word1 = CODEWORDS[int(random.uniform(0,len(CODEWORDS)))] + word1 = CODEWORDS[int(random.uniform(0, len(CODEWORDS)))] - word2 = CODEWORDS[int(random.uniform(0,len(CODEWORDS)))] - word3 = CODEWORDS[int(random.uniform(0,len(CODEWORDS)))] - print "%s%s%s" % (word1.rstrip(), word2.rstrip(), word3.rstrip()) + word2 = CODEWORDS[int(random.uniform(0, len(CODEWORDS)))] + word3 = CODEWORDS[int(random.uniform(0, len(CODEWORDS)))] + print(f"{word1.rstrip()}{word2.rstrip()}{word3.rstrip()}") number -= 1 @@ -54,8 +55,10 @@ def main(argv=None): argv = sys.argv try: try: - opts, args = getopt.getopt(argv[1:], "hn:p:i:vw:", ["help", "number=", "prefix=", "wordlist="]) - except getopt.error, msg: + opts, args = getopt.getopt( + argv[1:], "hn:p:i:vw:", ["help", "number=", "prefix=", "wordlist="] + ) + except getopt.error as msg: raise Usage(msg) # option processing @@ -67,23 +70,19 @@ def main(argv=None): if option in ("-n", "--number"): number = int(value) if option in ("-w", "--wordlist"): - global CODEWORDS - print "Importing: %s" % value - CODEWORDS = open(value, 'r').readlines() + global CODEWORDS + print(f"Importing: {value}") + CODEWORDS = open(value, "r").readlines() if option in ("-p", "--prefixe"): - print value - - if (value): - prefix = value - else: - prefix = 'TRUE' + print(value) + prefix = value if value else "TRUE" generate(prefix, number) - except Usage, err: - print >> sys.stderr, sys.argv[0].split("/")[-1] + ": " + str(err.msg) - print >> sys.stderr, "\t for help use --help" + except Usage as err: + print(sys.argv[0].split("/")[-1] + ": " + str(err.msg), file=sys.stderr) + print("\t for help use --help", file=sys.stderr) return 2 diff --git a/scripts/generators/generate12words.py b/scripts/generators/generate12words.py index 6ef2bc5..d03eb90 100755 --- a/scripts/generators/generate12words.py +++ b/scripts/generators/generate12words.py @@ -11,44 +11,49 @@ import getopt import random -#sys.stdout = open('output.txt','wt') +# sys.stdout = open('output.txt','wt') -help_message = ''' +help_message = """ Bip39 12 Word Random Generator By TheRealLordFractal Output File Saved as 12words.txt Command Exntensions: -n or --number : Number of sample code phrases given. (Default is 5) -w or --wordlist : Uses another wordlist to generate code phrases from. -''' +""" + +CODEWORDS = open("wordlist.txt", "r").readlines() +outputtxt = open("12words.txt", "w") -CODEWORDS = open('wordlist.txt', 'r').readlines() -outputtxt = open('12words.txt', 'w') class Usage(Exception): def __init__(self, msg): self.msg = msg + def generate(prefix=False, number=5): while number > 0: - if prefix == 'TRUE': - print ("Not Supported.") - # word1 = PREFIXES[int(random.uniform(0,len(PREFIXES)))] + if prefix == "TRUE": + print("Not Supported.") + # word1 = PREFIXES[int(random.uniform(0,len(PREFIXES)))] elif prefix: word1 = prefix else: - word1 = CODEWORDS[int(random.uniform(0,len(CODEWORDS)))] - word2 = CODEWORDS[int(random.uniform(0,len(CODEWORDS)))] - word3 = CODEWORDS[int(random.uniform(0,len(CODEWORDS)))] - word4 = CODEWORDS[int(random.uniform(0,len(CODEWORDS)))] - word5 = CODEWORDS[int(random.uniform(0,len(CODEWORDS)))] - word6 = CODEWORDS[int(random.uniform(0,len(CODEWORDS)))] - word7 = CODEWORDS[int(random.uniform(0,len(CODEWORDS)))] - word8 = CODEWORDS[int(random.uniform(0,len(CODEWORDS)))] - word9 = CODEWORDS[int(random.uniform(0,len(CODEWORDS)))] - word10 = CODEWORDS[int(random.uniform(0,len(CODEWORDS)))] - word11 = CODEWORDS[int(random.uniform(0,len(CODEWORDS)))] - word12 = CODEWORDS[int(random.uniform(0,len(CODEWORDS)))] - print >> outputtxt, "%s %s %s %s %s %s %s %s %s %s %s %s" % (word1.rstrip(), word2.rstrip(), word3.rstrip(), word4.rstrip(), word5.rstrip(), word6.rstrip(), word7.rstrip(), word8.rstrip(), word9.rstrip(), word10.rstrip(), word11.rstrip(), word12.rstrip()) + word1 = CODEWORDS[int(random.uniform(0, len(CODEWORDS)))] + word2 = CODEWORDS[int(random.uniform(0, len(CODEWORDS)))] + word3 = CODEWORDS[int(random.uniform(0, len(CODEWORDS)))] + word4 = CODEWORDS[int(random.uniform(0, len(CODEWORDS)))] + word5 = CODEWORDS[int(random.uniform(0, len(CODEWORDS)))] + word6 = CODEWORDS[int(random.uniform(0, len(CODEWORDS)))] + word7 = CODEWORDS[int(random.uniform(0, len(CODEWORDS)))] + word8 = CODEWORDS[int(random.uniform(0, len(CODEWORDS)))] + word9 = CODEWORDS[int(random.uniform(0, len(CODEWORDS)))] + word10 = CODEWORDS[int(random.uniform(0, len(CODEWORDS)))] + word11 = CODEWORDS[int(random.uniform(0, len(CODEWORDS)))] + word12 = CODEWORDS[int(random.uniform(0, len(CODEWORDS)))] + print( + f"{word1.rstrip()} {word2.rstrip()} {word3.rstrip()} {word4.rstrip()} {word5.rstrip()} {word6.rstrip()} {word7.rstrip()} {word8.rstrip()} {word9.rstrip()} {word10.rstrip()} {word11.rstrip()} {word12.rstrip()}", + file=outputtxt, + ) number -= 1 @@ -62,8 +67,10 @@ def main(argv=None): argv = sys.argv try: try: - opts, args = getopt.getopt(argv[1:], "hn:p:i:vw:", ["help", "number=", "prefix=", "wordlist="]) - except getopt.error, msg: + opts, args = getopt.getopt( + argv[1:], "hn:p:i:vw:", ["help", "number=", "prefix=", "wordlist="] + ) + except getopt.error as msg: raise Usage(msg) # option processing @@ -76,22 +83,18 @@ def main(argv=None): number = int(value) if option in ("-w", "--wordlist"): global CODEWORDS - print "Importing: %s" % value - CODEWORDS = open(value, 'r').readlines() + print(f"Importing: {value}") + CODEWORDS = open(value, "r").readlines() if option in ("-p", "--prefixe"): - print value - - if (value): - prefix = value - else: - prefix = 'TRUE' + print(value) + prefix = value if value else "TRUE" generate(prefix, number) - except Usage, err: - print >> sys.stderr, sys.argv[0].split("/")[-1] + ": " + str(err.msg) - print >> sys.stderr, "\t for help use --help" + except Usage as err: + print(sys.argv[0].split("/")[-1] + ": " + str(err.msg), file=sys.stderr) + print("\t for help use --help", file=sys.stderr) return 2 diff --git a/scripts/generators/generate2words.py b/scripts/generators/generate2words.py index 2421cf2..bb23d1c 100755 --- a/scripts/generators/generate2words.py +++ b/scripts/generators/generate2words.py @@ -15,31 +15,32 @@ import random -help_message = ''' +help_message = """ Code Phrase Generator -n or --number : Number of sample code phrases given. (Default is 5) -p or --prefix : Uses a prefix word along with a random codeword instead of two codewords. -w or --wordlist : Uses another wordlist to generate code phrases from. -''' +""" -CODEWORDS = open('wordlist.txt', 'r').readlines() +CODEWORDS = open("wordlist.txt", "r").readlines() class Usage(Exception): def __init__(self, msg): self.msg = msg + def generate(prefix=False, number=5): while number > 0: - if prefix == 'TRUE': - word1 = PREFIXES[int(random.uniform(0,len(PREFIXES)))] + if prefix == "TRUE": + word1 = PREFIXES[int(random.uniform(0, len(PREFIXES)))] elif prefix: word1 = prefix else: - word1 = CODEWORDS[int(random.uniform(0,len(CODEWORDS)))] + word1 = CODEWORDS[int(random.uniform(0, len(CODEWORDS)))] - word2 = CODEWORDS[int(random.uniform(0,len(CODEWORDS)))] - print "%s %s" % (word1.rstrip(), word2.rstrip()) + word2 = CODEWORDS[int(random.uniform(0, len(CODEWORDS)))] + print(f"{word1.rstrip()} {word2.rstrip()}") number -= 1 @@ -53,8 +54,10 @@ def main(argv=None): argv = sys.argv try: try: - opts, args = getopt.getopt(argv[1:], "hn:p:i:vw:", ["help", "number=", "prefix=", "wordlist="]) - except getopt.error, msg: + opts, args = getopt.getopt( + argv[1:], "hn:p:i:vw:", ["help", "number=", "prefix=", "wordlist="] + ) + except getopt.error as msg: raise Usage(msg) # option processing @@ -66,23 +69,19 @@ def main(argv=None): if option in ("-n", "--number"): number = int(value) if option in ("-w", "--wordlist"): - global CODEWORDS - print "Importing: %s" % value - CODEWORDS = open(value, 'r').readlines() + global CODEWORDS + print(f"Importing: {value}") + CODEWORDS = open(value, "r").readlines() if option in ("-p", "--prefixe"): - print value - - if (value): - prefix = value - else: - prefix = 'TRUE' + print(value) + prefix = value if value else "TRUE" generate(prefix, number) - except Usage, err: - print >> sys.stderr, sys.argv[0].split("/")[-1] + ": " + str(err.msg) - print >> sys.stderr, "\t for help use --help" + except Usage as err: + print(sys.argv[0].split("/")[-1] + ": " + str(err.msg), file=sys.stderr) + print("\t for help use --help", file=sys.stderr) return 2 diff --git a/scripts/generators/generate3words.py b/scripts/generators/generate3words.py index 1b701a0..01a2d5e 100755 --- a/scripts/generators/generate3words.py +++ b/scripts/generators/generate3words.py @@ -15,32 +15,33 @@ import random -help_message = ''' +help_message = """ Code Phrase Generator -n or --number : Number of sample code phrases given. (Default is 5) -p or --prefix : Uses a prefix word along with a random codeword instead of two codewords. -w or --wordlist : Uses another wordlist to generate code phrases from. -''' +""" -CODEWORDS = open('wordlist.txt', 'r').readlines() +CODEWORDS = open("wordlist.txt", "r").readlines() class Usage(Exception): def __init__(self, msg): self.msg = msg + def generate(prefix=False, number=5): while number > 0: - if prefix == 'TRUE': - word1 = PREFIXES[int(random.uniform(0,len(PREFIXES)))] + if prefix == "TRUE": + word1 = PREFIXES[int(random.uniform(0, len(PREFIXES)))] elif prefix: word1 = prefix else: - word1 = CODEWORDS[int(random.uniform(0,len(CODEWORDS)))] + word1 = CODEWORDS[int(random.uniform(0, len(CODEWORDS)))] - word2 = CODEWORDS[int(random.uniform(0,len(CODEWORDS)))] - word3 = CODEWORDS[int(random.uniform(0,len(CODEWORDS)))] - print "%s %s %s" % (word1.rstrip(), word2.rstrip(), word3.rstrip()) + word2 = CODEWORDS[int(random.uniform(0, len(CODEWORDS)))] + word3 = CODEWORDS[int(random.uniform(0, len(CODEWORDS)))] + print(f"{word1.rstrip()} {word2.rstrip()} {word3.rstrip()}") number -= 1 @@ -54,8 +55,10 @@ def main(argv=None): argv = sys.argv try: try: - opts, args = getopt.getopt(argv[1:], "hn:p:i:vw:", ["help", "number=", "prefix=", "wordlist="]) - except getopt.error, msg: + opts, args = getopt.getopt( + argv[1:], "hn:p:i:vw:", ["help", "number=", "prefix=", "wordlist="] + ) + except getopt.error as msg: raise Usage(msg) # option processing @@ -67,23 +70,19 @@ def main(argv=None): if option in ("-n", "--number"): number = int(value) if option in ("-w", "--wordlist"): - global CODEWORDS - print "Importing: %s" % value - CODEWORDS = open(value, 'r').readlines() + global CODEWORDS + print(f"Importing: {value}") + CODEWORDS = open(value, "r").readlines() if option in ("-p", "--prefixe"): - print value - - if (value): - prefix = value - else: - prefix = 'TRUE' + print(value) + prefix = value if value else "TRUE" generate(prefix, number) - except Usage, err: - print >> sys.stderr, sys.argv[0].split("/")[-1] + ": " + str(err.msg) - print >> sys.stderr, "\t for help use --help" + except Usage as err: + print(sys.argv[0].split("/")[-1] + ": " + str(err.msg), file=sys.stderr) + print("\t for help use --help", file=sys.stderr) return 2 diff --git a/scripts/generators/generate6words.py b/scripts/generators/generate6words.py index a75c054..ec56944 100755 --- a/scripts/generators/generate6words.py +++ b/scripts/generators/generate6words.py @@ -11,38 +11,43 @@ import getopt import random -#sys.stdout = open('output.txt','wt') +# sys.stdout = open('output.txt','wt') -help_message = ''' +help_message = """ Bip39 6 Word Random Generator By TheRealLordFractal Output File Saved as 12words.txt Command Exntensions: -n or --number : Number of sample code phrases given. (Default is 5) -w or --wordlist : Uses another wordlist to generate code phrases from. -''' +""" + +CODEWORDS = open("wordlist.txt", "r").readlines() +outputtxt = open("6words.txt", "w") -CODEWORDS = open('wordlist.txt', 'r').readlines() -outputtxt = open('6words.txt', 'w') class Usage(Exception): def __init__(self, msg): self.msg = msg + def generate(prefix=False, number=5): while number > 0: - if prefix == 'TRUE': - print ("Not Supported.") - # word1 = PREFIXES[int(random.uniform(0,len(PREFIXES)))] + if prefix == "TRUE": + print("Not Supported.") + # word1 = PREFIXES[int(random.uniform(0,len(PREFIXES)))] elif prefix: word1 = prefix else: - word1 = CODEWORDS[int(random.uniform(0,len(CODEWORDS)))] - word2 = CODEWORDS[int(random.uniform(0,len(CODEWORDS)))] - word3 = CODEWORDS[int(random.uniform(0,len(CODEWORDS)))] - word4 = CODEWORDS[int(random.uniform(0,len(CODEWORDS)))] - word5 = CODEWORDS[int(random.uniform(0,len(CODEWORDS)))] - word6 = CODEWORDS[int(random.uniform(0,len(CODEWORDS)))] - print >> outputtxt, "%s %s %s %s %s %s" % (word1.rstrip(), word2.rstrip(), word3.rstrip(), word4.rstrip(), word5.rstrip(), word6.rstrip()) + word1 = CODEWORDS[int(random.uniform(0, len(CODEWORDS)))] + word2 = CODEWORDS[int(random.uniform(0, len(CODEWORDS)))] + word3 = CODEWORDS[int(random.uniform(0, len(CODEWORDS)))] + word4 = CODEWORDS[int(random.uniform(0, len(CODEWORDS)))] + word5 = CODEWORDS[int(random.uniform(0, len(CODEWORDS)))] + word6 = CODEWORDS[int(random.uniform(0, len(CODEWORDS)))] + print( + f"{word1.rstrip()} {word2.rstrip()} {word3.rstrip()} {word4.rstrip()} {word5.rstrip()} {word6.rstrip()}", + file=outputtxt, + ) number -= 1 @@ -56,8 +61,10 @@ def main(argv=None): argv = sys.argv try: try: - opts, args = getopt.getopt(argv[1:], "hn:p:i:vw:", ["help", "number=", "prefix=", "wordlist="]) - except getopt.error, msg: + opts, args = getopt.getopt( + argv[1:], "hn:p:i:vw:", ["help", "number=", "prefix=", "wordlist="] + ) + except getopt.error as msg: raise Usage(msg) # option processing @@ -70,22 +77,18 @@ def main(argv=None): number = int(value) if option in ("-w", "--wordlist"): global CODEWORDS - print "Importing: %s" % value - CODEWORDS = open(value, 'r').readlines() + print(f"Importing: {value}") + CODEWORDS = open(value, "r").readlines() if option in ("-p", "--prefixe"): - print value - - if (value): - prefix = value - else: - prefix = 'TRUE' + print(value) + prefix = value if value else "TRUE" generate(prefix, number) - except Usage, err: - print >> sys.stderr, sys.argv[0].split("/")[-1] + ": " + str(err.msg) - print >> sys.stderr, "\t for help use --help" + except Usage as err: + print(sys.argv[0].split("/")[-1] + ": " + str(err.msg), file=sys.stderr) + print("\t for help use --help", file=sys.stderr) return 2 diff --git a/scripts/hash160.py b/scripts/hash160.py index 31ff32f..2ea3e31 100644 --- a/scripts/hash160.py +++ b/scripts/hash160.py @@ -1,13 +1,15 @@ import sys from bit.base58 import b58decode_check from bit.utils import bytes_to_hex + + def address_to_hash160(address): address_bytes = b58decode_check(address) - address_hash160 = bytes_to_hex(address_bytes)[2:] - - return address_hash160 -with open('list.txt') as textfile: - for line in textfile: - s = (line.rstrip('\n')) - h160=address_to_hash160(s) - print(h160) + return bytes_to_hex(address_bytes)[2:] + + +with open("list.txt") as textfile: + for line in textfile: + s = line.rstrip("\n") + h160 = address_to_hash160(s) + print(h160) diff --git a/defcoin_stealme.hex b/tests/defcoin_stealme.hex similarity index 100% rename from defcoin_stealme.hex rename to tests/defcoin_stealme.hex diff --git a/electrum-mnemonic-1626.txt b/tests/electrum-mnemonic-1626.txt similarity index 100% rename from electrum-mnemonic-1626.txt rename to tests/electrum-mnemonic-1626.txt diff --git a/example.hex b/tests/example.hex similarity index 100% rename from example.hex rename to tests/example.hex