Skip to content

Instantly share code, notes, and snippets.

Handshake Airdrop

The airdrop is based on the paper An airdrop that preserves recipient privacy.

To claim the airdrop, you needed to have at least 15 followers on Github as of ~2 years ago and an ssh or gpg key linked to your Github account. You will need to download hsd to create an address and have access to the key linked to your Github account.

It is an easy process with 3 terminals. If you prefer to use a GUI, see Bob.

Writing an EVM-debugger for Geth

This document provides some ideas on how someone fairly easily could build the basic blocks for a debugger using geth.

Integration

The tracer interface defines four methods that a 'tracer' needs to implement:

General

  • Each key is 256 bit long, or 32 hexadecimal characters, each key needs to be less than "curve order" (function is called sc_reduce)
  • Address = Public Spend Key + Public View Key (with some check encoding)
  • All hashing is done with Keccak-256

Deterministic Key Derivation:

With 25 word Mnemonic:

@chriseth
chriseth / snarktest.solidity
Last active December 3, 2023 07:03
zkSNARKs test code
// This file is MIT Licensed.
//
// Copyright 2017 Christian Reitwiessner
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF O
@Earlz
Earlz / greeter.c
Last active June 12, 2018 16:12
Using a Qtum prototype implementation including an x86 VM, I built this contract. It's messy cause there is not yet a standard library due to it requiring freestanding code. Compare to the Solidity implementation at https://www.ethereum.org/greeter
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
typedef unsigned char uint8_t;
typedef unsigned int size_t;
//#include <stdint.h>
// copy-paste some library functions until we get a basic libc working
void* memcpy(void* restrict dstptr, const void* restrict srcptr, size_t size) {
@warengonzaga
warengonzaga / warens_led_music_visualizer.ino
Last active April 2, 2019 20:19
Waren's L.E.D Music Visualizer (The Project W.L.E.D.M.V)
/**
* Waren's LED Music Visualizer (Project W.L.E.D.M.V)
* by Waren Gonzaga
* Version: 1.0.1
*
* An Arduino project that translates the sound into lights.
* Check this project on Instructables.com
* Link: https://www.instructables.com/id/Warens-LED-Music-Visualizer
*
* Contribute to improve this project on gist!
@mihow
mihow / load_dotenv.sh
Last active June 14, 2024 02:15
Load environment variables from dotenv / .env file in Bash
if [ ! -f .env ]
then
export $(cat .env | xargs)
fi
@arsham
arsham / go_cpu_memory_profiling_benchmarks.sh
Last active June 26, 2024 13:32
Go cpu and memory profiling benchmarks. #golang #benchmark
go test -run=. -bench=. -benchtime=5s -count 5 -benchmem -cpuprofile=cpu.out -memprofile=mem.out -trace=trace.out ./package | tee bench.txt
go tool pprof -http :8080 cpu.out
go tool pprof -http :8081 mem.out
go tool trace trace.out
go tool pprof $FILENAME.test cpu.out
# (pprof) list <func name>
# go get -u golang.org/x/perf/cmd/benchstat
benchstat bench.txt
@axic
axic / ecverify.sol
Last active May 13, 2024 12:07
Ethereum ECVerify
//
// The new assembly support in Solidity makes writing helpers easy.
// Many have complained how complex it is to use `ecrecover`, especially in conjunction
// with the `eth_sign` RPC call. Here is a helper, which makes that a matter of a single call.
//
// Sample input parameters:
// (with v=0)
// "0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad",
// "0xaca7da997ad177f040240cdccf6905b71ab16b74434388c3a72f34fd25d6439346b2bac274ff29b48b3ea6e2d04c1336eaceafda3c53ab483fc3ff12fac3ebf200",
// "0x0e5cb767cce09a7f3ca594df118aa519be5e2b5a"

Problems & Solutions for Interaction Between C and Go

At Vimeo, on the transcoding team, we work a lot with Go, and a lot with C, for various tasks such as media ingest. This means we use CGO quite extensively, and consequently, have run into bits that are perhaps not very well documented, if at all. Below is my effort to document some of the problems we've run into, and how we fixed or worked around them.

Many of these are obviously wrong in retrospect, but hindsight is 20/20, and these problems do exist in many codebases currently.

Some are definitely ugly, and I much welcome better solutions! Tweet me at @daemon404 if you have any, or have your own CGO story/tips, please! I'd love to learn of them.

Table of Contents