Skip to content

Instantly share code, notes, and snippets.

@darelf
darelf / jwt.py
Last active April 13, 2022 21:24
Python 3 JWT
"""
Functions for creating and verifying authentication tokens
according to the `JWT spec <https://jwt.io/>`_.
JWT authentication tokens are made of three sections that are
Base64Url encoded with no padding. The third section is an HMAC
of the first two sections, so that without knowing the secret
key you cannot verify the token nor create tokens that will be
accepted on the other end.

A description of known problems in Satoshi Nakamoto's paper, "Bitcoin: A Peer-to-Peer Electronic Cash System", as well as notes on terminology changes and how Bitcoin's implementation differs from that described in the paper.

Abstract

The longest chain not only serves as proof of the sequence of events witnessed, but proof that it came from the largest pool of CPU power.