๐
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
CFLAGS := -Wall -Wextra -Wpedantic -O3 | |
CXXFLAGS := ${CFLAGS} | |
LDFLAGS := -lsimdutf | |
main: main.o utf8_incremental.o |
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
""" | |
This pure-python ChaCha20 implementation reaches 32MiB/sec on my machine (M1 Pro) | |
otoh, cryptography.io's impl reaches about 1700MiB/s. Way faster, of course, but only about 50x faster. | |
This is code is a proof-of-concept and should not be used in a security context. | |
""" | |
CONST_MAGIC = b"expand 32-byte k" | |
CONST_WORDS = [int.from_bytes(CONST_MAGIC[i:i+4], "little") for i in range(0, 16, 4)] |
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
from typing import List, Tuple, Any | |
import json | |
def ensure_no_duplicate_keys(object_pairs: List[Tuple[str, Any]]) -> dict: | |
value = dict(object_pairs) | |
if len(value) != len(object_pairs): | |
raise ValueError("Duplicate JSON map keys") | |
return value | |
if __name__ == "__main__": |
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
""" | |
DISCLAIMER: This is a quick prototype, it's not at all tested, and may be deeply cryptographically flawed. | |
Normally, JSON canonicalization is at least O(nlogn), because you need to sort the map keys. | |
This approach avoids the need to do that, and in theory it's O(n), but in practice it's probably slower for most inputs... I have not benchmarked. | |
If you limit recursion depth, you could implement it as an Online Algorithm https://en.wikipedia.org/wiki/Online_algorithm | |
NB: Python's JSON parser allows duplicate map keys, which this impl will be oblivious to. |
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
/* | |
gcc main.c -o main -O3 -lSDL2 | |
This hits 240fps at 4K resolution, on my M1 Pro | |
*/ | |
#include <SDL2/SDL.h> | |
#include <stdio.h> |
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 zlib | |
from io import BytesIO | |
# TODO: make this shorter | |
RLEFLATE_MAGIC = b'\xed\xe3\t\x90$I\x92$I\xcc\xff\xff\xff\xff\xff\xff\xff\xff'\ | |
b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'\ | |
b'\xff\xff\xff\xff?3333\xe1\x0e\x00\x0e``\xa0\xaa*"\xc2\xdc]U\x04\x00\x80' | |
RLEFLATE_EOF = b'\x77' | |
RLEFLATE_REPEAT = [ | |
None, b'W', b'7', b'G', b'g', b'#', b'3', b'+', b';', b'\x11', b'Q', |
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
NUCLEAR WASTE SOFTWARE LICENSE V1.0 | |
Copyright <YEAR> <OWNER> | |
This software license is a message... and part of a system of messages... | |
pay attention to it! Writing this software and associated documentation | |
files (the "Software") was important to us. We considered ourselves to be a | |
powerful culture. This Software is not a place of honor... no highly | |
esteemed deed is commemorated here... nothing valued is here. What is here was | |
dangerous and repulsive to us. This message is a warning about danger. The |
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 io | |
import base64 | |
import struct | |
import hashlib | |
import asyncio | |
import websockets | |
from enum import Enum | |
# ground control to major type |
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 hashlib | |
from functools import reduce | |
inputs = """\ | |
4194f2d3111228a07aeb0a54684fa4de21164109c4c789cd6b890771dbb3fff6 | |
273853d452aec0d82d7599c043ec4bb55bf1f473a8d02302992f032e0804c02b | |
f4b264de9e84cd80c356712b686d9faff35dabb4221fd33966a18c9ddbe8a371 | |
5f15dfdc4f1916427eb126f65d0b49ceba89db4653215fae7683b7c93ac733f7 | |
78036761ae5ce55a3646baf06b0caf7301f7b060034c59bb097566c511f2c91d | |
7cb072d0b4be5eee1b115882d5655a588ad5ada350cfffb635216fa6cf871e91 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.