Skip to content

Instantly share code, notes, and snippets.

View fivepiece's full-sized avatar

fivepiece

View GitHub Profile
bip32 test vector 2:
seed : fffcf9f6f3f0edeae7e4e1dedbd8d5d2cfccc9c6c3c0bdbab7b4b1aeaba8a5a29f9c999693908d8a8784817e7b7875726f6c696663605d5a5754514e4b484542
m : xprv9s21ZrQH143K31xYSDQpPDxsXRTUcvj2iNHm5NUtrGiGG5e2DtALGdso3pGz6ssrdK4PFmM8NSpSBHNqPqm55Qn3LqFtT2emdEXVYsCzC2U
m/0 : xprv9vHkqa6EV4sPZHYqZznhT2NPtPCjKuDKGY38FBWLvgaDx45zo9WQRUT3dKYnjwih2yJD9mkrocEZXo1ex8G81dwSM1fwqWpWkeS3v86pgKt
m/0/42 : xprv9wSp6B7UBdybENFjzPMtDqKoddXxLZSijm538rhsNgSsnpD7VjcCc9XdzsBcWfS75TmeG27WLVsCEfaL7LzaEoNcKU8xUyzMqAS1DHHvTw6
m/0/42/2 : xprv9yidjfEMLNAmykgi1p3MVsP3huXJ17K55ywbpFSJYGUYJ5tTrz4aRJXMnUu4NJZVMTymi434adgFxfTwyr7YCQ3jQAaJiHNMd4uSR7bEXXE
---
rm -f /tmp/p*key.pem* /tmp/msg*; \
echo "generating and encrypting private key..."; \
openssl ecparam -name secp256k1 -genkey | \
openssl ec -conv_form compressed -out /tmp/privkey.pem -param_enc named_curve; \
openssl ec -in /tmp/privkey.pem -pubout -out /tmp/pubkey.pem; \
echo "deriving public key..."; \
openssl ec -pubin -in /tmp/pubkey.pem -noout -text; \
echo "creating and hashing message..."; \
echo -en "\x18Bitcoin Signed Message:\x0a\x06hello!" | tee /tmp/msg | \
#!/bin/bash
export LANG=C.UTF-8
export LC_LANG=C.UTF-8
bhash="${1:-$(bitcoin-cli getbestblockhash)}"
hex_cb=( $( bitcoin-cli getrawtransaction $( bitcoin-cli getblock "${bhash}" | grep -m1 " \"[0-9a-f]\{64\}\"" | tr -d '", ') 1 2>/dev/null | grep coinbase | grep -o "[0-9a-f]\{3,\}" | sed -e 's/\([0-f]\{2\}\)/\1 /g' ) )
if [[ ${bhash} == '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f' ]]; then
hex_cb=( $( echo '04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73' | sed -e 's/\([0-f]\{2\}\)/\1 /g' ) )
39d38
< from bitcoin import TESTNET
654,657c653
< if TESTNET == True:
< return "m/44'/1'/%d'"% int(account_id)
< else:
< return "m/44'/0'/%d'"% int(account_id)
---
> return "m/44'/0'/%d'"% int(account_id)
@fivepiece
fivepiece / sssbtctx.txt
Last active November 4, 2020 01:30
self signed sigs in btc tx
self signed signature in a bitcoin transaction
variables:
P - pubkey for op_checksig
d - discrete log for P
k - nonce used in signing
R - public point, discrete log is k
r, s - signature
@fivepiece
fivepiece / zcf_issue.md
Last active December 10, 2018 04:33
a list of issues with ZCF

Questions and concerns about ZCF
https://gist.github.com/awemany/619a5722d129dec25abf5de211d971bd

1

In "Creating a Zero Conf Forfeit transaction", it is mentioned that :

... a transaction that has the following structure:

  • Inputs: [P2PKH inputs 1] ... [P2PKH input I]
  • Outputs: [any-type-output 1] ... [any-type-output O] [Forfeit Output]
@fivepiece
fivepiece / rp-bu-abc-sv.txt
Last active September 1, 2018 14:07
BU\ABC\SV replay protection with script
<nums pubkey> = 02EFD6CF6CE988CF11384C70CCCC8B3FE5451F2FA415E6F75A5FB3D911ECF16514
<dummy msg> = 666F726B696E67 # `echo -n "forking" | xxd -ps`
<msg header> = 426974636F696E205369676E6564204D6573736167653A0A # `echo "Bitcoin Signed Message:" | xxd -ps`
<user pubkey> = as the name suggests
The script builds on stack a typical "Bitcoin signed message" (as in sign\verifymessage), with the text "forking" and a signature (1,1), signed by the pubkey <nums pubkey>.
Depending on which path is used when redeeming the script, the transaction becomes replay protected in one of 3 ways :
path 0 : valid on BU only
path 1 : valid on ABC only
@fivepiece
fivepiece / segfault.bc
Created March 9, 2018 19:03
gnu bc non base 10 array index segfault
#!/usr/bin/bc
# bc has memory issues
# this program will cause bc 1.07.1, 1.06.95, to segfault
define void toucharr(num, *ret[]){
ret[0] = num;
}
@fivepiece
fivepiece / c54959de.txt
Created March 24, 2017 14:25
block 1094169 / 000000000000034ba26cee29d86f20d6ead376aa1b868c14fd13bacac54959de on testnet
block 000000000000034ba26cee29d86f20d6ead376aa1b868c14fd13bacac54959de
txid list:
cb147f01d54ef67477b8387f3f8a9a9758400825e5d6cb74a53fc97aa178b15d
431dc972cb02d6b9bc7eb4b24df5c8093eff3f5ee503fa841cea852b6a3367d1
78607dc3d3e284d12b6eab724075da79fc2b6c76dcafdabcc71b459045334329
a250a7fb9967970171b22f04a7a3cdb9827d1f4933aad5429e637d4d3eba501c
dacf0634c4a5bae5361242a1522c55f8c7c956725912041f05718c9352d5f6c7
7dad1c55612f7fafe4659a07f538109a86f26a80aee17d8b7a2582d1430bec97
--- EvalScript START
Script : 3045022100ce5dd767430d42a9df1ac88d1bfd04a3fe4cf0ca3241c0bb143e76677528b9f702206f51396eab2c5c808c00d3ce3156774fa9c5b47e7190e6193dc952ab6e89e10c01
Stack :
PushOp : 48
Stack :
'3045022100ce5dd767430d42a9df1ac88d1bfd04a3fe4cf0ca3241c0bb143e76677528b9f702206f51396eab2c5c808c00d3ce3156774fa9c5b47e7190e6193dc952ab6e89e10c01'