Skip to content

Instantly share code, notes, and snippets.

@axic
axic / linux-timestamp.rb
Created October 6, 2010 20:45
Turn the Linux kernel timestamp (from dmesg) into a date
input = ARGV.to_s.match(/^\[?([\d.]+)\]?/)
input = input[1] if input
uptime = File.new("/proc/uptime").gets
uptime = uptime.match(/^([\d.]+)/).to_a.first if uptime
if input and uptime then
puts(Time.now - uptime.to_f + input.to_f)
else
puts "unable to parse"
@axic
axic / gist:6675759231013e484c01
Created November 28, 2015 16:17
Onion Omega motd + dmesg (Kickstarter version)
BusyBox v1.23.2 (2015-09-13 17:56:41 UTC) built-in shell (ash)
____ _ ____
/ __ \___ (_)__ ___ / __ \__ _ ___ ___ ____ _
/ /_/ / _ \/ / _ \/ _ \ / /_/ / ' \/ -_) _ `/ _ `/
\____/_//_/_/\___/_//_/ \____/_/_/_/\__/\_, /\_,_/
W H A T W I L L Y O U I N V E N T ? /___/
-----------------------------------------------------
CHAOS CALMER (Chaos Calmer, r46849)
-----------------------------------------------------
@axic
axic / README.md
Last active April 27, 2016 11:46
Ethereum HD KDF

There's a long discussion about using BIP32 (the Bitcoin HD wallet KDF) and BIP44 (the KDF path standard) for Ethereum.

It was raised that perhaps a different scheme could be useful.

How Bitcoin HD wallets work?

  1. A mnemonic (i.e. a list of memorable words) is generated (see BIP39)

  2. This mnemonic is converted to a seed using PBKDF2 (see BIP39)

@axic
axic / ETON.md
Created April 27, 2016 22:31
A very old proposal from November 2015

Ethereum Object Notation (ETON)

A simple ABI structure to replace JSON's object when passed between contracts. It is especially useful when interacting with outside oracles, where a JSON would be converted into this notation.

A JSON supports the following object types:

  • number (double precision floating point)
  • string (double quoted unicode string)
  • boolean (true or false)
  • array (ordered sequence)
  • null
@axic
axic / README.md
Last active May 25, 2016 21:41
How to get started with Trezor-Ethereum (for developers only!)

Ethereum support in Trezor is in early development. The following steps can help you to get started.

First of all have a read at the protocol discussion thread.

To summarize the key decisions:

  • Transaction data is taken as raw binary, all fields of the transaction separately (in order they appear).
  • Every field is optional and it defaults to 0 if something is not supplied.
  • Trezor will internally recreate the RLP of those fields, hash it and create a signature.
  • The above is in a streaming manner and thus no RLP data is kept nor returned to the client.
  • Only the signature fields (v, r, s) are returned. The callee then needs to recreate the RLP structure and include the signature fields.
@axic
axic / EWASMTest.wast
Last active August 2, 2016 08:23
Solidity eWASM compiled code
;; Contract: EWASMTest
(module
(import $calldatacopy "ethereum" "calldatacopy" (param i32 i32 i32))
(import $sstore "ethereum" "sstore" (param i32 i32))
(import $return "ethereum" "return" (param i32))
(memory 1 1)
(export "memory" memory)
(export "main" $main)
(func $main
(call_import $calldatacopy (i32.const 0) (i32.const 0) (i32.const 4))
@axic
axic / eth_interface.md
Created August 4, 2016 18:05
EEI v0.1

Block

  • blockHash -> getBlockHash
  • coinbase -> getCoinbase
  • difficulty -> getDifficulty
  • gasLimit -> getBlockGasLimit
  • number -> getBlockNumber
  • timestamp -> getBlockTimestamp

Tx

  • gasPrice -> getTxGasPrice
@axic
axic / keybase.md
Created August 8, 2016 00:15
Trying out keybase.io...

Keybase proof

I hereby claim:

  • I am axic on github.
  • I am axic (https://keybase.io/axic) on keybase.
  • I have a public key ASCAJvumCmc0vRQ86molQyK9QLq7BifAMHzWUqwcGplOZQo

To claim this, I am signing this object:

// (words * 3 + words ^ 2 / 512) - (allocated_words * 3 + allocated_words ^ 2 / 512)
var memsize = 1
var current = 0
while (true) {
var a = (memsize * 3) + (memsize ^ 2 / 512)
var b = ((memsize - 1) * 3) + ((memsize - 1) ^ 2 / 512)
current += (a - b)
@axic
axic / deployer.wast
Last active August 25, 2016 02:53
Standard eWASM deployer code.
;;
;; Standard eWASM deployer code.
;;
;; We keep the to-be-deployed contract as a memory segment and simply return it.
;;
(module
(memory 1
(segment 0 "\10\00\00\00") ;; Here comes the size of the code in LSB
(segment 4 "Hello World CODE") ;; Here comes the code as a escaped hex string