How does a smart contract know your phone signed?
In short
Since Fusaka, Ethereum has a built-in checker for P-256 signatures. It takes five numbers and answers 1 or nothing, worked through step by step.
Your phone's security chip signs a trade order, and a smart contract on Ethereum accepts it without ever seeing your phone. So how does it know the signature is real? Since the Fusaka upgrade, the answer is a checker built into Ethereum itself, specified in EIP-7951. This post works through what goes into that checker, what comes out, and what breaks it.
The order is an illustration. The numbers below come from a run in Python, with a software key standing in for the phone's chip; no phone, contract or chain was involved.
A contract only ever sees numbers
A smart contract is code deployed to the Ethereum network, not an app on your phone. Whatever your phone does, the contract only gets the data it is called with: bytes. So "my phone signed this" has to be turned into something the contract can calculate.
Security chips sign with an elliptic curve called secp256r1, also known as P-256. EIP-7951 says so directly: secure hardware, hardware security modules and FIDO2/WebAuthn authenticators "use secp256r1 for key storage and signing operations". Ethereum itself already uses a different curve, secp256k1. Before the EIP, it says, the use cases it enables were "currently impossible or prohibitively expensive".
That changed with Fusaka. According to ethereum.org, the upgrade went live on 3 December 2025 and introduced "a built-in, passkey-style secp256r1 (P-256) signature checker at the fixed address 0x100".
The signature is two numbers, the key two more
When the chip signs, it produces a signature made of two numbers, called r and s. The chip also has a key pair. The private key stays in the chip and makes signatures. The public key is the half it can share: it is a point on the curve, so it is two numbers as well, x and y. As ethereum.org's page on accounts puts it for Ethereum's own keys, you can derive a public key from a private key, but not the other way round.
So a signature and the key that should have made it are four numbers. Each fits in 32 bytes.
The checker takes five numbers
The checker at 0x100 is called P256VERIFY. EIP-7951 fixes its input: exactly 160 bytes, read as five values of 32 bytes each. The first is a hash of the message, a short fingerprint: change one character of the message and almost the whole hash changes. The other four are the signature's two numbers and the key's two.
This is the input from our run, for the message approve order A, with SHA-256 as the hash:
bytes 0–31 hash h 926104cb1a287afe…bytes 32–63 r (signature, part 1)bytes 64–95 s (signature, part 2)bytes 96–127 x (public key, part 1)bytes 128–159 y (public key, part 2) 5 × 32 = 160 bytes
The output is short. For a valid signature, the checker returns 32 bytes whose last byte is 1. For an invalid signature, or for any input it cannot read, it returns nothing at all: zero bytes. It never reverts, and a failed check costs the same gas as a successful one.
In our run, the signature made for approve order A, checked against the key that made it, returned the
…01.
One letter changed: the answer is empty
Now the same signature, the same key, but the message is approve order B. The hash is calculated again:
order A: 926104cb1a287afe469012223c07a45fd5eca7f0fced14625567896d9d842a9border B: ac02a01d69cb1760b71e9a9257bf16e7e9c54b7ec02364232248b06ceb505af7
60 of the 64 characters differ. The signature was made for the first hash, not the second, so the checker returns nothing. The same happens the other way round: a second key, signing
approve order A correctly, gets …01 when checked against its own public key, and nothing when checked against the phone's.
We also changed one random byte at a time, a thousand times, either in the message or in one of the signature's two numbers. None of the 1,000 changed inputs passed. Our checker, written out in Python from the EIP's steps, gave the same answer as the
cryptography library on all 1,000.
What the contract learns from a yes
A …01 says one precise thing: the holder of the private key behind x and y signed this hash. If the contract already knows that x and y are your phone's key, and the hash was made from this exact order, then a yes means your phone signed exactly this order. The contract never needs the phone itself.
This is also why the checker wants the key as input. EIP-7951 chose "verification rather than public key recovery". Ethereum's older checker for its own curve, ECRECOVER, works the other way and recovers a key from a signature. For P-256, the EIP notes that hardware verifies directly and that verification is more efficient for this curve.
The price per check is fixed in the EIP: 6,900 gas, against 3,000 for ECRECOVER. The authors say they benchmarked P-256 verification as significantly slower and raised the cost to match.
Check it yourself
The input layout fits in a few lines of Python with the cryptography package. The function
check reads the five numbers out of the 160 bytes and answers like the checker: 32 bytes ending in 1, or nothing.
import hashlibfrom cryptography.hazmat.primitives import hashesfrom cryptography.hazmat.primitives.asymmetric import ec, utilsfrom cryptography.exceptions import InvalidSignaturekey = ec.generate_private_key(ec.SECP256R1()) # stands in for the phone's chippub = key.public_key()r, s = utils.decode_dss_signature(key.sign(b"approve order A", ec.ECDSA(hashes.SHA256())))x, y = pub.public_numbers().x, pub.public_numbers().ydef call(order): # the 160 bytes for the checker at 0x100 words = [r, s, x, y] return hashlib.sha256(order).digest() + b"".join(w.to_bytes(32, "big") for w in words)def check(data): # same answer as the checker: 1 or nothing h = data[:32] r_, s_, x_, y_ = (int.from_bytes(data[i:i + 32], "big") for i in range(32, 160, 32)) try: q = ec.EllipticCurvePublicNumbers(x_, y_, ec.SECP256R1()).public_key() q.verify(utils.encode_dss_signature(r_, s_), h, ec.ECDSA(utils.Prehashed(hashes.SHA256()))) return (1).to_bytes(32, "big") except (InvalidSignature, ValueError): return b""print(len(call(b"approve order A"))) # 160print(check(call(b"approve order A")).hex()) # 000…001print(check(call(b"approve order B")).hex()) # empty line
The snippet hands the actual curve arithmetic to the library. The run behind this post also wrote the check out from the EIP's curve parameters and steps, and compared both.
What the check does not do
- It does not know whose key it is. The checker answers whether this key signed this hash. Which key belongs to which user is the contract's job, recorded before any check.
- It checks the hash, not the order. The checker never sees the order text. What the hash covers, and which hash function makes it, is up to the contract and the signing side. SHA-256 is the choice in our run, not a rule of the EIP.
- A valid signature is not unique. EIP-7951 notes that P-256 signatures are not required to be non-malleable, and that applications which need that "should implement additional checks at the application layer".
- The run is not a phone. A software key stood in for the chip, and no contract or chain was involved. The answers above come from code that follows the EIP, not from a node.
Get the next explainer
Every Cube Algos reel gets a post like this one: the mechanism worked through, with sources and limits. If you would like the next one by email, sign up below. You will first get an email with a confirmation link; you are only on the list after you click it, and every email has a link to unsubscribe.
Sources
- Ethereum Improvement Proposals, "EIP-7951: Precompile for secp256r1 Curve Support": the address 0x100, the 160-byte input, the output, gas 6,900 against 3,000, verification rather than recovery, secure hardware using secp256r1, malleability.
- ethereum.org, "Fusaka": the date, 3 December 2025, and the checker at 0x100.
- ethereum.org, "Ethereum accounts": public keys derive from private keys, not the other way round.
All sources last opened on 1 December 2026. The hashes, the 60 of 64 characters, the second key and the 1,000 changed inputs come from our own run (Python, with the
cryptography library), not from the sources.
More posts
-
Why did the API key survive obfuscation?
A key written into Dart code ships in the app file, and --obfuscate only renames symbols. What one search finds, and what a server changes.
-
If Claude Code runs the deploy script anyway, why does nothing go live?
A Claude Code deny rule matches command text, so a full path slips past. A contract deployment still needs a signature from a private key.
-
Same build step, same tag, different code: what would have stopped it?
A tag like v1 can be moved to other code. A commit's fingerprint follows from its content. Why pinning to the SHA keeps a build on the code you chose.
-
How do you add money when 0.1 + 0.2 is not 0.3?
Binary floating point builds fractions from halves, where a tenth never ends. That is why 0.1 + 0.2 is not 0.3, and why money is counted in whole cents.