what is preventing an adversary to find (in many hours) a nonce that would make a malicious validator script to have the same hash and address of my validator script, and then submit it with cardano-cli in a transaction that unlocks at once all the utxos held at that address? Would this take (in average) a year with 8 or 16 of today's CPUs? 10 years? 1000 years?
Actually, This is an interesting question. I would like to share my thought about this. I don't know if I made mistakes somewhere. Please just consider it as a reference.
we want to consume all UTxOs locked at a validator address without knowing the validator script or without qualifying it.
we could try to create our malicious script that always returns to True. However, Cardano will always check if the hash value of the actual script is the same as the hash value of the provided script when we submit the consuming transaction. So in our malicious script, we could add a random line such as nonce = 1, nonce = 2, nonce = 3 and so on until the hash value of our script is the same as the actual script.
As far as I know, the validator address is also the hash value of the script. I tried to take a sample validator address which is from plutus-pioneer-program (see here), it seems to be the shortest address type. addr_test1wqag3rt979nep9g2wtdwu8mr4gz6m4kjdpp5zp705km8wys6t2kla. although I am not sure how the hash function is implemented, I can see all characters could be 0-9 or a-z and the length of the address 1wqag3rt979nep9g2wtdwu8mr4gz6m4kjdpp5zp705km8wys6t2kla is 54. Based on this idea, I calculated the number of all possible cases of the hash value as the following
Total possible cases = (10 + 26) 54 cases
- 10 is for 0-9
- 26 is for a-z
- 54 is the length of the address (is also the length of the hash value of the validator).
I am not really sure about the speed of today's CPU. let's say that 8 CPUs could handle 10^9 check (including compiling and running the malicious programs to take the hash value and check if it's expected) per second.
the result will be: (10+26) 54 / 109 / 3600 / 24 / 365 ~ 3.48 * 10 67 years.
It's a rough estimation, that's possible to have the case that some nonce value lead to the same hash value. for instance, nonce = 1 and nonce = 123978231231 return the same hash value, we need to check even more. Otherwise, in case we could find the result during the checking process soon, we don't need that long time.
Hope this is helpful!