Karl Semich 0xloem at gmail.com
Thu Aug 11 14:48:46 PDT 2022


# indexes a balanced tree of past indices
class append_indices(list):
    def __init__(self, degree = 2, initial_indices = []):
        self.degree = degree
        self.leaf_count = 0
    def append(self, last_indices_id):
        self.leaf_count += 1
        leaf_count = self.leaf_count
        idx = 0
        for idx, (sub_leaf_count, value) in enumerate(self):
            if sub_leaf_count * self.degree <= leaf_count:
            leaf_count -= sub_leaf_count
            idx += 1 # to append if the loop falls through
        self[idx:] = [(leaf_count, last_indices_id)]

I am quite satisfied and proud of putting this together. It produces a
balanced binary tree from append-only data like the dat project's
protocol, but is only a handful of lines long and uses few operations.
I made it to try to draft another cryptographic livestreaming system.
Still haven't quite reached workability yet. It does _not_ include
random writes as pursued in the other thread for a bit, which i
decided i wanted to do by organizing trees to be deepest away from
recent writes. The theory is quite similar, of used indices obscuring
the content of deeper indices, keeping the depth of the tree bounded
even when including references to deeper leaves.

When I was making it, I was in one of my confusing situations where I
was using an offline terminal with a working keyboard via serial cable
to connect to a raspberry pi without a keyboard where i used mosh over
yggdrasil to connect to a firewalled remote system that had more
resources than local things. Something had started going wrong with
the network or possibly remote i/o, and keystrokes were very slow. The
algorithm was quite hard for me to think about, and the delay with
keystrokes was making it harder. I disconnected from all the things,
and tried hard to draft it locally. I had struggle-fun with it, and
kept reorganising it until it got small. I worked on it inside a local
tmux session, so I then opened up the serial terminal and mosh again
from within the local tmux session, and used tmux's buffer support to
copy the text over.

The end result actually works; I blockchained some audio from an
android phone, and after a lot of dev attempts downloaded the audio
again off a network peer, and reconstructed it from the index trees,
and played it. However, the upload process was too slow, and most of
the content was lost from recording overrun; the download contained
only interspersed brief clear snippets of audio pasted together.

Still, so close!! and it's enough to prove something happened from
your phone. It runs in tmux and uses the android audio hardware.

More information about the cypherpunks mailing list