/bitcoin

Main Repository. Python Scripts demonstrating Bitcoin technical aspects.

Primary LanguagePythonMIT LicenseMIT

Bitcoin Python Codes

Bitcoin is a decentralized digital currency that enables online payments between parties without going through a central authority like a bank or government. Created by Satoshi Nakamoto in 2008.

This repository includes Python scripts demonstrating different technical aspects of Bitcoin.

Bitcoin is the money of the future.

Bitcoin is today's hope.


Besides the Python codes, I have also written several articles related to Bitcoin:

  1. Elliptic Curve in Bitcoin

Bitcointuesday

bitcointuesday.py

This script has been the one showed in the Bitcoin Tuesday Meetup #32. LINK[https://www.meetup.com/bitcoin-tuesday/events/300714364/] The code has all the comments in Spanish, also the output messages showed in command line. The script provides a step-by-step visualization of multiplying a generator point on an elliptic curve by a scalar value. This is done through a series of point duplications and additions, as used in ECC cryptography.

ECDSA Simple Signing and Verifying Flow

ECDSA-simple-flow.py

This Python script showcases the ECDSA process for signing plaintext messages and verifying their authenticity using a public-private key pair. It unfolds each step transparently, unlike comprehensive library modules. It generates key pairs, hashes messages with SHA-256, signs messages, and enables interactive signature verification.

secp256k1 Elliptic Curve Generator Point Multiplier Visualizer

secp256k1-elliptic-curve-generator-point-multiplier-visualizer.py

The script provides a step-by-step visualization of multiplying a generator point on an elliptic curve by a scalar value. This is done through a series of point duplications and additions, as used in ECC cryptography.

The script allows inputting a desired multiple of the secp256k1 generator point. It calculates the sequence of point operations required to arrive at this multiple through analitic geometry.

The steps are shown graphically on the secp256k1 curve plotted with Matplotlib. Each point duplication is marked with a red line and each point addition with a green line. The points are labeled clearly as multiples of the generator "G".

This provides an intuitive understanding of how private key scalars derive public keys on an elliptic curve.

3G Example

image

4G Example

image

6G Example

image

Elliptic Curve Field P Chart

The elliptic-curve-field-p-chart.py script generates an interactive visualization of an elliptic curve plotted over a finite field.

image

Elliptic Curve a+b=c labels

The elliptic-curve-a+b=c-labels.py script provides a visual demonstration of elliptic curve point addition. It graphs the secp256k1 elliptic curve used in Bitcoin and marks sample points A, B, and C.

image

Elliptic Curve Secp256k1 Simple Plot

The elliptic-curve.py script generates a simple plot of the secp256k1 elliptic curve, the one used in Bitcoin, over the real numbers.

image

RSA vs ECC keys security chart comparison

The RSA-vs-ECC-keys-security-chart-comparison.py script generates a chart comparing the security levels of ECC and RSA keys of equivalent strength.

image