Readit News logoReadit News
hoten · 2 months ago
Personally I'd append the Nonce as a git trailer, not to the message body.

And would keep the date constant rather than use the time of each attempt (such that the only thing that actually varies is the Nonce)

And just for more fun... Nonces should only be prime numbers. Probably won't run out :)

AaronFriel · 2 months ago
Could you explain what a git trailer is if not appended to the message body? My understanding is that trailers are just key-value pairs in a particular format at the end of the message; there's not an alternative storage mechanism.

Even so, trailers or message body might be moot - rerolling the committed at timestamp should be sufficient!

kazinator · 2 months ago
Trailers are part of the commit message, but are separated from the body by a blank linke:

  Subject ...

  Body body body
  body body ...

  Signed-off-by: ...
This is all one commit message, but it is understood by convention has having several parts: subject line, body and trailers.

kazinator · 2 months ago
It is a trailer; see the source code, line 100:

            message = f"{base_message}\n\ngit-prime Nonce: {attempt}"
I'm not sure whether that's a valid header name, with the space and all, but I remarked on that in another comment already.

keepamovin · 2 months ago
It is now a proper git trailer, I think.
rbongers · 2 months ago
Finally, a tool optimized for creating Git commit hash collisions
perrygeo · 2 months ago
Even with git-prime reducing the address space by a few orders of magnitude, there's still (effectively) zero chance for collision. The difference between 10^-29 and 10^-27 isn't that great in practice.
nlehuen · 2 months ago
I came here to write that :-)
nlehuen · 2 months ago
Actually there are π(N) ~ N / ln(N) primes less than N per the Prime Number Theorem, so π(2 ^ 160) ~ 2 ^ 153.2 - this only drops 7 bits. So that does increase the odds of collision but much less than what I expected!
kazinator · 2 months ago
> Hash as int

Should be "Hash as decimal". The hexadecimal hash is already the same integer.

> Message: "Fix critical bug" + git-prime Nonce: 167

In the actual code it looks like:

  Fix critical bug
  
  git-prime Nonce: 167
So it is like a trailer. However, can trailer names have spaces in them?

A more conservative choices for the trailer header seems wiser, like:

  Prime-nonce: N
would be a safer choice for the trailer. (The word "git" is not required; we know we are in Git.)

Another subtlety is that if the message already has trailers, then you don't need to separate that from them by a blank line

Git has a command for manipulating trailers; that could be used.

(I see the developer doesn't really believe in this because I don't see the nonces in the commit messages of the project itself.)

keepamovin · 2 months ago
I added the trailer syntax, and rewrote git-prime history to ensure all commits are now number theoretic certified.

If you wish to do the same in your own repo I added a script "make-whole.sh" to do this - but I don't recommend it as force pushes and history rewrites could break stuff.

Also added a new tool

  git prime-log
To show which commits are already prime.

mlyle · 2 months ago
Attempt 168: cb80ebbd975f0028... not prime

[PRIME] Found after 168 attempts! Commit: cb80ebbd975f00288dca70d8fa735c688755f947

Why does it say not prime then prime?

cobbal · 2 months ago

Dead Comment

themafia · 2 months ago
Hisenprime.
keepamovin · 2 months ago
Nice work. We should probably go looking for such a category
keepamovin · 2 months ago
Bug, or just a example text bug. Now fixed
extraduder_ire · 2 months ago
Tangentially, I love how easy it is to add submodules to git. Just put an executable named git-<something> in your $PATH and it will get called by git when invoked like that.
wiml · 2 months ago
Nice. I think it would be even more æsthetically pointless if it fuzzed the commit date, message whitespace, etc instead of adding a blob...
keepamovin · 2 months ago
Pointless yes, but not as aesthetically pleasing at least for me.

This way you can have a choice a ordered primes based on none. Good mood? I’ll go with nonce 773 today.

kazinator · 2 months ago
Whenever you amend a commit, the commit time stamp changes; that ought to be enough, so that the nonce is not required. However, I think it has only second precision, so if you stick to honest wall time, it means 100 attempts require 100 seconds.
dudeinjapan · 2 months ago
Claude, copy git-prime but make it git-hexspeak instead https://en.wikipedia.org/wiki/Hexspeak
yencabulator · 2 months ago
dudeinjapan · 2 months ago
damn. there's nothing new under the sun...
aidenn0 · 2 months ago
Just be aware that there are more prime hashes than there are hashes with a specific 2 hex-digit prefix, so even relatively short messages will be much harder to find.
dudeinjapan · 2 months ago
worth it. plus my room is cold so I need my CPU to heat it up.
keepamovin · 2 months ago
Cute. 8008CAFE