Created
November 6, 2018 16:37
-
-
Save maqp/90a64e9649764b21234ce90367fc7971 to your computer and use it in GitHub Desktop.
Riot vs Signal fingerprint read time
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
import base64 | |
import os | |
# The durations floats are durations in seconds it took to have Google | |
# translate pronounce each word. These samples were recorded and the | |
# duration was measured using Audacity to best of ability. | |
b10_table = {'0': ('zero ', 0.882), | |
'1': ('one ', 0.699), | |
'2': ('two ', 0.718), | |
'3': ('three ', 0.661), | |
'4': ('four ', 0.573), | |
'5': ('five ', 0.647), | |
'6': ('six ', 0.522), | |
'7': ('seven ', 0.781), | |
'8': ('eight ', 0.642), | |
'9': ('nine ', 0.737)} | |
nato_table = { | |
'a': ('alfa', 0.669), | |
'b': ('bravo', 0.710), | |
'c': ('charlie', 0.756), | |
'd': ('delta', 0.702), | |
'e': ('echo', 0.784), | |
'f': ('foxtrot', 0.909), | |
'g': ('golf', 0.666), | |
'h': ('hotel', 0.781), | |
'i': ('india', 0.726), | |
'j': ('juliett', 0.882), | |
'k': ('kilo', 0.658), | |
'l': ('lima', 0.658), | |
'm': ('mike', 0.456), | |
'n': ('november', 0.849), | |
'o': ('oscar', 0.658), | |
'p': ('papa', 0.776), | |
'q': ('quebec', 0.770), | |
'r': ('romeo', 0.868), | |
's': ('sierra', 0.937), | |
't': ('tango', 0.806), | |
'u': ('uniform', 0.915), | |
'v': ('victor', 0.819), | |
'w': ('whiskey', 0.874), | |
'x': ('xray', 0.745), | |
'y': ('yankee', 0.918), | |
'z': ('zulu', 0.808), | |
'/': ('slash', 0.708), | |
'+': ('plus', 0.726) | |
} | |
samples = 100_000 | |
b10_total_time = 0 | |
b64_total_time = 0 | |
for _ in range(samples): | |
fingerprint = os.urandom(32) | |
base64_fingerprint = base64.b64encode(fingerprint).decode().strip('=') | |
# Signal style, combined fingerprint truncated to 60 digits | |
base10_fingerprint = str(int(fingerprint.hex(), base=16))[:60] | |
b10_read_duration = 0 | |
for c in base10_fingerprint: | |
b10_read_duration += b10_table[c][1] | |
b10_total_time += b10_read_duration | |
b64_read_duration = 0 | |
for c in base64_fingerprint: | |
if c.isdigit(): | |
b10_read_duration += b10_table[c][1] | |
continue | |
if c.isupper(): | |
b64_read_duration += 0.707 # Time to say "capital" | |
b64_read_duration += nato_table[c.lower()][1] | |
b64_total_time += b64_read_duration | |
print("Base10 average: {}".format(b10_total_time / samples)) | |
print("Base64 average: {}".format(b64_total_time / samples)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment