1

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?

4
  • Can you share more information about what you are trying to do? Apr 11, 2023 at 1:54
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Apr 11, 2023 at 1:55
  • By adding a constant to a malicious script (let's call this constant "nonce") and by changing its value, one can obtain a different hash for the malicious script and so after many different attempts, can find a value for nonce such that the malicious script has the same hash (and address) of my genuine validator. If I originally provided only the hash of my validator and not the script itself, then one could in theory substitute it with the malicious script and override my genuine validator. So the question is:
    – Quantinity
    Apr 12, 2023 at 12:42
  • how long could it take in average to a computer with 16 of today's CPUs, given a malicious script, to find a nonce such that the hash and the address of the malicious script is the same hash and address of my genuine validator?
    – Quantinity
    Apr 12, 2023 at 12:42

1 Answer 1

0

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.

Problem:

we want to consume all UTxOs locked at a validator address without knowing the validator script or without qualifying it.

Approach:

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.

My calculation:

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

Where

  • 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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.