Skip to content

Instantly share code, notes, and snippets.

View richardkiss's full-sized avatar

Richard Kiss richardkiss

View GitHub Profile
@richardkiss
richardkiss / sl
Created March 30, 2018 17:54
A "mirror-image" ls in python, as discussed at https://news.ycombinator.com/item?id=16716150
#!/usr/bin/env python
import subprocess
import sys
output = subprocess.check_output(["ls"] + sys.argv[1:])
lines = output.split("\n")
@richardkiss
richardkiss / pycoin_custom_sign.py
Last active March 4, 2020 19:50 — forked from darklow/pycoin_custom_sign.py
pycoin_custom_sign.py
from pycoin.encoding.hexbytes import b2h
from pycoin.intbytes import int2byte
from pycoin.key import Key
from pycoin.networks.registry import network_for_netcode
from pycoin.satoshi.der import sigencode_der
network = network_for_netcode('XTN')
Tx = network.tx
TxIn = network.tx.TxIn

Idempotent clarifications

Here are a bunch of changes you can make for humans only. None of these changes should change how it compiles, so you should be able to change anything in this section and compare the resultant compile. It should be identical.

reformat

I've really love an automated pretty-printer akin to "black" for python or "cargo fmt" for rust so you can write whatever mess you want and have a computer indent it so it looks nice, but I haven't been able to find one yet.

@richardkiss
richardkiss / venv
Created March 18, 2021 22:10
A nice shell script to put all your venvs in the same place
#!/bin/sh
VENV_PATH=${@:-${VENV_BASE_PATH:-~/tmp/virtualenvs}}/`pwd | sed "s|/|_|g"`/venv
if [ -e $VENV_PATH ]
then
echo rm -rf $VENV_PATH
echo and try again
else
mkdir -p $VENV_PATH
@richardkiss
richardkiss / settlement_payments.md
Last active November 5, 2023 09:40
Ideas about Offers on Chia

We introduce a new puzzle, "settlement_payments", which pays out coins and make an announcement for each new coin created.

settlement_payments.cl:

(mod (coins_paid)
  ;; `coins_paid` is a list of notarized coin payments
  ;; a notarized coin payment is `(nonce puzzle_hash amount ...)`
  ;; Each notarized coin payment creates a `(CREATE_COIN puzzle_hash amount)` payment
@richardkiss
richardkiss / comp-test.py
Last active December 23, 2021 03:35
offer-zlib-compression
import zlib
from chia.wallet.puzzles.load_clvm import load_clvm
from chia.wallet.puzzles import p2_delegated_puzzle_or_hidden_puzzle as standard_puzzle
from chia.wallet.puzzles.cc_loader import CC_MOD
OFFER_MOD = load_clvm("settlement_payments.clvm")
puzzle_dict = bytes(OFFER_MOD) + bytes(standard_puzzle.MOD) + bytes(CC_MOD)
@richardkiss
richardkiss / block-compression.md
Created August 23, 2022 20:00
Block Compression: serialization with back-references

Block Generators

Block generators in Chia are clvm programs that, when run with particular arguments, produce a list of coin spends. This provides opportunity to do compression by recognizing patterns and encoding.

CLVM Serialization

The standard serialization mechanism of clvm is defined here.

If you review this specification, you'll see that deserialization begins by inspecting the first byte. If the byte is 0xff, the object is a pair. If the byte is 0x00 to 0xfb, the object is an atom whose length is partially or fully encoded by this first byte.

@richardkiss
richardkiss / copy-protection.cl
Created August 31, 2022 18:09
A generator blob that check parameters
(mod arguments
; this generator blob will fail if the correct run-time parameters are not included
(defun sha256tree
(TREE)
(if (l TREE)
(sha256 2 (sha256tree (f TREE)) (sha256tree (r TREE)))
(sha256 1 TREE)
)
@richardkiss
richardkiss / nvidia-proxmox-kernel.md
Last active February 27, 2024 03:23
Minimal install of nvidia kernel drivers on proxmox host
(mod V0 ;; V0 should be 0
(include *standard-cl-21*)
;; projective point: ((X . Y) . Z)
(defun-inline x-for-p (POINT) (f (f POINT)))
(defun-inline y-for-p (POINT) (r (f POINT)))
(defun-inline z-for-p (POINT) (r POINT))