‹ BackHN Continuity

Thread

Git 3.0's upcoming SHA-256 default will be a costly mistake

570 points · 536 comments · chmaynard

  1. GrantMoyer · · focus · HN ↗
    For reference: <a href="https:&#x2F;&#x2F;git-scm.com&#x2F;docs&#x2F;hash-function-transition" rel="nofollow">https:&#x2F;&#x2F;git-scm.com&#x2F;docs&#x2F;hash-function-transition

    Notably, a few of the featured author&#x27;s reservations appear to be addressed. According to the Git docs:

    - Objects can be referred to by their old, SHA-1 name or their new, SHA-256 name. This means old refs in docs and comments and such remain valid. The mapping between SHA-1 representations and SHA-256 representations appears to be intentionally bijective a.k.a. 1-to-1 (assuming no hash collisions), so that it could be re-computed on demand. The constraint of bijectivity appears to be the source of some limitations, ex. no mixed repos and submodules needing to match hash algroithm, but also bijectivity has strong benefits like the following items.

    - A bi-directional dictionary is maitained from SHA-1 to SHA-256 names so translations between the two don&#x27;t required re-hashing objects. This table could be recomputed on demand due to the bijection between names; it&#x27;s only a performance optimization.

    - A local SHA-256 converted repo (including an SHA-256 converted submodule) can interoperate with an SHA-1 only remote transparently to the remote server by translating names using the lookup table.

    - SHA-1 based GPG signatures will be preserved. A commit can be signed based on its SHA-1 representation, its SHA-256 representation, both, or neither. The bijection means the two types of signatures are in a sense interchangeable, or in other words the bijection between object representations implies an equivalence relation on signatures. An SHA-256 converted repo can quickly validate an SHA-1 based gpg signature using the lookup table.

    1. froh · · focus · HN ↗
      now I&#x27;m confused: if sha-256 is only used for new repos (default) and sha-1 continues to work for sha-1 based remotes, so a git clone, git push just keeps sha-1, then what exactly is the remaining issue? to me this sounds like a perfect and user friendly migration strategy.
      1. GrantMoyer · · focus · HN ↗
        The third-party tooling concerns seem plausible. For example, it seems like the intension for Git hosting is:

        1. Git users all transition to SHA-256 while git hosts stay on SHA-1.

        2. Once almost all Git users are on SHA-256, Git hosts flip a switch and convert all hosted repos to SHA-256. Git users on SHA-256 don&#x27;t notice anything, because the only thing that changes is how the client and server negotiate which objects to send.

        3. Git hosts disable SHA-1 support. Git users on ancient clients need to upgrade or switch hosts.

        Instead, by the author&#x27;s account, Git hosts are deciding to convert repos to SHA-256 individually and placing the decision of when to do each conversion upon their users, who may not be informed about the situation. To me, that seems like the wrong decision, but then I don&#x27;t run a Git hosting service.

        No doubt other tools will take some time to catch up too. For example, libgit2 is perhaps the most popular third-party Git client, and it still doesn&#x27;t support newer Git features like reftables (circa 2020). Though libgit2 does appear to implement SHA-256.

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.