Skip to content

Instantly share code, notes, and snippets.

@HeXenCore
HeXenCore / _Very_big_int_in_cython.txt
Created June 6, 2021 12:55 — forked from ricrogz/_Very_big_int_in_cython.txt
Use int128 (really LONG integers) in cython
Taken from https://stackoverflow.com/questions/27582001/how-to-use-128-bit-integers-in-cython
Basically, we make cython believe we will use 64 bit int to generate the .c file,
but by using a C header we will, in fact, define a 128 bit int (the definition
in the .h file does not match what we put into the pyx file).
Once Cython has generated the .c file, we can compile it with GCC without further trouble,
as GCC does support 128 bit ints
@HeXenCore
HeXenCore / addrgen
Created May 27, 2021 17:14 — forked from JBaczuk/addrgen
addrgen
#!/bin/bash
echo
echo "Welcome to the Bitcoin address generator!"
echo "input private key (32 bytes, hex format)"
read priv
echo ""
echo "#####################################"
# priv=0C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D # Testing only
@HeXenCore
HeXenCore / gen.py
Created May 27, 2021 16:16 — forked from matthewdowney/gen.py
P2WPKH-P2SH (SegWit) Wallet Address Generation
"""
Implementation of "Pay to Witness Public Key Hash nested in BIP16 Pay to Script Hash" (P2WPKH-P2SH) address generation.
Described in BIP 141 (SegWit) https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#P2WPKH_nested_in_BIP16_P2SH
I.e.: Public key -> SegWit address
"""
import hashlib
from hashlib import sha256
@HeXenCore
HeXenCore / bitcoin-wif-litecoin-wif.py
Created May 26, 2021 11:26 — forked from losh11/bitcoin-wif-litecoin-wif.py
Convert Bitcoin WIF to Litecoin WIF format
'''
Bitcoin WIF to Litecoin WIF converter
=== INFO ===
Idk
=== USAGE (example) ===
% python3 litecoinwif.py
@HeXenCore
HeXenCore / address.py
Created May 26, 2021 11:24 — forked from chenxu2048/address.py
bitcoin and ethereum address
import hashlib
from ecdsa import SECP256k1, SigningKey
from sha3 import keccak_256
import sys
import binascii
BASE58TABLE = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
def from_bytes (data, big_endian = False):
if isinstance(data, str):
#https://en.bitcoin.it/wiki/Wallet_import_format
import os, binascii, hashlib, base58, ecdsa
#Input params
#random_number - 32 byte random number string ex:b'-\xf2L~\xe1Gq\xeeN\x8e\x97La$\xc7\xbb\x05\xaf\x05\xf9^\x00\xd5\x19o`@Q\x02\xc18\xa1'
#If no random number input, one is automatically generated
#Output params - Private Wallet Key, Public Address
def create_wallet(random_number=""):
def ripemd160(x):
@HeXenCore
HeXenCore / bitcoin.py
Created May 26, 2021 09:15 — forked from HelloZeroNet/bitcoin.py
Bitcoin signature signing and verficiation using coincurve
import hashlib
import struct
from coincurve import PrivateKey, PublicKey
from base58 import b58encode_check, b58decode_check
from hmac import compare_digest
RECID_MIN = 0
RECID_MAX = 3
RECID_UNCOMPR = 27
LEN_COMPACT_SIG = 65
@HeXenCore
HeXenCore / ecdsa_to_bitocin_addy.py
Created May 26, 2021 09:09 — forked from nealmcb/ecdsa_to_bitocin_addy.py
Calculate Bitcoin address corresponding to given ECDSA private key. Handy for verifying document timestamps provided by OriginStamp.org.
#!/usr/bin/env python
"""Calculate Bitcoin address corresponding to given ECDSA private key.
Handy for verifying document timestamps provided by OriginStamp.org.
Usage: ecdsa_to_bitocin_addy.py ecdsa_private_key # that's a 64-character hex string
Prerequisite:
pip install ecdsa
@HeXenCore
HeXenCore / easy-litecoin-address-from-public-key.py
Created May 26, 2021 08:47 — forked from circulosmeos/easy-litecoin-address-from-public-key.py
Easily generate the litecoin address from the public key using Python (compatible with Python 2 and 3)
#!/usr/bin/env python
# patched from https://bitcoin.stackexchange.com/questions/56923/is-this-how-to-generate-a-bitcoin-address-with-python
# https://en.bitcoin.it/wiki/Protocol_documentation#Addresses
# Adapted to litecoin, following https://bitcoin.stackexchange.com/questions/65282/how-is-a-litecoin-address-generated
import hashlib
import base58
# ECDSA bitcoin Public Key
pubkey = '0450863ad64a87ae8a2fe83c1af1a8403cb53f53e486d8511dad8a04887e5b23522cd470243453a299fa9e77237716103abc11a1df38855ed6f2ee187e9c582ba6'
# https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses
# http://gobittest.appspot.com
# -*- coding: utf-8 -*-
import hashlib
import base58
prefix = "04"
version_main = "00"