Distributed ESON

I’ve been reading through the Telehash spec and the updated spec. I’ve been contemplating a similar network built on KadOH.

One of the first things I’m changing is that instead of JSON the values returned from hash values are ESON. An ESON object is returned by the function:

return eval( "( function() { return " + eson + " } )()" )

JSON is a subset of ESON. One thing that ESON will allow us to do is give literals valid positions in the distributed object.

Imagine, there is a DHT in place such that an ESON object can be retrieved with a key.

Objects are stored by decomposing them into nodes in a hash tree. For example, starting with the object:

{
  foo : { bar : 'baz' },
  x : 'y',
  abc : [ 1, 2, 'f' ],
}

First insert the non-array / non-object values into the DHT:

{
  foo : { bar : 'baz' },
  x : 'y',
  abc : [ 1, 2, 'f' ],
}
  • 'baz' → 7008a69f99f290ca687ddd752e016517b339c958
  • 'y' → 4da61411af38bbbcc58d67e46682f890fc8c9ceb
  • 1 → 356a192b7913b04c54574d18c28d46e6395428ab
  • 2 → da4b9237bacccdf19c0760cab7aec4a8359010b0
  • 'f' → 5e526cc14a935fc1a1b4179472a788b89dda5cb6

Next create objects where the values are replaced by their hashes (the values are shortened for readability):

{
  foo : { bar : '7008a69f' },
  x : '4da61411',
  abc : [ '356a192b', 'da4b9237', '5e526cc1' ],
}

An object/array is complete if it doesn’t have any objects as values:

  • { bar : '7008a69f' }
  • [ '356a192b', 'da4b9237', '5e526cc1' ]

Next insert the JSON representations of those objects into the DHT:

  • { "bar" : "7008a69f" } → e74d732ade880c70eae4100a336c127974198572
  • [ "356a192b", "da4b9237", "5e526cc1" ] → ca89648739400617740cb11cf369e602fc161191

Then replace those objects with their hash values in the original object:

{
  foo : 'e74d732a',
  x : '4da61411',
  abc : 'ca896487',
}

And one final round of hashing to get the root key:

{ "foo" : "e74d732a", "x" : "4da61411", "abc" : "ca896487" } → 0f5ccdb211adaba64c4a8ceb86c92475ec730ba5

The object can be represented as a graph:

When reconstructing an object, the values of arrays and objects are always looked up in the DHT.

Leave a Reply

Your email address will not be published. Required fields are marked *