/building-a-cryptocurrency:coin-cryptographic-primitivesfrom building-a-cryptocurrency
Reference for cryptographic primitives used in blockchain development: hash functions, signature schemes (ECDSA, Schnorr, EdDSA, ring signatures), Merkle trees, Merkle-Patricia tries, and BIP-32/39/44/380 key derivation. Part 2 of the Building a Cryptocurrency series.
Ships in building-a-cryptocurrency. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Part 2 of 8 of the Building a Cryptocurrency reference (plugin
building-a-cryptocurrency), covering §2 — the hashes, signatures, key derivation and commitment schemes a chain is built from. Sibling skills:coin-what-it-is-and-the-three-architectures(§1 — the replicated-state-machine definition and the Bitcoin / Ethereum / Monero reference architectures),coin-consensus-and-finality(§3 — proof of work, proof of stake, Sybil resistance, fork choice and what finality actually means),coin-building-a-utxo-chain(§4 — the UTXO ledger model, script, transaction validation and what a fork of Bitcoin actually involves),coin-building-an-account-chain(§5 — the account/world-state model, the EVM, gas, and building a chain with smart contracts),coin-privacy-features(§6 — ring signatures, stealth addresses, confidential amounts and zero-knowledge approaches),coin-networking-and-tokenomics(§7–§8 — peer-to-peer gossip and propagation, then issuance, fees, supply schedules and incentive design),coin-security-and-the-build-guide(§9–§10 — what actually loses money, and the ordered guide to building and launching a chain),Section numbers are shared across the whole set: a reference written as §N →
skillpoints into that sibling skill. This is an engineering reference, not investment, legal or tax advice — deploying a chain that handles real value carries securities, AML/KYC and consumer-protection obligations that are a question for counsel in your jurisdiction.
Scope and disclaimer, carried forward from the source document. This is an engineering reference, not investment advice. Creating a cryptocurrency is a legitimate software engineering exercise with well-documented open-source reference implementations. However: deploying a cryptocurrency that handles real value carries serious legal, financial, and security responsibilities. Consult counsel regarding securities law, AML/KYC requirements, and consumer protection regulations in your jurisdiction before launching anything that distributes tokens to the public. §2 is where key material, addresses and seed phrases are defined, so it is directly upstream of every custody and consumer-protection question.
Every cryptocurrency is built from the same cryptographic primitives. Understanding them deeply is essential — not because you will implement them from scratch (you absolutely should not), but because every design decision in a cryptocurrency is ultimately a cryptographic decision.
The golden rule of cryptography: use vetted, well-maintained libraries at the highest level of abstraction that solves your problem. Never implement primitives yourself.
A hash function takes arbitrary input and produces a fixed-size output. The required properties:
| Property | What it means |
|---|---|
| Deterministic | The same input always gives the same output |
| Quick to compute | Cheap enough to run on every block, transaction and address |
| Preimage resistance | Infeasible to reverse — given the output, you cannot recover the input |
| Second preimage resistance | Infeasible to find a second input with the same output |
| Collision resistance | Infeasible to find any two inputs with the same output |
Collision resistance is the weakest of these properties and the first to fall. Design on the assumption that it is the property you lose first.
In cryptocurrencies, hash functions serve three critical roles:
| Role | What it does | Reference practice |
|---|---|---|
| Block hashing | The proof-of-work puzzle and the chain linkage (§3 → coin-consensus-and-finality) | Bitcoin: SHA-256d (double SHA-256). Ethereum: Keccak-256 (the pre-standardization Keccak variant, distinct from SHA3-256) |
| Merkle trees | Compact commitment to transaction sets (see 2.3) | Bitcoin: transaction sets per block. Ethereum: Merkle-Patricia trie over full state |
| Address derivation | Turning public keys into addresses | Bitcoin: RIPEMD-160(SHA-256(pubkey)). Ethereum: Keccak-256 |
| Function | Status | Verdict for a new chain |
|---|---|---|
| SHA-256 | Secure and well-studied | Natural choice |
| SHA3-256 (FIPS 202) | Secure and well-studied | Natural choice |
| Keccak-256 (the pre-standardization variant, Ethereum's) | Secure and well-studied, but not SHA3-256 — the padding and domain-separation rules differ, so the two return different digests for the same input | Natural choice, but pick it deliberately. Name which of the two your spec means and check which one your library's sha3/keccak entry point actually computes; getting this wrong silently breaks Ethereum compatibility |
| BLAKE2 / BLAKE3 | Faster alternatives with strong security properties | Viable |
| SHA-1 | Broken for collisions; deprecated everywhere that matters | Do not use for any security purpose |
| MD5 | Completely broken — collisions are trivial | Do not use for any security purpose |
SHA-2 uses the Merkle-Damgård construction and is vulnerable to length extension: knowing
H(m) lets you compute H(m + padding + extra) without knowing m. This is why
H(key + message) is not a valid MAC construction. SHA-3 and BLAKE are not vulnerable to
this. For HMAC, the construction is specifically designed to resist length extension regardless of
the underlying hash.
Digital signatures are the identity system of a cryptocurrency. You sign with your private key; anyone can verify with your public key. The signature proves the holder of the private key authorized the exact bytes that were signed — and that is the whole of what it proves. It does not make a transaction globally unique: the same signature over the same bytes verifies again, later, and on any other chain that encodes transactions the same way.
Replay resistance is a property of the ledger, not of the signature. A UTXO chain gets it
because a transaction names the outputs it consumes and each output can only be consumed once
(§4 → coin-building-a-utxo-chain); an account chain gets it because the signed bytes include the
sender's nonce, which the state machine increments (§5 → coin-building-an-account-chain). Across
chains and contracts it takes explicit domain separation — a chain ID inside the signed bytes
(EIP-155), an EIP-712 domain separator, or an equivalent tag. The rule for a new design:
whatever must not be replayable has to be inside the bytes you sign.
| Algorithm | Used By | Key Size | Notes |
|---|---|---|---|
| ECDSA (secp256k1) | Bitcoin (pre-Taproot), Ethereum | 256-bit | Widely deployed. Requires a per-signature random nonce k — reusing k across two signatures reveals the private key. This has broken real systems. |
| Schnorr (secp256k1) | Bitcoin (Taproot, Nov 2021) | 256-bit | Linear and aggregatable (enabling MuSig2 multisig); BIP340 specifies deterministic nonce derivation, but nonce handling remains security-critical. The modern default for new designs. |
| EdDSA (Ed25519) | Many modern systems | 256-bit | Fast, and hard to misuse: RFC 8032 derives the per-signature nonce by hashing the private key's prefix together with the message, so no per-signature RNG sits in the path to fail. That is the derivation doing the work — a repeated nonce still reveals the key. Ed25519 signs over edwards25519, a twisted Edwards curve; Curve25519 is the birationally equivalent Montgomery curve used by X25519 key exchange, which is a different primitive and does not sign. Do not substitute one for the other. Verification strictness (cofactor handling, signature malleability) differs between libraries, so a consensus system must pin one rule and test against it. An excellent default for new cryptocurrencies. |
| Ring Signatures | Monero | 256-bit | A group of possible signers, but the actual signer is hidden among them. The key privacy primitive for anonymous transactions. |
Ring signatures are developed in full — ring size, decoy selection and the FCMP++ upgrade path —
in §6 → coin-privacy-features. Taproot address encoding and the script consequences of Schnorr
are in §4 → coin-building-a-utxo-chain.
THE NONCE HAZARD, AND WHY IT IS NOT ONLY ECDSA'S
ECDSA requires a secret per-signature value
k. Ifkis reused across two signatures with the same key, simple algebra reveals the private key. This has broken real systems, including a well-known game console. Even biasedk(not perfectly random) leaks the key over many signatures.The fix is a specified deterministic derivation: RFC 6979 for ECDSA, BIP340 for Schnorr, RFC 8032 for Ed25519. Be precise about what that buys. Determinism is a property of the derivation a specification chose, not of the signature scheme: Schnorr and Ed25519 are nonce-based too, and a repeated or biased nonce reveals the key there by the same algebra. They are safer because their standard derivation takes the random-number generator out of the path, not because the hazard is absent.
Whichever scheme you use, use its specified derivation and never a homegrown one. One exception to keep in view: interactive multi-party signing (MuSig2, FROST) needs a fresh nonce per signing session that is never reused across sessions or retries — single-signer deterministic derivation does not carry over, and reusing a session nonce leaks the key share.
A Merkle tree is a binary tree of hashes where leaf nodes are hashes of data (transactions) and each internal node is the hash of its children. The root hash is a compact cryptographic commitment to the entire dataset. To prove a specific transaction is included in a block you provide a Merkle proof — the sibling hashes along the path from the leaf to the root — which is O(log n) in size. This enables lightweight clients (SPV) to verify transaction inclusion without downloading the entire blockchain.
// Merkle tree construction (simplified)
leaves = [hash(tx1), hash(tx2), hash(tx3), hash(tx4)]
level1 = [hash(leaves[0] + leaves[1]), hash(leaves[2] + leaves[3])]
root = hash(level1[0] + level1[1])
// To prove tx3 is included, provide:
// leaf = hash(tx3)
// sibling at level 0 = hash(tx4)
// sibling at level 1 = hash(leaves[0] + leaves[1])
// Verifier hashes up the tree and checks against the known root
| Chain | Structure | What the header commits to |
|---|---|---|
| Bitcoin | Merkle tree | Transaction sets within blocks |
| Ethereum | Merkle-Patricia trie | The entire state — accounts, balances, code, storage — not just the transactions |
Ethereum's trie commits the block header to the full state, which is what enables state
proofs; those are essential for light clients and bridges. The account/world-state model that
trie encodes is §5 → coin-building-an-account-chain.
Every user in a cryptocurrency has key pairs. The private key is the identity; the public key is
the address others send to. Key management is the hardest part of cryptocurrency — not the
cryptography, but the operational security around storing and using keys (the losses this causes
are §9–§10 → coin-security-and-the-build-guide).
| Standard | What it defines | What to watch |
|---|---|---|
| BIP-39 seed phrases | A human-readable encoding of a master seed — 12–24 words from a defined wordlist | The seed is the backup of the entire wallet: anyone with the seed has all the keys. The optional passphrase is a plausible-deniability/decoy layer — and a loss vector, since losing it makes the wallet unrecoverable |
| BIP-32 hierarchical-deterministic (HD) derivation | From the master seed, a tree of keys is deterministically derived; each branch produces a new key pair | Lets you never reuse addresses — address reuse damages privacy permanently on transparent ledgers |
| BIP-44 / 49 / 84 / 86 | Standard derivation paths by script/address type | Pick paths deliberately; wallets interoperate on these |
| Descriptors (BIP-380s) | Strings such as wpkh(xpub.../0/*) that fully describe a wallet's script structure | The modern interchange format between wallet software and signing devices |
PRACTICAL KEY MANAGEMENT
For your cryptocurrency, you need to define:
- The key derivation scheme — HD wallet with standard paths.
- The address format — how public keys are encoded as addresses. Bitcoin uses Base58Check or bech32; Ethereum uses hex with a checksum.
- The signature scheme and what exactly a signature commits to — the sighash flags.
- The multi-signature support — how M-of-N key sets are expressed in the transaction format.
coin-consensus-and-finality.coin-building-a-utxo-chain.coin-building-an-account-chain.coin-privacy-features.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
cryptography, blockchain, key-derivation, merkle-tree, signature-scheme
Other plugins' skills for the same job
8 skills in this plugin
/coin-building-an-account-chainUse when deciding between shipping an ERC-20 token, a new account-model chain, or an L2 rollup, and when designing or reviewing account state, EVM data locations, gas budgets, call semantics, or a fungible token contract. Covers the account world-state model, the EVM stack machine and its storage costs, the EIP-1559 gas system, the ERC-20 interface and its integration hazards. Part 5 of the Building a Cryptocurrency reference./coin-building-a-utxo-chainUse when designing or implementing a UTXO-based chain, modelling transaction inputs and outputs, writing or auditing Bitcoin Script locking and unlocking scripts, deciding which address formats a wallet or node must support, or forking Bitcoin. Covers the UTXO ledger model, block structure and chain linkage, the coinbase transaction and its maturity rule, Script validation, and the four Bitcoin address types. Part 4 of 8 of the Building a Cryptocurrency reference./coin-consensus-and-finalityUse when choosing a consensus mechanism for a new chain, sizing confirmation counts before releasing value, reasoning about 51 percent attacks and chain reorganizations, tuning difficulty retargeting, picking a proof-of-work algorithm, or deciding between probabilistic, explicit and instant finality. Covers proof of work, proof of stake, Gasper, BFT and DAG designs, slashing, nothing-at-stake and validator economics. Part 3 of 8 of the Building a Cryptocurrency reference./coin-networking-and-tokenomicsUse when designing or debugging the peer-to-peer layer of a chain — DNS seeds, peer exchange, inv and getdata gossip, compact block relay, mempool and relay policy — or when setting issuance, supply caps, tail emission, fee markets, token distribution and the security budget. Covers the policy versus consensus distinction and the trade-offs of each distribution method. Part 7 of 8 of the Building a Cryptocurrency reference./coin-privacy-featuresUse when adding sender, receiver or amount privacy to a chain, choosing among ring signatures, stealth addresses and confidential transactions, sizing an anonymity set, planning a move to full-chain membership proofs, or weighing mandatory privacy against exchange delisting and EU AMLR exposure. Covers the Monero reference design end to end: stealth address derivation and view-key scanning, ring size 16, Pedersen commitments with Bulletproofs+ range proofs, FCMP++, Dandelion++, subaddresses and RandomX. Part 6 of 8 of the Building a Cryptocurrency reference./coin-security-and-the-build-guideUse when auditing a chain or a contract for the failures that actually drain funds, choosing between an ERC-20 token, an L2 rollup and a new blockchain, picking the language, consensus, signature, wallet and explorer stack for a custom chain, or working a pre-mainnet launch checklist. Covers the 2025-2026 loss data, the design principles and key-management rules that prevent most bugs, and the three build paths with their timelines. Part 8 of 8 of the Building a Cryptocurrency reference.npx claudepluginhub the-vibey-project/vibey --plugin building-a-cryptocurrency