Repository navigation
blockchainkit 0.2.0
The package is aligned with its kit-family siblings, and every subpackage now
follows its field through at least 15 breakthroughs, each with its own
experiment.
Added
- Tutorials across subpackages, every line run by the doctest build: Life of
a payment, Nonces everywhere, Hashes everywhere and Who do you
trust?. - Exercise pages, one per subpackage, with 40 worked solutions in collapsed
boxes, each run by the doctest build. They replace the single solutions page. - A "Teaching vs production" note on every history entry that adapts a
deployed protocol, naming the difference. - README figures, regenerated by
docs/make_readme_figure.pyand
docs/make_readme_subpackage_figures.py. - Execution history: 16 breakthroughs, each with its own gallery example,
from reverse Polish notation (1924-1957) to the BeautyChain overflow
(2018). New APIs:execute(..., arguments=...), the Forth wordsOVERand
ROT,REVERT, and the sharedSTACK_EFFECTStable;validate_program;
assemble(labels);to_rpnandcompile_expression;verify_bytecode
andVerificationResult;run_turing_machine,enumerate_machinesand
busy_beaver(reproducing S(2) = 6); Bitcoin-style Script with
verify_script,p2pkh_locking/p2pkh_unlockingandhtlc_locking
(OP_CHECKLOCKTIMEVERIFY); the contractsvending_machineand
batch_transfer(BEC overflow, with a SafeMath option);drain_bank
(DAO reentrancy); and the plotplot_stack_height. - Network history: 17 breakthroughs, each with its own gallery example, from
Erdős-Rényi random graphs (1959) to Dandelion (2017). New APIs:Graph,
erdos_renyi,ring_lattice,watts_strogatz,barabasi_albertand
complete_graph;lamport_timestamps,vector_timestamps,
happened_beforeandconcurrent;spread_rumor(push, pull, push-pull)
andpittel_rounds;reliable_broadcast(Bracha);ReplicatedRegister
(CAP);KademliaNetwork,xor_distanceandnode_id;AddressManager
andeclipse_probability;relay_cost,compact_block_relayand
short_id;fork_rateandsimulate_fork_rate;first_spy_precision;
SimulatedNetwork.from_graphandSimulatedNetwork.messages_sent; the
plotsplot_graph,plot_space_timeandplot_rumor_spread; and the
COMPACT_BLOCK_DOMAINconstant. - Consensus history: 17 breakthroughs, each with its own gallery example,
from the gambler's ruin (1656) to Casper FFG (2017). New APIs:
oral_messages(Byzantine generals);ben_or(randomized consensus, also
used to show the FLP adversary);view_changes(partial synchrony);
modular_square_root(Dwork-Naor pricing);pbft_roundand
quorum_size;attacker_success_probability(whitepaper section 11, checked
against its table);retargetandsimulate_difficulty;ghost_tipand
subtree_work;selfish_mining_revenue,selfish_mining_thresholdand
simulate_selfish_mining;fork_voting_payoffs(nothing at stake);
sortition; andFinalityGadget(Casper FFG with slashing detection). - Structures history: 15 breakthroughs, each with its own gallery example,
from double-entry bookkeeping (1494) to Merkle mountain ranges (2016). New
APIs:Ledger.total_supply;BloomFilter;hash_chainand
verify_one_time_password;BlockHeader,Block.to_header()and
verify_header_chainfor light clients;bitcoin_merkle_root(Bitcoin's
duplicated-leaf convention, for CVE-2012-2459);MerkleTree.consistency_proof
andverify_consistency(RFC 6962/9162);UTXOSet,UTXOTransaction,
OutPointandCoin;Transaction.unsigned_id(SegWit-style);
SparseMerkleTreewith membership and non-membership proofs; and
MerkleMountainRange. - Cryptography history: 22 breakthroughs, each with its own gallery example,
from the one-time pad (1917-1949) to MuSig (2018). New APIs behind them:
one_time_pad/xor_bytes;baby_step_giant_stepandpohlig_hellman;
merkle_puzzles/solve_puzzle;lamport_keypair/lamport_sign/
lamport_verify;find_collision/truncated_hash; a readable
Merkle-Damgard SHA-256 (merkle_damgard_sha256,sha256_compress,
sha256_padding) withlength_extension;naive_macandhmac_sha256;
pedersen_commit/pedersen_generators;feldman_split/feldman_verify;
TEACHING_GROUP, a 62-bit safe-prime group;simulate_transcript;
deterministic_nonce(RFC 6979, checked against the RFC's vectors); and
musig_coefficients/aggregate_public_keys/musig_sign. visualizers/in every subpackage (Matplotlib, imported explicitly; plain
import blockchainkitstill loads only the standard library):
plot_curve_points,plot_hamming_distances,plot_merkle_tree,
plot_proof_trace,plot_block_tree,plot_mining_trials,
plot_stake_shares,plot_gossip_timeline,plot_execution_trace.
Matplotlib and NumPy are now runtime dependencies; theexamplesextra is
gone.execute(..., trace=True)records aTraceStepafter every instruction,
following jumps; a failed run carries its partial trace inVMError.trace.
execute(..., gas_costs=...)prices opcodes individually (each at least 1).MerkleTree.levels,MerkleTree.leaf_count, andtrace_proof, which
returns aMerkleTraceofProofSteps, even for a proof that fails.Blockchain.blocks,tips(),work_at()andstate_at()to inspect
side forks.enumerate_pointslists every point of a small curve.
Changed
- The documentation follows the kit-family structure: generated hub pages per
subpackage, per-subpackage API pages, ahistory/directory with one
breakthroughs page per subpackage (each entry with its own References:
line andminigallery), an examples index, tutorials (the guided course and
solutions), and JupyterLite launch buttons. Examples moved to
examples/<subpackage>/<topic>/. The committed per-example notebooks and
their sync scripts are replaced by sphinx-gallery downloads and a single
notebooks/quickstart.ipynb. - The package uses the kit-family layout: one subpackage per domain with
core/,systems/,utils/andtests/, shared validation in
_validation.py, and every consensus-relevant constant inconstants.py.
Publicbk.<subpackage>.<name>imports are unchanged. - A wrong argument type (bool, float, string) now raises
TypeError; an
out-of-range integer still raisesValueError.multiplyreports the two
cases separately. - Mining varies only the header nonce:
Block.merkle_rootandBlock.hash
are cached, andBlock.header(nonce=...)builds a candidate header without
rebuilding the Merkle tree. Mining a 20-transaction block is about 59 times
faster per attempt (2 µs instead of 118 µs). verifyskips the subgroup-membership multiplications when Hasse's bound
proves the cofactor is 1 (newCurve.cofactor_is_one), halving the cost of
verification on secp256k1.Ledger,Blockchain,MerkleTreeandSimulatedNetworkhave readable
reprs.
Fixed
Transactionrejects asignaturethat is not aSchnorrSignature;
before, the block hash raisedAttributeErrorlater.executeraisesVMError, notTypeError, for a non-string opcode.Curveaccepts secp256k1's field prime and group order only in their own
roles; swapping them no longer skips the primality check.- A receive callback that raises no longer leaves the payload marked seen.
eventual_catch_uprejects non-numeric fractions, andStakeSamplerand
SimulatedNetworkreject non-integer seeds.