Skip to content

Instantly share code, notes, and snippets.

BIP322 Message Verification for Signing Devices

A proposal for displaying human-readable messages on hardware signing devices during BIP322 signature operations.

Problem

BIP322 defines a generic message signing format using virtual Bitcoin transactions. The message is reduced to a 32-byte hash (message_hash) embedded in the to_spend transaction's scriptSig:

vin[0].scriptSig = OP_0 PUSH32[ message_hash ]
@orangesurf
orangesurf / README.md
Created December 8, 2024 05:50
directivo ots verifier

Document Verification Script

This script automates the verification of document timestamps using the OpenTimestamps (OTS) protocol and SimpleProof service. It is designed to process government documents from transparencia.gob.sv and verify their opentimestamps from simpleproof.

Running

  • install opentimestamps pip install opentimestamps-client
  • download directivo-ots-verifier.py & run python directivo-ots-verifier.py
  • (optional) update files/input.json with 2024 list
  • run python directivo-ots-verifier.py again
  • files/verified.json will be generated for all ots proofs that PASS the verifiaction
curl -s "https://mempool.space/api/v1/fees/mempool-blocks" | jq -r '.[0].feeRange |
"Percentile sat/vB
----------------------
0 (min) \(.[0] | floor)
10 \(.[1] | tostring | .[0:4])
25 \(.[2] | tostring | .[0:4])
50 (median) \(.[3] | tostring | .[0:4])
75 \(.[4] | tostring | .[0:4])
90 \(.[5] | tostring | .[0:4])
100 (max) \(.[6] | floor | tostring + ".")"'
import sys
import json
from datetime import datetime, timezone
import requests
def get_transaction_info(txid):
# Check if the transaction is confirmed
tx_url = f"https://mempool.space/api/tx/{txid}"
try:
response = requests.get(tx_url)