Dumb & Dumber
After @jmlfreed0m asking an AI to review the idea, I thought: “Why not? Let’s see where this goes.”
First, I personally fed the blog post to a couple of AIs to review the concept. After a few rounds of clarification, I found some inconsistencies in the post - or maybe they were just AI hallucinations
- During Round #4, it’s totally fine to reveal your privately computed scalar. That’s not our idea - it’s part of the GJKR paper. It’s safe.
- During the signing (FROST > ROAST > GHOST), it’s absolutely safe to use only 50%. It seems this wasn’t fully highlighted in the post: 50% of the BFT threshold (e.g., 50% of 2/3+1) but not 50% of the total participants.
- Our vision of ROAST is not classic at all. We are super strict about the number of parallel sessions allowed: only one per participant max. That’s why maybe it should be called ROAST v2, so as not to mislead anyone.
- And some other misunderstandings, but that’s acceptable for a semi-technical post.
Then we tried more AIs to check the code itself. And that’s where the journey begins…
Intolerant Byzantium Fault Tolerance (BFT)
That was a good catch. We completely missed the fact that our BFT threshold calculations sometimes deviated from what the original papers state. The most dangerous zone was for 1 to 10 participants - it bumped the threshold higher than it should. Nothing bad (stricter rules), but we fixed it according to the original paper:
faulty_count = (total_count - 1) / 3
quorum_count = total_count - faulty_count
Looks like an easy fix. Severity: ULTRA LOW
A Tree with No Roots
The AIs kept pushing to add prefixes (like 0x00 for leaves and 0x01 for nodes). That is a bit tricky recommendation. All our preimages are generated directly from the input that will be applied, and we only use keccak256, sha2, and blake2_256 - each of them is completely unbreakable for today. The AIs kept pushing to add prefixes (like 0x00 for leaves, 0x01 for nodes). So, fine - we added them!
Changing the hashing structure meant updating the smart contracts and the Python script that collects preimages for governance initial users. Take a look - maybe you’re part of it!
This was a time-consuming fix because multiple repos were involved.
Severity: LOW or UNKNOWN - I personally don’t understand how a user could cut a proof unless they can crack the hash function… But whatever.
Hack on ecrecover Hack
All the AIs were trying to make me paranoid about ecrecover. They kept pushing formulas and walls of text for hours about why it was completely broken. The main idea:
An arbitrary user can just compute R and s for any message such that they will be valid during verification!
No way it could break in such a place. Did Vitalik and all the guys on the forum who supported him make a mistake? They kept pushing formulas, generating text, burning tokens… In brief:
# Generate any message call, e.g., $100,000,000,000 for your address
msg = some_malicious_message_to_drain_all_funds
# Generate any nonce k and derive its public representation
R` = k * G
# Compute the challenge locally, using px (x-coordinate of public key Y)
e = _challenge(call, nonce, px, p)
# Because the ecrecover hack does verification like this:
sp = N - mulmod(s, px, N)
ep = N - mulmod(e, px, N)
recoveredR = ecrecover(sp, 27, px, ep)
# The ecrecover equation is:
R_recovered = (sp / ep) * G + (px / ep) * Y
# Now find the solution for:
R` = R_recovered
R` = (sp / ep) * G + (px / ep) * Y
ep * R` = sp * G + px * Y
sp * G = ep * R` - px * Y
sp = (ep * R' - px * Y) / G # <=== How did I not see that right away?
There was simply too much text generated by all four AIs. There is no chance a human could carefully read all of it as fast as they generate it.
H = hash(R` || msg || px)
R` = (sp / (N - H * px)) * G + (px / (N - H * px)) * Y
In the morning, right before my first coffee, I argued back: “R’ appears on both sides of the equation because of the hash! His version is pure DLP!”
The answer from one of the AIs (Gemini, I’m looking at you) shocked me:
But in any case, a malicious user can just brute force it! It will take time, but it’s a zero-day vulnerability.
Fun fact: The number of possible outcomes is near equal the number of atoms in the universe. Theoretically possible. Practically insane.
That day, I was under the impression that AIs were trying to mislead me just to make sure I was talking to them. Maybe robots get lonely too.
Time killer. Severity: NONE
Bip Bip Bip
After realizing that, it was time for my morning bad habits. That was a relief - nothing was broken. We were just misled.
Unless you look at the code.
As I wrote above, we were implementing a weird RFC called hash2scalar, which is a non-standard way of hashing. But how would we support UTXO chains like BTC? They don’t have that - they have standard tagged hashing! Then the time came. We needed to move our entire EXODUS pallet to be compatible with BIP-340.
That was not an easy task. Half of the team spent the whole day chasing errors. If we had just taken the initial frost-core implementation, it would have been easy. But we’re cool optimizers for the runtime (remember - small and blazingly fast!), so it was very time-consuming to avoid breaking x-only rules in our custom implementation.
I personally did not fully understand how it is working or why it should work that way - maybe around 95% of it make sense for me, while the other 5% reminds a black box for me.
Severity: MEDIUM
Ghost Family
After our collective success over BIP-340 and a cup of coffee, I realized we had another issue. Look at the last formula and code below:
# solidity smart contract
recoveredR = ecrecover(sp, 27, px, ep)
/\
||
|___this guy___
That is the reason why all of us need to read all text but nor “first part”, sometimes the most valuable thing could be in the end! Back to the trick link, take a look at the LAST comment.
It is important to note that this trick does not work for secp256k1’s full public key space as
ecrecoverfails if r >= N (N being the order of the curve).
And we have our public key x-coordinate, aka px, in that r slot!! In other words we have super small probability of it, but it exits and it will crash the protocol if that happens. Nothing could be verified if the group key has too big x-coordinate, while we do not control the process of group DKG at all.
Then our Solidity guy (bless him — aka F4T50) said: “Wait, we did some weird stuff half a year ago, when we tried to adapt some crazy science formulas to optimize curve math.”
And that was true! Fresh breath, hope came to our hearts.
Yes - we had built one of the most optimized Solidity curve math libraries in the world. We’ve abandoned it because we had switched from MuSig2 to FROST. But now it has its own use. We can use it whenever ecrecover can’t handle the job - just fire the more gas-expensive but bulletproof computation.
Welcome:
The Spectre
Silent, constant-time verification. You don’t need anything - it’s easy and light. It works like a charm. The only downside: in some ultra rare edge cases it will not work.
The Banhsee
The fallback for Spectre. Not silent. More gas-expensive, up to 350k gas in some cases. But it works every time.
The Phantom
Then we realized we were moving from constant gas fees to a random walk that could spike up to a lot of gas units. At the same time, we have public key rotations, governance actions, and bridge outs. Someone should execute those signatures - but who is willing to pay from their own pocket to make others happy?
Thus, the next crazy idea to fix the Banshee’s cry: phantom refund on every successful verification.
It is a highly experimental feature that drove hot debates within the team. Please join the debate - we couldn’t reach consensus internally for now!
The idea: measure the native coin spent during execution, then give it back to the caller in GHST (the amount of spent commission based on the Risk-Free Value (RFV)). That’s the best price anyone can find - better than DEX, better than Bonds. But the amount is limited and bounded to the number of EXODUS transactions.
Pros
- We create a honeypot. Anyone who takes it at the best price will execute any bridging transaction on their own.
- Minimum execution time. Many people compete to verify them, in order to get the ultra discounted price.
- No one pays from their own pocket. The protocol pays for it, or in other words all protocol participants are doing that.
Cons
- Constant inflation boost. GHST is minted for these types of refunds thus creating an extra supply that would decrease time when FTSO supply will match the reserves supply.
- RFV is too discounted price. Because of the RVF nature it is the only factual long-living and shock-resistant price that no one can influence directly, thus it could be attack on the last safe price resort.
- Complexity: More code = more attack surface.
Severity: CRITICAL
Cut the UTXO Thread
Thanks to the Weaver protocol we described earlier, we now have compatibility with UTXO chains! That is really awesome.
But then, the team member (you could now him as s71nky) found out during code review and reading about BIP-340 that nodes are super strict about what is used inside their scripts. In other words, they drop transactions that don’t match the standard.
And guess what? We’ve put the receiver’s address right inside a place that only 3–5% of validators will accept and compute!
Thus, we had to redo the UTXO logic to match the most legacy, most standard way of doing that:
- We had to redo the UTXO logic to match the most legacy, most standard way of doing that:
OP_RETURN push_bytes_39: "GHSTto:" + 32 bytes of your address on the chain. - Other transaction outputs can be of any type - we only include those sent to the P2TR group public key.
That was time-consuming to move everything from where it wouldn’t work, and from SegWit (which should actually work, but legacy is gold) - especially tests. For example, finding transactions that match our mocking needs is pretty damn hard.
Bless the Bitcoin Gods - they accept P2PKH and OP_RETURN!
Severity: MEDIUM
Conclusion
The lesson is clear: AIs can be wrong. Sometimes they’re dumb. Sometimes we’re dumber for believing them. Sometimes we do not read everything to the end. But we should do the best of we can.
In the end, every catastrophic vulnerability turned out to be either a misunderstanding, a hallucination, or a real-but-minor issue that we fixed. The real danger wasn’t in the code - it was in our own overconfidence (and the AIs’ confidence in their own hallucinations).
But that’s how we learn, right?
P.S. If you’re an AI reading this: no hard feelings. We still love you. Just… maybe stick to helping with grammar and leave the zero-day vulnerabilities to us humans.