Skip to content

Instantly share code, notes, and snippets.

@shmookey
shmookey / README
Created January 7, 2022 05:54
3103 common 5-letter words
this word list comprises the intersection of 5 letter words occurring in three source lists:
- wikipedia's list of most 100k most common words in the english language
- the american english dictionary file on my laptop
- the british english dictionary file on my laptop
the source lists are sanitised by dropping words that contain non-alphabetic or non-ascii
characters and converting capitals to lowercase.
only words that occur in all three resulting lists are kept.
@shmookey
shmookey / translate.lhs
Last active January 18, 2020 19:24
off-chain storage for ethereum smart contracts
External storage on the EVM: a static recompilation approach 7 May 2017
Luke Williams <shmookey@shmookey.net> Rev. 3
This document describes a way of converting ordinary compiled EVM contracts to
a form suitable for use with an off-chain storage backend, such as the system
described by Smolenski for storing contract state on IPFS. This technique is
completely invisible to the contract developer and requires no modification to
contract logic. It is also generic to any EVM contract, regardless of the high
level language it was written in, and compatible with the public blockchain.
@shmookey
shmookey / rot13words.hs
Last active February 8, 2017 03:05
words that rot13 to other words
import Data.Char (chr, ord)
import Data.List (sortOn)
rot13 :: String -> String
rot13 = map rot where
rot x =
let
n = ord x
isUpper = n >= 65 && n <= 90
isLower = n >= 97 && n <= 122
@shmookey
shmookey / enigma-problem.md
Created May 16, 2016 05:58
multiparty computation

Consider two business associates, Adam and Karl, who want to arrange an exchange of information. Adam has knowledge of two secret numbers k and j. He must never disclose their values to anyone. Karl wants to calculate a function of these two numbers:

f(k, j) = k + j

Adam decides that it is OK for Karl to know the value produced by this function, but not the inputs. This poses a tricky problem. Karl is not interested in the input values, and though he trusts Adam to be honest about them, he wants some proof that his calculation is being performed correctly. Puzzled by these seemingly irreconcilable constraints, they decide to call upon some mutual contacts for help.

@shmookey
shmookey / rsa.hs
Created May 2, 2016 04:40
rsa experiments in haskell
module Main where
import Math.NumberTheory.Powers
import Math.NumberTheory.Moduli
import Data.Maybe
e = 65537
φ p q = (p - 1) * (q - 1)
d p q = fromJust $ invertMod e (φ p q)
@shmookey
shmookey / rsa-decryption-order.sh
Last active April 30, 2016 21:42
rsa decryption order experiment
!/bin/bash
# Hypothesis: data encrypted with multiple RSA public keys can be
# decrypted by the matching private keys irrespective of the order in
# which the keys were originally used.
# We shall see about that.
# Generate two 1024-bit RSA keys `k` and `j`
openssl genrsa -out k 1024
@shmookey
shmookey / test.hs
Created April 19, 2016 04:03
Overlapping instances
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
-- Let's say our project involves a number of similarly-structured reader monads.
-- Their data types might look like this:
data Conf = Conf {}
data ConfReader a = ConfReader { runConfReader :: Conf -> IO a }
@shmookey
shmookey / Effector.elm
Last active August 27, 2015 07:09
Effector in Elm
module Data.Effector where
import List exposing (length)
type alias Effector a b =
{ run : ((a, List b) -> a) -> a -> (a -> a, List b) }
(|>>) : Effector a b -> (a -> (a -> a, List b)) -> Effector a b
(|>>) f g = Effector <|
### Keybase proof
I hereby claim:
* I am shmookey on github.
* I am shmookey (https://keybase.io/shmookey) on keybase.
* I have a public key whose fingerprint is 430B FD47 1DB7 645F 8F42 DD04 0E06 2D5F 0D5B 197F
To claim this, I am signing this object: