Skip to main content

Type a word from a question or an article title.

1 · Basics

Public-key cryptography - how a signature proves it is you

How private and public keys work, where an address comes from, what an ECDSA digital signature is and why a wallet needs no password. With a clear example.

4 min readUpdated:
In this article

When you press "Confirm" in a wallet you do not type a password. Instead the wallet creates a digital signature. It proves that the key's owner approved the action, while the key itself stays secret. Behind this lies one of the most beautiful ideas in mathematics - public-key cryptography.

The idea: a lock everyone can close but only one can open

Imagine a mailbox with a slot: anyone can drop a letter in, but only the key holder can take them out. In asymmetric cryptography every participant has a pair of keys:

  • The private (secret) key - known only to the owner.
  • The public key - known to everyone; the address is derived from it.

The keys are mathematically linked, but the link is one-way: from the private key the public one is easy to get, and the other way round is impossible in reasonable time.

What a private key is

A private key is simply a very large random number: 256 bits, about 10^77 possibilities. That is comparable to estimates of the number of atoms in the universe, so a stranger's key cannot be guessed by brute force. This number is "access to the money": whoever knows it controls the address. In wallets the key is derived from a seed phrase that you write down at creation (how not to lose it).

From key to address

Ethereum and Bitcoin use the elliptic curve secp256k1. The path from secret to address:

  1. The private key k (a number).
  2. The public key = a point on the curve obtained by multiplication: K = k × G, where G is a "base point" shared by everyone. The result is 64 bytes.
  3. The address = the last 20 bytes of the hash of the public key (what a hash is): keccak256(K).

That is why an address can be shown to anyone. You cannot compute the public key from it, let alone the private one. It is like a bank account number, not a password.

The digital signature

A signature answers the question: "How do you prove a message was written by the key's owner without showing the key?"

The ECDSA scheme:

  1. The sender takes the hash of the message or transaction.
  2. Computes a signature from the hash and the private key. The signature is a pair of numbers (r, s) plus a "hint" v, 65 bytes in all.
  3. Anyone can check: from the signature and the hash, the signer's public key (and address) is computed. If it matches the sender's address, the signature is genuine.

Important properties:

  • A signature is bound to the message. Change one letter and the signature no longer fits.
  • It cannot be forged without the private key.
  • The private key stays secret however many signatures you produce.

Example: a signature in a deal

Anna creates a deal. Her wallet:

  1. builds the transaction: "call createOffer with such-and-such parameters";
  2. computes the transaction's hash;
  3. signs it with Anna's key;
  4. sends the transaction with the signature to the network.

Network nodes do not know Anna's key, but from the signature they see: the sender is Anna's address and the parameters were not altered. That is why the contract can trust that msg.sender is exactly Anna: the signature was verified before the contract code started running.

What else is signed besides transactions

  • Login messages ("Sign-In with Ethereum"): you prove to a site that you own an address, with no password and no transaction.
  • Structured data (the EIP-712 standard): the wallet shows a readable form - recipient, amount, deadline (more on signatures).
  • Permissions (permit): a signature that lets a contract pull tokens without a separate approve transaction (about this).

How a signature differs from encryption

A signature does not hide content - it confirms authorship and integrity. Encryption, on the contrary, hides content from outsiders. A blockchain mostly uses signatures: everything is public, but nothing can be forged.

Learn how all your keys come from one phrase: HD wallets and the seed phrase. Or return to practice: the wallet security checklist.

Mentioned in

Ready to try it?

Create your first deal in a couple of minutes. The money is locked in a smart contract and paid out by rules you can see in advance.