Skip to content

Instantly share code, notes, and snippets.

View dhruv's full-sized avatar

dhruv

View GitHub Profile
@ryanxcharles
ryanxcharles / stealth.md
Last active June 14, 2023 13:35
Stealth Addresses, Transactions and Messages

Stealth Addresses, Transactions and Messages

Normal bitcoin addresses cannot be published in public without losing all privacy, since all transactions to that address can be seen by anybody. Stealth addresses let us publish an address in public which can be used by payers to derive a new address that the payee has access to, but no one else knows is associated with the stealth address. The trick is that the payer must use a nonce to derive the address paid to, and this nonce must be delivered to the payee so they know how to recover the funds. This nonce can be delivered in the transaction, so that no separate channel is required to communicate the nonce.

The same technology can also be used to construct new public keys to send encrypted messages to.

We will discuss four methods:

  1. The simplest form of stealth addresses, which has some drawbacks that can improved upon.
@Nurdok
Nurdok / python_conversion.md
Last active December 16, 2022 03:45
Python Conversion

Python Number Conversion Chart

From To Expression


  BIP: 324
  Layer: Peer Services
  Title: Version 2 Peer-to-Peer Message Transport Protocol
  Author&#58; Jonas Schnelli <dev@jonasschnelli.ch>
          Dhruv Mehta <dhruvkaran@pm.me>
  Status&#58; Draft
  Type&#58; Standards Track
  Created&#58; 2019&#45;03&#45;08
  License&#58; PD

@shrikeh
shrikeh / csrf-lua.conf
Created February 6, 2013 13:15
A simple nginx host file that, using the lua module, handles CSRF, rather than the backend having to (and thus generally breaking caching by having to use Set-Cookie). Here, the front end takes care of CSRF, and sends an X-CSRF-Valid header to the backend regarding the validity of the POST, so that it is advisory (the backend then choose whether…
server {
listen 80;
root /root/to/your/docroot;
proxy_redirect off;
proxy_intercept_errors on;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@fernandonm
fernandonm / softpeg.md
Last active November 25, 2021 17:35
Soft pegged sidechains

Soft pegged sidechains

Sidechains have been the Holy Grail to scale and try new features on Bitcoin for a long time. But the trade-offs of the different proposals relying on Bitcoin modifications (SPV two-way peg, drivechains, etc) prevented them from being adopted.

Only proposals not requiring of any change to Bitcoin, like federated sidechains (e.g. Liquid Network), have seen some adpotion. Although they imply significant trust requirements.

I have always found in sidechains the most honest way to explore other applications of Bitcoin technology. E.g. Namecoin, a network with greater privacy, a distributed oracle, or a network with different trade-offs for high velocity money (low fees), etc. So I have tried (in multiple ocasions) to figure out a trust minimized solution for the two way peg problem that did not require changes to Bitcoin.

[Statechains](https://medium.com/@RubenSomsen/statechain

@leolord
leolord / vim.sh
Last active August 4, 2021 19:45
Compiling vim on Ubuntu 18 with LUA-support
# Remove previous installations
sudo apt-get remove vim vim-runtime vim-tiny vim-common
# Install dependencies
sudo apt-get install libncurses5-dev python-dev liblua5.3-dev lua5.3 python3-dev
# Fix liblua paths
# You have to compile luajit for yourself.
sudo ln -s /usr/include/lua5.3 /usr/include/lua
sudo ln -s /usr/lib/x86_64-linux-gnu/liblua5.3.so /usr/local/lib/liblua.so
@kristovatlas
kristovatlas / README.md
Created April 16, 2018 01:22
How to verify Trezor Bridge on MacOS (and maybe other operating systems)

Background reading

Verification Steps

  1. Visit https://wallet.trezor.io/data/bridge/latest/index.html. For MacOS, you download a .pkg file.
  2. From https://wallet.trezor.io/data/bridge/latest/index.html also download the PGP signature file.
  3. The Satoshi Labs CTO signs the Bridge releases. Download his PGP key from his Keybase signature: https://keybase.io/stick This means at least that someone created an account with his identity and bothered to link a specific PGP key. If you retain this key over time, you can be sure that it wasn't recently swapped out. You can find same PGP under his identity in various places on the web: https://duckduckgo.com/?q=Pavol+Rusn%C3%A1k+pgp+key&ia=web
@glamp
glamp / svmflag.py
Last active March 5, 2021 06:59
Plotting SVM predictions using matplotlib and sklearn
import numpy as np
import pylab as pl
import pandas as pd
from sklearn import svm
from sklearn import linear_model
from sklearn import tree
from sklearn.metrics import confusion_matrix
@glamp
glamp / cows_and_wolves.txt
Last active July 3, 2017 14:23
plotting wolf/cow fence boundaries
o o o
o x
o x x x
x o
x x x o
x
o o
o
@mrowl
mrowl / enum_int_type.py
Created January 19, 2011 17:31
This defines a new enum type using the sqlalchemy type decorator. Data is stored with the sqlalchemy SmallInteger type while strings are used with the model. Preferable to the varchar (too large) or native enum (pain on postgres).
import sqlalchemy as sa
class EnumIntType(sa.types.TypeDecorator):
impl = sa.types.SmallInteger
values = None
def __init__(self, values=None):
sa.types.TypeDecorator.__init__(self)
self.values = values