September 12, 2016

The California Zephyr

Filed under: photo — Benjamin Vulpes @ 6:30 p.m.

I found this beauty parked on the rails while taking the garbage out today (my office is in a train station as gorgeously art deco as this train):


The "Silver Solarium", the observation car:

Silver Solarium

Custom stepstool:

Silver Solarium step

Gratuitous typography shot:

dat art deco typeface

September 11, 2016

Extracting and Hashing Bitcoin Block Headers

Filed under: bitcoin, common lisp — Benjamin Vulpes @ 12:28 a.m.

Presented herein: some code for deserializing, reserializing and hashing Bitcoin block headers. This work leans heavily on Frode Vatvedt Fjeld's binary-types and Nathan Froyd's ironclad Common Lisp libraries, and would have taken oodles of time longer without John Ratcliff's How to Parse the Bitcoin BlockChain (sic).

Over a year ago, Stan suggested that I use binary-types to do something similar to his blkcut utility. Some time after that, he patched TRB, providing a handle to dump an arbitrary block on demand. The project to which the below code belongs, and which leans on the block dumper dumpblock patch is still downright larval, but the block header parsing is baked enough to share.

First, the header definition:

(binary-types:define-binary-class bitcoin-block-header ()
  ((version :binary-type binary-types:u32 :accessor version)
   (previous-block-hash :binary-type binary-types:u256 :accessor previous-block-hash)
   (merkle-root :binary-type binary-types:u256 :accessor merkle-root)
   (time-stamp :binary-type binary-types:u32 :accessor time-stamp)
   (target :binary-type binary-types:u32 :accessor target)
   (nonce :binary-type binary-types:u32 :accessor nonce)))

The double hash:

(defmethod double-sha256 ((header bitcoin-block-header))
      (header-bytes (make-array 80 :fill-pointer 0 :element-type '(unsigned-byte 8)))
    (let ((binary-types:*endian* :little-endian))
      (binary-types:write-binary 'bitcoin-block-header header-bytes header)
        (ironclad:digest-sequence :sha256 header-bytes))))))

I am utterly pleased with binary-types. Writing the binary-class definition for the header is adequate to prime the pump for both ingest and egress using read-binary and write-binary.

And a demonstration (ripped verbatim from the test suite):

(stefil:deftest can-hash-headers ()
      (stream (merge-pathnames #p "blocks/0.bin" (uiop:getcwd)) :direction :input)
    (let* ((binary-types:*endian* :little-endian)
           (header (binary-types:read-binary 'bitcoin-block-header stream))
           (expected "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f")
           (actual (ironclad:byte-array-to-hex-string (double-sha256 header))))
      (stefil:is (string= expected actual)))))

Called at the REPL:


September 9, 2016

Fallon Smart's Murderer Out On Bail

Filed under: portland, sovereignty games — Benjamin Vulpes @ 9:48 p.m.

The Oregonian, as always, gets it wrong:

Noorah, 21, remains in the Multnomah County Detention Center on $1 million bail.

One can trivially determine this to be false:


Hey, what was that?


But (from the same rag)...

A deputy who compiled records filed Aug. 31 in Multnomah County Circuit Court wrote that she spoke about Noorah with an official from the Saudi Arabian consulate in Los Angeles. The deputy wrote that it was her understanding the consulate has retained legal counsel for Noorah and plans to post his bail.

The US educational system (which never achieved anywhere near the Stradivarius quality of the European universities) thirsts for turkey-buyin' dollars, to the extent that it reaches far and wide, collecting the children of those who yet believe that the US education is worth their money, or need to park a particularly useless specimen (I did my ME studies next to the guys who make lots of noise with their Maseratis and mirror-wrapped Nissan Z's (?!) ripping up and down 4th and Broadway in the University district, and Community College and a Lexus are /not/ the jewels a Roman family would hang around their kids necks to indicate the danger of touching the kid in question) elsewhere for a few years. The practice is far older than your typical internet commenter realizes—I, for instance, went to a local high school that operates a boarding program with a population of somewhere in the neighborhood of %85 Korean/Chinese/Japanese (the odd white kid could be found in the dorms, but not many).

The spectacle will now revolve around sovereignty games: will the Saudi "government" (to the extent that it has something shaped like what the typical American thinks of as a "government", which is to say "the great not-a-lord to which we have all delegated our decisionmaking aka Democracy") step in and extract their wayward child from a lynching in Portland, or will the glorious United States Government step up to bat for its barely-attached Cascadian subjects and demand restitution? Or, will the two Great Incas join hands and come up with some brilliant plan to assuage both the injured sovereignty and keep the kid from getting poked full of holes in jail?

However this plays out, it's popcorn time!

« Newer Posts