Skip to content

Instantly share code, notes, and snippets.

@rllola
rllola / bitcoinaddress.md
Last active November 5, 2024 11:49
Tutorials

How to get a bitcoin address from a public key

With Bitcoin one public key can give two different addresses. It will depend if the public key has been hashed first or not.

const bs58check = require('bs58check')
const RIPEMD160 = require('ripemd160')
const crypto = require('crypto')
from ecdsa import VerifyingKey
import ecdsa
# tx : https://sepolia.etherscan.io/getRawTx?tx=0x39adc69ce44b1cd82df7d024d59793cf774c2902c8894b01979d0976b420aa38
digest = bytearray.fromhex("365e8c124f9899fa9fe3f5d0b49f8c672b852340f32c1f4762cc02499b1e9cd5")
sig = bytearray.fromhex("00000000000000000000000000000000000000000000000000000005ca1ab1e0000000000000000000000000000000000000000000000000000000005ca1ab1e")
pubkeys = VerifyingKey.from_public_key_recovery_with_digest(sig, digest, ecdsa.SECP256k1, hashfunc=None)
# We should fin 0438df74e6944be4c15fe5396e7f8d317c41d512a0bc78ec1dbe9505da97b08c74aa80b5796d569395a4caf80f661a4f82a51c2b8d25df0953c882a777ea2e332c
@rllola
rllola / main.rs
Created July 10, 2024 19:00
Rinkeby peer (devp2p workshop)
// Fill the IP here
let ip = "67.223.119.155";
let port = 30303;
// Fill the remote_id here
let remote_id = hex::decode("9acab6f0d76413b33b1835000b956a62edac9945f97a47ad1ce2326ba3203d564e75de23fde8917ba2305b1bd99feab93ae17f1672fd2c1f580828280d4ff2a5").unwrap();
@rllola
rllola / command.txt
Last active April 2, 2024 09:11
Command to sort IPs by latency when using nmap
nmap -sn -iL ethereum_ips.txt | grep -Eo "((\(|)([0-9]{1,3}[\.]){3}[0-9]{1,3})(\)|$)|[0-9]+\.[0-9]+s" | tr -d '\015' | paste - - | sort -k 2
@rllola
rllola / signhash_single.py
Last active August 30, 2023 12:07
Attempting to verify the signature for a single signing flag transaction where the ouput is non existant
import ecdsa
# https://bitcoin.stackexchange.com/questions/114850/sighash-single-with-no-corresponding-output
pubkey = "044edfcf9dfe6c0b5c83d1ab3f78d1b39a46ebac6798e08e19761f5ed89ec83c108172c4776865f02047b39cd704135c00c1b00085e0d1b9255405ac7079fa50a2"
signature = "912f994094193109a9faedf7ef855220638f95ac51c66d4eb46740dd1c0813fa100bc99adb8b64fb784173ca8883a78835e156b74f143c02e071dc82695e8472"
msg = bytes.fromhex("0100000000000000000000000000000000000000000000000000000000000000")
verify_key = ecdsa.VerifyingKey.from_string(bytearray.fromhex(pubkey), curve=ecdsa.SECP256k1)
@rllola
rllola / repos.txt
Created February 14, 2022 20:53
Some Dogecoin repos
- SPV wallet : https://github.com/BitcoinAmiens/dogecoin-spv-node
- Payment Channel service : https://github.com/xanimo/dogecoin-spv-node-middleware
- Testnet faucet : https://gitlab.com/toffee_/dogecoin-testnet-faucet
- Payment Channel poc : https://github.com/rllola/doge-payment-channel
- Testnet miner : https://github.com/rllola/dogecoin-miner-rust
- Libdogecoin : https://github.com/xanimo/libdogecoin
- Discord tipping bot : https://github.com/BitcoinAmiens/dogecoin-tipping-bot
@rllola
rllola / auxpowblock.json
Created February 4, 2022 00:35
Testnet first auxpow block
{
"hash": "a19271cbe06a8243dfecdcf5935754566edc074a7544f042b5bb4796b8a87027",
"confirmations": 3429024,
"strippedsize": 516,
"size": 516,
"weight": 2064,
"height": 158390,
"version": 6422786,
"versionHex": "00620102",
"merkleroot": "cd258a54487d9239d10743cbe3f68ce07d610def2bd5659a6e41b84671245117",
@rllola
rllola / ecdsa_private_recovering.py
Last active October 5, 2022 22:50
Recover private key from ECDSA signature
#!/usr/bin/env python3
from Crypto.Util.number import inverse
import ecdsa
import random
import hashlib
C = ecdsa.SECP256k1
G = C.generator
n = C.order
@rllola
rllola / script.py
Created January 19, 2021 20:08
Get all the environement variable in electron project
import re
import glob
javascript_files = glob.glob('**/*.js', recursive=True)
variables = []
for file in javascript_files:
with open(file, 'r') as f:
javascript_blob = f.read()
Hello World !