From 17368c8961594f53925f4034a1c17d538a56f139 Mon Sep 17 00:00:00 2001 From: Christopher Lemmer Webber Date: Sat, 17 Aug 2019 16:43:04 -0400 Subject: [PATCH] Correct total ordering and canonicalization --- TUTORIAL.org | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/TUTORIAL.org b/TUTORIAL.org index b15881a..d94df28 100644 --- a/TUTORIAL.org +++ b/TUTORIAL.org @@ -152,15 +152,22 @@ unique elements where ordering of items is unimportant. #set{flour, salt, water} #+END_SRC -** Total ordering +** Total ordering and canonicalization This is a good time to mention that even though from a semantic perspective sets and dictionaries do not carry information about the ordering of their elements (and Preserves doesn't care what order we -enter them in for our hand-written-as-text Preserves documents), when -serializing to binary data (or even when the Preserves library itself -serializes to textual data), Preserves will always write out the -elements in the same order, every time (aka, "total ordering"). +enter them in for our hand-written-as-text Preserves documents), +Preserves has a well-defined "total ordering". + +*FULL WARNING:* the following claim is not implemented yet. :) +Coming soon! + +Based on this total ordering, Preserves provides support for canonical +ordering when serializing; in this mode, Preserves will always write +out the elements in the same order, every time. +When combined with binary serialization, this is Preserves' "canonical +form". This is important and useful for many contexts, but especially for cryptographic signatures. @@ -171,13 +178,16 @@ cryptographic signatures. cat: {"noise": "meow", "eats": #set{"kibble", "cat treats", "tinned meat"}}} -@"Will always, always be written out in this order:" +@"Will always, always be written out in this order when canonicalized:" {cat: {"eats": #set{"cat treats", "kibble", "tinned meat"}, "noise": "meow"} monkey: {"eats": #set{"bananas", "berries"}, "noise": "ooh-ooh"}} #+END_SRC +This is a bit more expensive than normal serialization (because +sorting needs to occur), but is still quite fast in general. + ** Defining our own types using Records Finally, there is one more type that Preserves provides... but in a