This file contains 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 sys import byteorder | |
from hashlib import sha256 | |
uint256 = int | |
uint256_minus_1 = uint256 | |
def source_parity(i: uint256) -> bool: | |
return (i & 1) != 0 | |
def target_parity(i: uint256) -> bool: |
This file contains 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
""" | |
I define a collision-free hash function, forward : uint256 -> uint256, that is invertible on | |
most values, but for which it is infeasible to find preimages of large hashes. | |
We also give an inverse, backward : uint256 -> uint256, that runs quickly for small hashes, but | |
becomes too slow to use at the extreme end. | |
For instance, backward(2^256 - 1) needs to run 2^256 playoffs amongst all numbers. This is a | |
feature, not a bug, as it provides an initial answer to Vitalik's puzzle: | |
https://twitter.com/VitalikButerin/status/1516317085290446848 |
This file contains 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
{-# LANGUAGE BlockArguments #-} | |
-- Setup | |
when :: (a -> Bool) -> a -> [a] | |
when f a = if f a then [a] else [] | |
newtype Zip a = Zip { getZip :: [a] } | |
deriving (Eq, Ord, Show) |
This file contains 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
#include <iostream> | |
#include <algorithm> | |
using namespace std; | |
#define fo(i,n) for(int i=0,_n=(n);i<_n;i++) | |
int n,delta,w[300][300],l[300],r[300],rm[300]; | |
bool ul[300], ur[300], m[300][300]; | |
const int oo = 2000000; | |
void relax() { |
This file contains 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 json | |
import hashlib | |
import hmac | |
from collections import OrderedDict | |
def get_viewer_url_signature(account_id, auth_token, identifier, valid_until_timestamp): | |
# type: (str, str, str, int) -> str | |
# First, we generate our policy, which is an object giving the account_id and |