When you just HAVE to verify a whole batch of Bitcoin signatures

0 430
Avatar for btcfork
Written by
This user is who they claim to be.
We have manually verified this user via some other channel.
3 years ago

... then you probably need a little Python script free software magic to help you:


See README for details on how to use.

Everything that's needed should be included, except for your own input text files (pubkeys/addresses, messages to sign, and corresponding signatures to verify).

You just need to create or obtain your own pubkey.txt (address), messages.txt and signatures.txt

Some trivial example files included - the format as shown above is simply plain text files with one item per line.

I've only run the script using Python 3 (3.5.2 and 3.5.3) , if you run into any problems with newer Python 3 versions, please let me know.

For Bitcoin Cashers, a small disappointment: the tools doesn't handle verification with new-style Bitcoin Cash addresses (CashAddr) yet. Maybe in a futurenext release. Otherwise, pull requests welcome!

I'll accept issues raised as comments below, or if you have a Gitlab account, you can submit them on the project's Issues tracker.

Example run, including copying over the good signature file to make all verifications pass.

This post was inspired by the news that a bonded courier arrived.

Generating a nice list of messages for someone to sign

Produce a list of 16,404 unique messages:

(beware, this only appends to any existing messages.txt file, so remove it beforehand to start fresh)

$ D=$(date +"%d %b %Y"); for i in `seq 16404`; do H=$(openssl rand -hex 32); echo "I claim this block for Satoshi ($D) $H" >> messages.txt; done

Depending on the speed of your computer, this may run a while.

Later, make sure the contents are good.

$ wc -l messages.txt
16404 messages.txt
$ head -3 messages.txt
I claim this block for Satoshi (16 Jan 2020) 29dfa7d4701778cf5aa4b0a252c5c75732a80965f8400fe4c5353fb5e465c832
I claim this block for Satoshi (16 Jan 2020) 861aec3b534381268c306701bdde3a8b05c07bb78e8bbc1099246b15e91e8059
I claim this block for Satoshi (16 Jan 2020) b5a581f9b3cdf3adbcf4e6a9be4f873b2857da22b7e2cc877c9ab8f5276ebf41

All good?

Keep a copy of the file, and give a copy to the person who is going to do the signing.

Once you get the list of addresses and signatures, you will use your copy of the messages to verify their signatures.


Thanks to Vitalik Buterin for the excellent pybitcointools, I took the liberty to include it even though he no longer maintains it. Please don't trouble him with support requests.

Update: Greg Maxwell has raised some concerns about the reliability of pybitcointools, which are probably valid since it's not maintained.
I'll search around for a better maintained replacement.

In the meantime, please do not rely on only one tool to verify Bitcoin signatures, if the results may have big monetary implications. Trusting one piece of software, which one has not fully reviewed, is never a good idea.
When there is a lot at stake, do not trust, verify as thoroughly as possible, that also means cross-checking against other tools. Spare no expense :-)

Sponsors of btcfork

$ 2.80
$ 1.00 from @Read.Cash
$ 1.00 from @JavierGonzalez
$ 0.50 from @molecular
+ 3
Avatar for btcfork
Written by
This user is who they claim to be.
We have manually verified this user via some other channel.
3 years ago