Guest User

Golly Life Data Memorialization Script

a guest
Sep 20th, 2018
181
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- This script was developed by Dave Scotese.
  2. -- It was designed to enable people to recognize large amounts
  3. -- of data without having to rely on a computer to store any
  4. -- kind of hash or fingerprint.  It creates a memorable visual
  5. -- experience inside of the open-source project "Golly"
  6. -- available at https://sourceforge.net/p/golly/.  
  7. -- You may be familiar with OpenSSH's "randomart" feature.  If
  8. -- not, you can check it out at:
  9. -- https://superuser.com/questions/22535/what-is-randomart.
  10. --
  11. -- The memorable visual experience is what happens when you watch
  12. -- "Conway's Game of Life" (a deterministic cellular automaton)
  13. -- process the bit pattern created by the hash of the large
  14. -- amount of data. That's what Golly is for.
  15. --
  16. -- Typically, the SHA256 algorithm can be used to create a hash
  17. -- of the data you'd like to verify.  Someone would have to have
  18. -- that data, compute the hash, and then run this script to create
  19. -- the experience, but the end result is quite unique, so even a
  20. -- still shot of the final pattern on which the Game of Life
  21. -- stabilizes would work.  Once enough people verify that the
  22. -- correct data produces the experience, we can trust any data that
  23. -- produces the same experience, because (we can assume) only that
  24. -- data would produce the hash that entirely comprises the intial
  25. -- conditions for the experience.
  26. --
  27. -- The motivation for this project was to preserve the integrity of
  28. -- the "UTXO set" for Bitcoin without having to keep the entire
  29. -- blockchain forever.
  30. --
  31. -- The example doesn't use the UTXO set because I don't know how to
  32. -- get it easily.  Instead, I memorialized block 542,324 into the
  33. -- "Apron image" at https://imgur.com/a/rwIQuVz.  I did this by
  34. -- inputting to this script the Merkle root for that block plus the
  35. -- 32-bit hexadecimal number for the block height (00084672).  This
  36. -- creates a 16x18 grid of random pixels and the pattern stabilizes
  37. -- at generation 2,418.
  38.  
  39. local g = golly()
  40. local gp = require "gplus"
  41. local validint = gp.validint
  42.  
  43. local gen = g.getstring("Enter a Hex string",
  44.                   "abc", "Render Hex to a Game of Life")
  45. drawstate = g.getoption("drawingstate")
  46.  
  47. if gen == "" then
  48.     g.exit()
  49. elseif string.match(gen,'[^a-fA-F0-9]') then
  50.     g.exit("Sorry, but \""..gen.."\" is not a valid hex string.")
  51. else
  52.     g.new("HexPattern: "..gen)
  53.     g.setrule("B3/S23:T200,200")
  54.     g.setmag(2)
  55.     local x = 0;
  56.     local y = 0;
  57.     gen:gsub(".", function(c)
  58.         if c > '7' or c >='A' or c >= 'a' then
  59.             g.setcell(x,y,drawstate)
  60.         end
  61.         x = x+1
  62.         if string.match(c,'[4567cdefCDEF]') then
  63.             g.setcell(x,y,drawstate)
  64.         end
  65.         x = x+1
  66.         if string.match(c,'[2367abefABEF]') then
  67.             g.setcell(x,y,drawstate)
  68.         end
  69.         x = x+1
  70.         if string.match(c,'[13579bdfBDF]') then
  71.             g.setcell(x,y,drawstate)
  72.         end
  73.         x = x+1
  74.         if x == 16 then
  75.             x = 0
  76.             y = y + 1
  77.         end
  78.     end)
  79. end
  80.  
  81. g.autoupdate(true)
  82. local sPop = 0;
  83. local h = g.hash( g.getrect() )
  84. local maxSteps = 100;
  85. while( oldH ~= h  and popsC ~=sPop)
  86. do
  87.     local pop1 = tonumber(g.getpop());
  88.     local pop2 = 0;
  89.     local pop3 = 0;
  90.     local pop4 = 0;
  91.     local pops1 = '';
  92.     local popsC = 'X';
  93.     local pops2 = '';
  94.     local pops3 = '';
  95.     local pops4 = '';
  96.     local steps = 0;
  97.     oldH = h
  98.     while( (popsC ~= pops1 and popsC ~= pops2 and popsC ~= pops3 and popsC ~= pops4) or steps < maxSteps)
  99.     do
  100.         steps = steps+1
  101.         pops4 = pops3
  102.         pops3 = pops2
  103.         pops2 = pops1
  104.         pops1 = popsC
  105.         popsC = pop4..' '..pop3..' '..pop2..' '..pop1
  106.         g.step()
  107.         pop4 = pop3
  108.         pop3 = pop2
  109.         pop2 = pop1
  110.         pop1 = tonumber(g.getpop())
  111.         if steps > maxSteps then
  112.             maxSteps = 100
  113.         end
  114.     end
  115.     h = g.hash( g.getrect() )
  116.     maxSteps = maxSteps * 2
  117.     g.note("Going for "..maxSteps.." more steps because population is static at "..popsC.. ", ok?")
  118.     sPop = popsC
  119.     h = g.hash( g.getrect() )
  120. end
  121. g.exit("Looks like the pattern isn't changing any more.")
RAW Paste Data