Skip to content

Instantly share code, notes, and snippets.

@tynes
Last active May 25, 2021 07:33
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tynes/a0c8cb7f0ce63f8508bb185c5109155d to your computer and use it in GitHub Desktop.
Save tynes/a0c8cb7f0ce63f8508bb185c5109155d to your computer and use it in GitHub Desktop.

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.

Terminal 1

Create a Handshake address that you will receive the airdrop to by downloading hsd, the JavaScript implementation of the Handshake protocol. It includes a wallet, full node and SPV node (for Light Name Resolution). If you would like to generate the address on a Ledger Nano S instead, see ledger-app-hns. It hasn't been accepted into the Ledger store yet, but you can install it via CLI if you want.

$ git clone https://github.com/handshake-org/hsd
$ cd hsd
$ npm i

# Start the full node. Can pass additional arguments
# such as `--listen true` to allow inbound connections.
# see hsd-dev.org for all configuration options
$ ./bin/hsd --log-level info

Terminal 2

Install the client library to access the HTTP api of the full node. Be sure to back up your mnemonic! The wallet abstraction corresponds to a mnemonic account abstraction corresponds to a bip44 account. As long as you keep your ~/.hsd/wallet directory, you will be able to spend your funds.

$ git clone https://github.com/handshake-org/hs-client
$ cd hs-client
$ npm i

# HSD_ prefix can be used in config, can also use `--network main`
# with the hsw-cli command
$ export HSD_NETWORK=main

$ ./bin/hsw-cli account get default
# there should be a receiveAddress property on the response
# pipe response to jq -r .receiveAddress | xclip for simplicity

It is a good idea to back up the mnemonic. This will allow for recovery of funds. A new wallet can be created using the mnemonic and the wallet will discover the funds. Otherwise the mnemonic will be stored in a LevelDB index in ~/.hsd/wallet.

To print the mnemonic as a string:

# BE VERY CERTAIN YOU ARE IN A TRUSTED ENVIRONMENT
$ hsw-cli master

Terminal 3

Create the airdrop claim which must include a signature from a key attached to your Github account. If you have multiple keys on Github, only one can be used. Pass in the address that you created earlier. The commands differ slightly depending on the type of key, see the hs-airdrop repository for more info.

If your key is encrypted, you will need to decrypt it with a passphrase. The hs-airdrop tool needs to download some data from Github and brute force search for your airdrop.

If you want to practice good security, please roll over the key being used. You can inspect the hs-airdrop source code, manually download the data from Github and sign on an airgapped machine if you want to.

$ git clone https://github.com/handshake-org/hs-airdrop

$ cd hs-airdrop
$ npm i

$ ./bin/hs-airdrop --help

To generate the proof, use the command:

$ ./bin/hs-airdrop [path to key] [address]

An example would look like:

# DO NOT RUN THIS UNLESS YOU WANT TO SEND YOUR CLAIM TO THIS ADDRESS
$ ./bin/hs-airdrop ~/.ssh/id_rsa [YOUR PERSONAL RECEIVE ADDRESS]

The set of airdrop recipients was selected ~2 years ago. The keys have been scraped multiple times since so keys added up to about 6 months ago should be included in the airdrop.

If you receive a NonceError, this means that the key in not included in the airdrop. Try using another key to see if a different one will work.

When a key is successfully found to be part of the airdrop, it will print out the airdrop in JSON. It will also base64 encode the raw airdrop.

Back to Terminal 2

Now you must submit the airdrop to the network.

$ ./bin/hsd-cli rpc sendrawairdrop [base64 encoded airdrop]

It will return the proof hash.

The target blocktime is 10 minutes, you should be able to look up your address on HNScan once the airdrop is included in a block. It creates a new pay to witness pubkey hash UTXO that you can spend. The maturity is 100 blocks so you will not be able to spend for ~2/3rds of a day.

@orimolade
Copy link

Nice project

@omalicha
Copy link

omalicha commented Feb 1, 2021

What a great way to say "happy new month"

@doki247
Copy link

doki247 commented Feb 2, 2021

Wow great project

@Babpet
Copy link

Babpet commented Feb 2, 2021

This is cool!

@Lexistouchm12
Copy link

This is amazing

@Ellity
Copy link

Ellity commented Feb 2, 2021

Great project

@mmababy95
Copy link

Nice project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment