A Blog by Richard Kiss
type: channel
description: Taste the Excitement™
date: 2021-02-06T01:30:13Z
update period: hourly
update frequency: 1
update base: 2000-01-01T12:00+00:00
generator agent: https://wordpress.org/
items: Get Your BCash in Under Ten Minutes with pycoin
items: Calculating Fibonacci Numbers, Quickly and Exactly
items: Messing with Bitcoin Keys and Addresses
items: Command-line Bitcoin Transactions
items: On BIP0032 and Bitcoin Deterministic Wallets
items: How to be Minimally Redundant (or “A Splitting Headache”)
items: Good-bye App Engine
items: Farley’s Open Mic Performance
items: Some Whining About Video Software
items: People Get Better at Stuff

Get Your BCash in Under Ten Minutes with pycoin
type: item
creator: Richard
date: 2017-09-09T00:06:57Z
subject: Computers
description: BCash, or Bitcoin Cash is a hard fork of Bitcoin as of August 1, 2017, so it’s pretty new. Recently, I’ve been working on a big refactor of pycoin to make it more flexible in handling altcoins. Creating BCash transactions seems to work now. If you had bitcoin on August 1, you now have bcash. … Continue reading Get Your BCash in Under Ten Minutes with pycoin →
encoded: BCash, or Bitcoin Cash is a hard fork of Bitcoin as of August 1, 2017, so it’s pretty new. Recently, I’ve been working on a big refactor of pycoin to make it more flexible in handling altcoins. Creating BCash transactions seems to work now. If you had bitcoin on August 1, you now have bcash. Here’s how you can create transactions with BCash with nothing but the private keys and a few calls to web services. First, switch to a throwaway environment. I like to use a RAM disk. On Mac OS X: $ diskutil erasevolume HFS+ RAMDISK `hdiutil attach -nomount ram://81920` $ cd /Volumes/RAMDISK/ Set up your service providers and a place to cache the source transactions. The service providers will be used to get spendables for the addresses you’re querying, as well as the source transactions. $ export PYCOIN_BCH_PROVIDERS=insight:http://blockdozer.com/insight-api $ export PYCOIN_CACHE_DIR=./tx-cache This example will query blockdozer.com to get spendables and transactions. Copy all your relevant WIFs to a file here. It’s okay for the file to have WIFs that aren’t used, but you will obviously need all the WIFs you wish to spend from. $ cat > wifs.txt (paste to terminal, one WIF per line) Alternatively, you can use a GPG-encrypted file. $ gpg -e > wifs.gpg (specify recipients, then paste to terminal, one WIF per line) We’ll be using python 3. Install pycoin into a virtual environment. $ python3 -m venv env $ . env/bin/activate $ pip install -e git+git@github.com:richardkiss/pycoin.git@57b508d5208f98a304b9bd3a491c3f0049aed96b#egg=pycoin Verify that an address has coins to spend from. $ tx -n BCH -i 16NgXiMwRimMcSXLTf4KFwoW968btQ1GmZ 62263e20a70ec98cd52452ffca6f5c54fa02a45cc0a70aca14b99f2445407678/0/76a9143af25c9925ad4d20e1df648a82268d44445430ec88ac/1990000/0/0/0 b0011baf07830ec04d5adb66b1503ad6c9498dfe6c5590f05c8226c9f83fa0df/0/76a9143af25c9925ad4d20e1df648a82268d44445430ec88ac/1185613/0/0/0 Create an unsigned transaction that contains just the inputs. $ tx -n BCH -a -i 16NgXiMwRimMcS…

Calculating Fibonacci Numbers, Quickly and Exactly
type: item
creator: Richard
date: 2013-12-28T06:25:47Z
subject: Computers
description: The well-known Fibonacci series \(F_n\) can be defined as follows: \(F_n = \begin{cases} 0 & n = 0 \\ 1 & n = 1 \\ F_{n-2} + F_{n-1} & n \ge 2\\ \end{cases}\) Let’s use a few facts about matrices to find a quick way to calculate terms in this famous series. Lemma Let \(A … Continue reading Calculating Fibonacci Numbers, Quickly and Exactly →
encoded: The well-known Fibonacci series \(F_n\) can be defined as follows: \(F_n = \begin{cases} 0 & n = 0 \\ 1 & n = 1 \\ F_{n-2} + F_{n-1} & n \ge 2\\ \end{cases}\) Let’s use a few facts about matrices to find a quick way to calculate terms in this famous series. Lemma Let \(A = \begin{bmatrix} 0 & 1 \\ 1 & 1 \end{bmatrix}\). Then \(A^n = \begin{bmatrix} F_{n-1} & F_n \\ F_n & F_{n+1} \end{bmatrix}\). Proof The \(n = 1\) case follows immediately from the definitions of \(A \text{ and } F_n\). Suppose the statement is true for n. Then $$\begin{align} A^{n+1} & = A^n A \\ & = \begin{bmatrix} F_{n-1} & F_n \\ F_n & F_{n+1} \end{bmatrix} \begin{bmatrix} 0 & 1 \\ 1 & 1 \end{bmatrix} \\ & = \begin{bmatrix} F_n & F_{n-1} + F_n \\ F_{n+1} & F_n + F_{n+1} \end{bmatrix} \\ & = \begin{bmatrix} F_n & F_{n+1} \\ F_{n+1} & F_{n+2} \end{bmatrix} \end{align}$$ And our result follows by induction. QED Now, notice that \(\begin{align} \begin{bmatrix} F_{2n-1} & F_{2n} \\ F_{2n} & F_{2n+1} \end{bmatrix} & = A^{2n} \\ & = A^n A^n \\ & = \begin{bmatrix} F_{n-1} & F_n \\ F_n & F_{n+1} \end{bmatrix} \begin{bmatrix} F_{n-1} & F_n \\ F_n & F_{n+1} \end{bmatrix} \\ & = \begin{bmatrix} F_{n-1}^2 + F_n ^ 2 & F_{n-1} F_n + F_n F_{n+1} \\ F_{n-1} F_n + F_n F_{n+1} & F_n^2 + F_{n+1} ^ 2 \end{bmatrix} \end{align}\) Using this identity, we can write \(F_{2n}\) and \(F_{2n+1}\) in terms of \(F_n\) and \(F_{n+1}\). \(\begin{align} F_{2n} & = F_{n-1} F_n + F_n F_{n+1} \\ & = (F_{n+1} – F_n) F_n + F_n F_{n+1} \\ & = F_n F_{n+1} – F_n^2 + F_n F_{n+1} \\ & = 2 F_{n+1} F_n – F_n ^ 2 \end{align} \) \(F_{2n+1} = F_{n}^2 + F_{n+1}^2\) We now have a way of calculating \(F_{2n}\) and \(F_{2n+1}\) by calculating only a few of the smaller terms in the sequence. This yields some wildly efficient Python code: def fib2(N): if N == 0: return (0, 1) half_N, is_N_odd = divmod(N, 2) f_n, f_n_plus_1 = fib2(half_N) f_n_squared = f_n * f_n f_n_plus_1_squared = f_n_plus_1 * f_n_plus_1 f_2n = 2 * f_n * f_n_plus_1 - f_n_squared f_…

Messing with Bitcoin Keys and Addresses
type: item
creator: Richard
date: 2013-10-26T23:58:06Z
subject: Computers
description: The “bu” tool is obsolete, which makes this post not-so-useful. Look at this file instead. The command line utility “bu” (for “Bitcoin utilities”) is included with my Python-based pycoin library. This utility makes it easy to deal with Bitcoin private keys and addresses in their native and various intermediate formats. Let’s go through some examples. … Continue reading Messing with Bitcoin Keys and Addresses →
encoded: The “bu” tool is obsolete, which makes this post not-so-useful. Look at this file instead. The command line utility “bu” (for “Bitcoin utilities”) is included with my Python-based pycoin library. This utility makes it easy to deal with Bitcoin private keys and addresses in their native and various intermediate formats. Let’s go through some examples. The most basic form of a Bitcoin private key is simply an integer between 1 and 115792089237316195423570985008687907852837564279074904382605163141518161494336 ? 1.15e77 (inclusive). That’s it! This integer is a “secret exponent”, because generating the public key involves exponentiation, and there is no known way to go from the public key to the secret exponent. Let’s take a look at the very first private key, also known as “1”. $ bu 1 secret exponent: 1 hex: 1 WIF: KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn uncompressed: 5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsreAnchuDf public pair x: 55066263022277343669578718895168534326250603453777594175500187360389116729240 public pair y: 32670510020758816978083085130507043184471273380659243275938904335757337482424 x as hex: 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 y as hex: 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 y parity: even key pair as sec: 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 uncompressed: 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\ 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 hash160: 751e76e8199196d454941c45d1b3a323f1433bd6 uncompressed: 91b24bf9f5288532960ac687abb035127b1d28a5 Bitcoin address: 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH uncompressed: 1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm You can see from blockchain.info that the addresses corresponding to this private key (1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH and 1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm) are used a lot in tests. Of course, neither has any funds in it (well, at least not at this time), since dr…

Command-line Bitcoin Transactions
type: item
creator: Richard
date: 2013-07-30T01:47:22Z
subject: Computers
description: The “spend” tool is obsolete, which makes this post not-so-useful. Look at the “tx” tool mentioned in this post instead. Creating a signed transaction is the holy grail of Bitcoin. Without this functionality, a Bitcoin client can’t really be called a client. Being able to sign a transaction though… wow! The whole Bitcoin world is … Continue reading Command-line Bitcoin Transactions →
encoded: The “spend” tool is obsolete, which makes this post not-so-useful. Look at the “tx” tool mentioned in this post instead. Creating a signed transaction is the holy grail of Bitcoin. Without this functionality, a Bitcoin client can’t really be called a client. Being able to sign a transaction though… wow! The whole Bitcoin world is at your fingertips! OK, that may be a bit of an overstatement… but it’s still pretty neat stuff. My pycoin project features a Python command-line script “spend” that will let you generate a standard transaction that reassigns coins from one set of addresses to another set. It’s obviously not nearly as easy as using a GUI app to spend your bitcoin. But it is very simple-to-follow sample code that you can use as a template should you want to create your own Bitcoin transactions programmatically. To create a transaction, you need the coin sources. These are the TxOut portions of the transactions that assigned bitcoin to an address. The “spend” script takes bitcoin addresses as input, and queries the blockchain.info web site to get the list of unclosed spendable transactions. This script “spends” all your bitcoin on the addresses you give. No problem though: you can send coins you want to keep (the “change”) to an address you control. Here’s an example blockchain.info query: http://blockchain.info/unspent?active=12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX (If Satoshi ever gets around to spending all these coins, this URL will throw a 500.) Of course, it’s not enough to have the sources for the coins; you need the private key. Although pycoin deals with this private key in its native “secret exponent” numerical form, the spend script expects WIF format. So you need to create a file with the WIF. How you get the WIF depends on how you generated the address. In Electrum, right-click on the address and choose “Private Key”, and the WIF will be displayed. For maximal security, you might think about creating this WIF file on a RAM disk. On Mac OS X, diskutil …

On BIP0032 and Bitcoin Deterministic Wallets
type: item
creator: Richard
date: 2013-07-08T19:34:24Z
subject: Computers
description: BIP0032 defines a way to create a hierarchical deterministic wallet (that is, a way to create an entire tree of Bitcoin addresses and private keys) through a tree of wallet key nodes. Each node has a public and private key associated with it, which can be displayed as a Bitcoin address and a WIF string. … Continue reading On BIP0032 and Bitcoin Deterministic Wallets →
encoded: BIP0032 defines a way to create a hierarchical deterministic wallet (that is, a way to create an entire tree of Bitcoin addresses and private keys) through a tree of wallet key nodes. Each node has a public and private key associated with it, which can be displayed as a Bitcoin address and a WIF string. But each node also has additional entropy information, called the “chain code”, which gets fed back into the algorithm that generates the children, so revealing even the WIF doesn’t give enough information to reveal the children. A node can be stripped of private key information, yielding a public key node. These nodes can only generate the Bitcoin address, and not the WIF. But they can still generate half of the child nodes. But only the public key node versions. So once you strip out the private-ness from a node, it’s gone forever. Each node element can be represented by a 111-digit base58 number that looks like this: [binary] Keys for the main network start with “xprv” (private) or “xpub” (public). A node has 2^32 children, enumerated 0, 1, 2 .. 4294967295. Children with index at least 2^31=2147483648=0x80000000 are derived using “prime” or “private key” derivation, and can only be generated by the private wallet key. We use the shortcut 2p or 2’ to indicate child number 2+0x80000000. A “key path” is a route down the tree. It’s a “/”-separated list of numbers, where each number can optionally have a trailing p or ’ character to indicate “prime”. (Typing “p” is much easier than “’” which needs to be escaped or quoted in the shell.) Example key paths: “1”, “0/2p”, “0p/1000/5”, “0/0/0/0/0/37”. Reading the BIP0032 is a hard slog. Maybe some examples will make this clearer. I’ve created a script for now called genwallet (I know, I know, I need a better name) that lives in my pycoin project. Create a virtualenv and install it. This has been tested with Python 3.3 but should work in Python 2.7 too. There may be minor discrepencies in what you see here and what you see on…

How to be Minimally Redundant (or “A Splitting Headache”)
type: item
creator: Richard
date: 2013-06-11T19:43:11Z
subject: Computers
description: I’ve recently been investigating the command-line utility zfec, which is a lot like the UNIX “split” utility, except, using a technique called erasure coding, you can choose to split your file into M pieces, any K of which are enough to recreate the file using the complimentary [sic] zunfec command. Concrete example: a 100K file … Continue reading How to be Minimally Redundant (or “A Splitting Headache”) →
encoded: I’ve recently been investigating the command-line utility zfec, which is a lot like the UNIX “split” utility, except, using a technique called erasure coding, you can choose to split your file into M pieces, any K of which are enough to recreate the file using the complimentary [sic] zunfec command. Concrete example: a 100K file can be split into 10 (or more) pieces, each just over 25K long, and zunfec can recreate the original from any 4 of them. Any 4. You might expect this to incur a lot of overhead in each piece, but it turns out it’s just a header of four bytes or less. Pretty much the same as cutting the file into pieces. This amazed me. How could this possible work? How can you split data into M pieces so that any K of them is enough to reconstruct them? Linear algebra to the rescue! Suppose we want to encode a twelve character text string into a bunch of arrays, each with four values, any three of which are sufficient to reconstruct the original. Let’s use the string “Lovefromdawn”. Here’s what you do: The matrix furthest to the left is a Vandermonde matrix, which is a matrix where each row forms a geometric series starting with 1. A square Vandermonde matrix has the special property that as long as the second column has no repeated elements, the matrix is invertible (and in fact, there is a special algorithm to invert it quickly). The split pieces correspond to rows of the matrix on the right. Choose any three of them; let’s say row 1, 2 and 4. Once we know what row numbers they are (and this explains the tiny header), we get the following system of equations: We know the leftmost matrix is invertible, so multiply both sides by the inverse, and we solve for X, recovering “Lovefromdawn”. Wowza! But wait! One problem remains: if we use standard integer arithmetic, the matrix on the right ends up with a lot of values larger than 255, and we can’t store it in a byte array. That ain’t no good. Luckily, it turns out that most theorems dealing with matrices and in…

Good-bye App Engine
type: item
creator: Richard
date: 2013-02-16T23:51:18Z
subject: Comedy
subject: Computers
description: I’d been running my web site for comedians LaffQ.com in Google App Engine for nearly two years. Google App Engine seemed pretty neat when it first came out: it was the only free hosting service I knew of where you could deploy dynamic Python apps (using Django no less, a framework I was already familiar … Continue reading Good-bye App Engine →
encoded: I’d been running my web site for comedians LaffQ.com in Google App Engine for nearly two years. Google App Engine seemed pretty neat when it first came out: it was the only free hosting service I knew of where you could deploy dynamic Python apps (using Django no less, a framework I was already familiar with) with the promise of Google managing the backups, scaling, and provisioning. But as time went on, the sunny optimism began to fade. Although Google supported Django, it uses a proprietary BigTable-backed database which was not compatible with Django’s object-relational wrapper (ORM). The originally unbelievably high free limits during the beta period which reduced drastically, in some cases absurdly, when the product came out of beta. Visiting my internal operations page just twice could blow out nearly the entire day’s quota because it produced counts of many tables — so each item counted towards a daily quota of 50000 “small operations”. Developing for Google App Engine was always a pain. It was non-standard enough that a lot of libraries and tools wouldn’t work or need annoying changes. There was a single point of documentation, written in a sort of corporate Google-ese — not horrible, but not the nicest documentation I ever read. There were a lot of layers of abstraction. It was proprietary. It was slow to fetch data. The pdb debugger didn’t work very well. Getting data out of production was an ordeal. It was even hard to launch a instance on the command line, which meant on those rare occasions when I decided to do development on my Linux netbook, I spent most of my time getting the newest version of Google App Engine to work again. I don’t exactly remember how or why, but late one Sunday evening in November I suddenly came up with the bright idea to port the Google App Engine infrastructure to “sqlite” (as I referred to it in my head), ie. to use the standard Django database back-end with the idea to deploy it to some unknown host using sqlite3. I started …

Farley’s Open Mic Performance
type: item
creator: Richard
date: 2009-08-03T18:24:50Z
subject: Comedy
description: I stopped by Farley’s one Saturday about a week ago and did a set at the open mic there. The audience seemed to be completely indifferent to the fact that comedy was going on (and not just me), but I thought it turned out well anyway. Thanks to Sean Stryker for filming this.
encoded: I stopped by Farley’s one Saturday about a week ago and did a set at the open mic there. The audience seemed to be completely indifferent to the fact that comedy was going on (and not just me), but I thought it turned out well anyway. Thanks to Sean Stryker for filming this.

Some Whining About Video Software
type: item
creator: Richard
date: 2009-07-27T16:33:36Z
subject: Computers
description: I’ve been working on editing video again lately. I’m struck by the same feelings I had last time I tried to do this way-too-complex and thankless task. I appeared on the local cable access show “Paint with Lynn”, with my friend, comedian Lynn Ruth Miller. They gave me a copy of the shows on DVD. … Continue reading Some Whining About Video Software →
encoded: I’ve been working on editing video again lately. I’m struck by the same feelings I had last time I tried to do this way-too-complex and thankless task. I appeared on the local cable access show “Paint with Lynn”, with my friend, comedian Lynn Ruth Miller. They gave me a copy of the shows on DVD. I want to edit each 30 minute episode down to something less than ten minutes so I could upload it to YouTube and so viewers wouldn’t have the urge to kill themselves out of boredom. First, I thought I would use Final Cut Express. Of course, they don’t let you import the .VOB file format that DVDs use (which is just a renamed mpeg-2 file) unless you spend $20 for the Apple MPEG-2 Playback Component. Why Quicktime won’t play back one of the most important file formats out of the box is beyond me. Okay, it’s not really beyond me: it probably has to do with the cost of patents. It’s still frustrating though. So I used Handbrake to convert to MPEG-4. This take an hour or so. Well, guess what… Final Cut Express would NOT import the MPEG-4 movies produced by Handbrake. Whaaat??? So after some tests, I used Handbrake to convert to AVI. Another hour. Why Apple’s Final Cut Express supports Microsoft’s container and not Apple’s is beyond the hell out of me. After spending hours figuring out and getting used to Final Cut, I discovered that Handbrake transcoded the audio, and I suppose due to some weird bug, shifted the levels, causing a bunch of pops in the audio. I noticed this only AFTER I had spent hours assembling all the clips. So I transcoded AGAIN, this time requesting Handbrake to not transcode the audio, but just it pass through. That’s generally better anyway: it takes less time, and it doesn’t involve conversion, which generally causes a loss in quality. Lesson #1: Avoid transcoding whenever possible. Finally, I had something that Final Cut could read (an AVI file) and did not have audio popping. I had created the clips by settings marks on the large clip. Luckily, I was abl…

People Get Better at Stuff
type: item
creator: Richard
date: 2009-06-24T06:52:03Z
subject: Comedy
subject: Life
description: I’ve been doing stand-up comedy for four and a half years now, and done over 400 shows. Recently, I taped a longer set I’ve done and posted it on my web site. I’m happy to see that I’m improving (I’m assuming. I haven’t actually watched it yet). I did 18 minutes, and while not 100% … Continue reading People Get Better at Stuff →
encoded: I’ve been doing stand-up comedy for four and a half years now, and done over 400 shows. Recently, I taped a longer set I’ve done and posted it on my web site. I’m happy to see that I’m improving (I’m assuming. I haven’t actually watched it yet). I did 18 minutes, and while not 100% solid and consistent, it’s definitely tolerable, if not funny. I’m hopefully overcoming my biggest weakness of being too boring and monotone with some fake excitement, inflection and movement. Audiences should realize, however that comedians get better. When you go see a comic live, you aren’t seeing a movie. You’re seeing a slice of a comic’s life. Their performance, although possibly rehearsed, is just another rehearsal, another practice for the shows that comes after. It’s not a final product. It’s another attempt, another try at improving, being funnier, becoming more compelling, getting more interesting. You’re just a guinea pig in this somewhat scientific experiment, and your reaction – laughter, groans, silence, obedience – is the feedback. Just because a comic is not funny or has a bad show does not mean you will never like that comic. It’s pretty amazing how much I’ve learned and changed in just the last two years. Talent plays a role, but comedy, like pretty much anything else, is something you get better at with practice. When you go see a comedian, you’re watching him or her practice. Just by being there, you’re helping comedians get better. Thanks, audience member. Here’s your gold star.