6
\$\begingroup\$

This is the cops thread of this cops and robbers challenge. The robbers thread is here.

Related, but hashes numbers instead of strings and uses a different scoring system.

Definitions

A hash collision is when two different strings produce the same hash.

Summary

In this challenge, the cops will make a hash function, with a collision they know of. Then, the robbers will try to crack it by finding a hash collision in the cop's hash algorithm. To crack an answer, the hash collision the robber finds does not have to be the intended solution.

If a cop submission is not cracked for 7 days, it is safe, so mark it as such and reveal the intended crack and the score.
If a cop submission is cracked, mark it as such and edit in a link to the crack.

Rules

  • Cryptographic functions are allowed only if you know a collision in them. If it is a famous and secure hash algorithm like SHA-256, you must post the hashes of each string in a different, specified hash algorithm (ideally also in a secure hash algorithm), like Keccak-512.

Format

A cop answer has to contain the language and the source code.

Scoring

The score of a safe cop answer is the sum of the number of bytes of the two strings with the hash collision, with the lower score being better.

The winner

With robbers and cops being ranked separately, the winner is the person with the best scoring answer.

Example

Cop:

Python

from hashlib import*
def singlecharhash(x):
  a = blake2b(digest_size=1)
  a.update(x)
  return a.hexdigest()

Robber:

4 Points, Cracks cop's answer

¯ and É, both 2 bytes.

Pinboard

I am thinking of changing the scoring system to make it the minimum of the two strings. Any thoughts?

\$\endgroup\$
15
  • 3
    \$\begingroup\$ Note your example submission is invalid since using cryptography in a cops and robbers challenge is a standard loophole \$\endgroup\$
    – mousetail
    Aug 14 at 16:27
  • \$\begingroup\$ Also É is not one byte in utf-8. if you use a different encoding you need to state which one \$\endgroup\$
    – mousetail
    Aug 14 at 16:28
  • \$\begingroup\$ @mousetail I have rectified both. \$\endgroup\$ Aug 14 at 16:33
  • \$\begingroup\$ @mousetail OP specifically overrides that loophole for this challenge. If you can find a collision in Blake 2B, you can use it (good luck with that tho) \$\endgroup\$ Aug 14 at 16:58
  • 1
    \$\begingroup\$ Note that return STRING2 if sha256(x) == STRING1 else return sha256(x) would have sha256^-1(STRING1) and sha256^-1(STRING2) as a collision, but all other collisions would imply a collision in SHA256 (which obviously isn't feasible for a robber to find) \$\endgroup\$ Aug 15 at 7:12

1 Answer 1

2
\$\begingroup\$

Python 3, Cracked

import hmac

def my_hash(x):
    assert type(x) == bytes
    return hmac.digest(x, b'good luck', 'sha256')

Function takes bytes. There are no typing/Python tricks here, it's a pure crypto challenge.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Cracked. Possibly not what you intended... \$\endgroup\$ Aug 15 at 6:07

Your Answer

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

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