-
-
Save hansieodendaal/721db88197b6b8ff1683f5748e7e9e44 to your computer and use it in GitHub Desktop.
Proposed RAID_ID algorithm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from hashlib import blake2b | |
import bitcoin.base58 as base58 #dependency: pip install python-bitcoinlib | |
import string | |
import random | |
import binascii | |
def create_raid(Pk, fqdn, prefix): | |
s = fqdn if fqdn else "NO_FQDN" | |
#Creat hash object | |
hash = blake2b(digest_size=10) | |
#Concatenate FQDN and public key | |
hash.update(bytes(map(ord, Pk))) | |
hash.update(bytes(map(ord, str(fqdn)))) | |
#Hash | |
hash_digest = hash.digest() | |
#Base58 encoding | |
s_con = bytes([prefix]) + hash_digest | |
base58_encode = [] | |
base58_encode.append([binascii.hexlify(bytes([prefix])), hash_digest, base58.encode(s_con)]) | |
return base58_encode | |
pub_key = "ca469346d7643336c19155fdf5c6500a5232525ce4eba7e4db757639159e9861" | |
print("\nPublic Key = %s" % (pub_key)) | |
for s in [None, "disney.com", "www.tarilabs.com", "tickets.bigneon.com"]: | |
print("\nFQDN: \"%s\"" % (s)) | |
print("PubKey & FQDN: \"%s\"" % (pub_key + str(s))) | |
raid_id = [] | |
#Calculate RAID_ID with extended prefix range | |
for prefix in range(0x00, 0xff): | |
b58 = create_raid(pub_key, s, prefix) | |
raid_id.append(b58[0]) | |
print(" => blake2b_10 digest %s" % (raid_id[0][1])) | |
print(" => blake2b_10 hexdigest %s" % (binascii.hexlify(raid_id[0][1]))) | |
#Only print selected prefix range | |
for i in range(len(raid_id)): | |
if raid_id[i][2][0] == 'R': | |
print(" => base58 (%4s) %s" % (raid_id[i][0], raid_id[i][2])) |
Author
hansieodendaal
commented
Mar 15, 2019
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment