Skip to content

Instantly share code, notes, and snippets.

View daira's full-sized avatar

Daira-Emma Hopwood daira

View GitHub Profile
@daira
daira / gist:3290388
Created August 7, 2012 23:08
excerpt from #leastauthorityenterprises on freenode
(18:37:09) amiller: zooko, i'd like to chat about lae sometime soon
(18:39:45) zooko: amiller: Hi! Oh, I'd love that. What mode of chat do you prefer?
(18:39:52) amiller: irc!
(18:39:54) zooko: When's the next time you're coming to visit Boulder? :-)
(18:40:00) amiller: sometime!
(18:40:02) zooko: Okay, anytime!
(18:40:05) amiller: how bout now
(18:40:06) zooko: I mean, okay anytime about IRC chat.
(18:40:09) zooko: Okay.
(18:40:38) amiller: i figured out / remembered how to use flogtool again
@daira
daira / gist:3300082
Created August 9, 2012 00:56
ExpirationPolicy
class ExpirationPolicy(object):
def __init__(self, enabled=False, mode="age", override_lease_duration=None,
cutoff_date=None, sharetypes=("mutable", "immutable")):
precondition(isinstance(enabled, bool), enabled=enabled)
precondition(mode in ("age", "cutoff-date"), mode=mode)
precondition(isinstance(override_lease_duration, (int, NoneType)),
override_lease_duration=override_lease_duration)
precondition(isinstance(cutoff_date, int) or (mode != "cutoff-date" and cutoff_date is None),
cutoff_date=cutoff_date)
precondition(isinstance(sharetypes, tuple), sharetypes=sharetypes)
# https://eprint.iacr.org/2012/254
def random(K):
ctr = 0
while True:
yield AES(K, ctr)
ctr += 1
def PRP(K, x):
return (x, 0, N, 0, random(K))
SELECT alltxs.block_timestamp_month, fulltxs.fully_shielded_count, 100*fulltxs.fully_shielded_count/alltxs.count AS fully_shielded_percent FROM
(SELECT
block_timestamp_month, count(distinct `hash`) AS fully_shielded_count
FROM
`bigquery-public-data.crypto_zcash.transactions` AS zec_txs
WHERE
NOT EXISTS (SELECT 1 FROM UNNEST(zec_txs.inputs) WHERE NOT type = 'shielded')
AND NOT EXISTS (SELECT 1 FROM UNNEST(zec_txs.outputs) WHERE NOT type = 'shielded')
GROUP BY block_timestamp_month) fulltxs
INNER JOIN

Keybase proof

I hereby claim:

  • I am daira on github.
  • I am zedaira (https://keybase.io/zedaira) on keybase.
  • I have a public key ASDhxWkEakEA-bzyc2LulixNHnPD83MdWX4Q4cGxlezvRwo

To claim this, I am signing this object:

@daira
daira / addchain_5inv_rtl.py
Created March 19, 2021 18:30
rtl addition chain
# ---> up to here is a multiple of 3 :-)
x_p = 0b11001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001101001110100111101110000011001001101000010000101001100000111000101110000011110000111100111111000011001100110011001100110011001101
pchain = Chain()
pi = pa = 1
for i in range(1, 114):
pi = pchain.sqr(pi)
if '101110000011001001101000010000101001100000111000101110000011110000111100111111000011001100110011001100110011001101'[113-i] == '1':
pa = pchain.mul(pa, pi)
@daira
daira / addchain_5inv_rtlv2.py
Created March 19, 2021 19:06
rtl addition chain v2
# ---> up to here is a multiple of 0b110011 = 51 :-)
x_p = 0b11001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001101001110100111101110000011001001101000010000101001100000111000101110000011110000111100111111000011001100110011001100110011001101
pchain = Chain()
pi = pa = 1
for i in range(1, 128):
pi = pchain.sqr(pi)
if '01001110100111101110000011001001101000010000101001100000111000101110000011110000111100111111000011001100110011001100110011001101'[127-i] == '1':
pa = pchain.mul(pa, pi)
#!/usr/bin/env python3
from collections import deque
from math import inf
import json
# For simplicity use the same disjoint-set data structure as for the
# permutation argument.
class DisjointSets(object):
def __init__(self, n):
#!/usr/bin/env python3
from collections import deque
from math import inf
from random import randrange
import json
# A proposed "set of simple selectors" s_{1..k} for a configuration is consistent iff
# for each selector s_i,
# * s_i is a boolean fixed column; and
@daira
daira / supply.py
Created November 12, 2022 00:03
Calculate the Zcash supply after a given block height on Mainnet or Testnet
#!/usr/bin/env python3
def exact_div(x, y):
assert x % y == 0
return x // y
# floor(u/x + v/y)
def div2(u, x, v, y):
return (u*y + v*x) // (x*y)