Skip to content

Instantly share code, notes, and snippets.

@DrI-T
Last active February 6, 2022 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DrI-T/3d0d81b382547c6e8ecd2d20086a5e44 to your computer and use it in GitHub Desktop.
Save DrI-T/3d0d81b382547c6e8ecd2d20086a5e44 to your computer and use it in GitHub Desktop.
using GIT add a blockchain

The git blockchain

GIT already "cryptographically chain commits the only thing we are missing is a secure timestamp to have a concensus among the participants.

Using ots will provide timestamp on the bitcoin chain (BTC)

We only need a way to discover the HEAD (i.e. longuest chain) git pull $(pick-random-node)

Consensus rule : all block that doesn't create conflict are valid !

INSTALLATION

  1. install ots
  2. install gpg
  3. run sh git-ots-init

usage :

git commit -a -S "stamped commit" git tag -s -m 'Hello World!' initial-commit HEAD

verification

git log -1 --show-signature

#
gitdir=$(git rev-parse --git-dir)
# ipfs add -r .git/ots
qmemptyd=$(ipfs object new unixfs-dir)
qmgitots=$(ipfs object patch add-link $qmemptyd ots QmV6R7rCNMSRpM1ycbQ9NK6UJ8biiNoJCyV5UETZRPsVEx)
ipfs get -o $gitdir /ipfs/$qmgitots
chmod a+x $gitdir/ots/ots-git-gpg-wrapper.sh
git config commit.gpgsign true
git config gpg.program gpg
git config gpg.program $(which ots-git-gpg-wrapper)
git config gpg.program ".git/ots/ots-git-gpg-wrapper.sh"
git config user.signingkey $USER
#git remote add origin git@gitea.localhost:DrIT/gitchain.git
# git rev-parse HEAD
# git cat-file -p HEAD
# read also: https://github.com/opentimestamps/opentimestamps-client/blob/master/doc/git-integration.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment