Skip to content

Instantly share code, notes, and snippets.

@ryanxcharles
ryanxcharles / stealth.md
Last active October 29, 2024 08:38
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.
@takeshixx
takeshixx / hb-test.py
Last active April 14, 2025 17:04
OpenSSL heartbeat PoC with STARTTLS support.
#!/usr/bin/env python2
"""
Author: takeshix <[email protected]>
PoC code for CVE-2014-0160. Original PoC by Jared Stafford ([email protected]).
Supportes all versions of TLS and has STARTTLS support for SMTP,POP3,IMAP,FTP and XMPP.
"""
import sys,struct,socket
from argparse import ArgumentParser
@gavinandresen
gavinandresen / OptimizingBlockBroadcast.md
Last active May 4, 2022 07:50
Optimizing block broadcasts

Optimizing New Block Messages

Motivation

The network message used to announce the discovery of a new block is inefficient, and that inefficiency translates indirectly into higher transaction fees for users. The dominating cost for a miner to include an extra transaction in their block is the incremental "orphan cost", which is dependent on how quickly the block is propagated across the peer-to-peer network.

@matheusoliveira
matheusoliveira / json_manipulator.sql
Last active January 13, 2025 00:56
Simple PostgreSQL functions to manipulate json objects. (Note: performance is not a concern for those functions)
CREATE OR REPLACE FUNCTION public.json_append(data json, insert_data json)
RETURNS json
IMMUTABLE
LANGUAGE sql
AS $$
SELECT ('{'||string_agg(to_json(key)||':'||value, ',')||'}')::json
FROM (
SELECT * FROM json_each(data)
UNION ALL
SELECT * FROM json_each(insert_data)
package main
import (
"log"
"github.com/piotrnar/gocoin/blockdb"
"github.com/piotrnar/gocoin/btc"
"encoding/hex"
)
func main() {
// Set real Bitcoin network
@gavinandresen
gavinandresen / fee_migration.md
Last active December 29, 2015 12:29
Network/miner fee policy migration plan

Network/miner fee policy migration plan

Introduction

Changing the fees required for transactions to be relayed across the network and/or accepted by miners into their blocks requires care; policy mis-matches can result in users' transactions never confirming, either because they never reach a miner (they are not relayed) or because they are rejected by miners.

I have been working on simplifying the transaction fee rules for the 0.9 release; this document is intended to capture all of the details needed to make that transition as smoothly as possible.

The general idea is to make sure the transaction-generating code (the wallet code) is conservative, and generates transactions compatible with the previous version's rules. The relay and mining code is changed more aggressively, to anticipate future releases.

@msm595
msm595 / bitwalletrecover.py
Last active April 22, 2025 10:19
bitwalletrecover.py - recover compressed private keys from your bitcoin wallet. Requires python3, pycoin (https://pypi.python.org/pypi/pycoin), and base58 (https://pypi.python.org/pypi/base58).
import re
import hashlib
import base58
from pycoin.ecdsa import generator_secp256k1, public_pair_for_secret_exponent
def bytetohex(byteStr):
return ''.join( [ "%02X" % x for x in byteStr ] ).strip()
litecoin = [b"\x30", b"\xb0"]
bitcoin = [b"\x00", b"\x80"]
import simplejson as json
import lxml
class objectJSONEncoder(json.JSONEncoder):
"""A specialized JSON encoder that can handle simple lxml objectify types
>>> from lxml import objectify
>>> obj = objectify.fromstring("<Book><price>1.50</price><author>W. Shakespeare</author></Book>")
>>> objectJSONEncoder().encode(obj)
'{"price": 1.5, "author": "W. Shakespeare"}'
"""
# coding=UTF-8
from __future__ import division
import re
# This is a naive text summarization algorithm
# Created by Shlomi Babluki
# April, 2013
class SummaryTool(object):
@ipconfiger
ipconfiger / Test.html
Created March 12, 2013 17:34
山寨版SSL,HTML端Javascript用公钥加密密码,在Python端用私钥解密活得明文密码。这样在POST传输 的过程中就是加密了的密码了,公钥可以直接输出到HTML。 javascript使用了https://github.com/ziyan/javascript-rsa 这个库 第一步通过 命令 生成私钥: openssl genrsa -out privatekey.key 1024 通过私钥生成公钥: openssl rsa -in privatekey.key -pubout -out pubkey.key
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="/jquery.js"></script>
<script src="/jsbn.js"></script>
<script src="/rsa.js"></script>
<script src="/sha1.js"></script>
<script type="text/javascript">
function encrypt() {