Re: [Json] [jose] EcmaScript V6 - Defined Property Order

John Cowan <cowan@mercury.ccil.org> Sun, 25 October 2015 23:25 UTC

Return-Path: <cowan@ccil.org>
X-Original-To: json@ietfa.amsl.com
Delivered-To: json@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 721FE1B335D for <json@ietfa.amsl.com>; Sun, 25 Oct 2015 16:25:38 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: 0.689
X-Spam-Level:
X-Spam-Status: No, score=0.689 tagged_above=-999 required=5 tests=[BAYES_50=0.8, J_CHICKENPOX_35=0.6, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=ham
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uKF0x43fztQV for <json@ietfa.amsl.com>; Sun, 25 Oct 2015 16:25:37 -0700 (PDT)
Received: from earth.ccil.org (earth.ccil.org [192.190.237.11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 0B3251B335B for <json@ietf.org>; Sun, 25 Oct 2015 16:25:37 -0700 (PDT)
Received: from cowan by earth.ccil.org with local (Exim 4.72) (envelope-from <cowan@ccil.org>) id 1ZqUfK-0005QJ-VL; Sun, 25 Oct 2015 19:25:31 -0400
Date: Sun, 25 Oct 2015 19:25:30 -0400
From: John Cowan <cowan@mercury.ccil.org>
To: "Manger, James" <James.H.Manger@team.telstra.com>
Message-ID: <20151025232530.GK22559@mercury.ccil.org>
References: <562C9C1F.6020507@gmail.com> <562CF614.4020200@gmail.com> <255B9BB34FB7D647A506DC292726F6E13BB107BC65@WSMSG3153V.srv.dir.telstra.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: inline
In-Reply-To: <255B9BB34FB7D647A506DC292726F6E13BB107BC65@WSMSG3153V.srv.dir.telstra.com>
User-Agent: Mutt/1.5.20 (2009-06-14)
Sender: John Cowan <cowan@ccil.org>
Archived-At: <http://mailarchive.ietf.org/arch/msg/json/dad3K8um50lEGyDqZu3svEMm66A>
Cc: "json@ietf.org" <json@ietf.org>, Anders Rundgren <anders.rundgren.net@gmail.com>
Subject: Re: [Json] [jose] EcmaScript V6 - Defined Property Order
X-BeenThere: json@ietf.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: "JavaScript Object Notation \(JSON\) WG mailing list" <json.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/json>, <mailto:json-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/json/>
List-Post: <mailto:json@ietf.org>
List-Help: <mailto:json-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/json>, <mailto:json-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sun, 25 Oct 2015 23:25:38 -0000

Manger, James scripsit:

> However, EcmaScript's ToString(number) doesn't quite give a canonical
> form. 7.1.12.1 step 5 says "the least significant digit of s is
> not necessarily uniquely determined by these criteria". EcmaScript
> guarantees that ToNumber(ToString(x)) gives the same number x, but that
> is not quite what we need for signing. We need ToString(ToNumber(s))
> to give the same string.

The Scheme community has for many years prescribed the use of read and
print (i.e. decimal-to-binary and binary-to-decimal) algorithms that
are fully accurate.  They are also slow, but for the limited purpose
of canonicalization, they might be employed.  A summary can be found
at <http://people.csail.mit.edu/jaffer/III/EZFPRW>, with links to the
original papers.

> I guess you could sign the 8 bytes of a 64-bit float, instead of the
> JSON decimal digits.

That would be hard to do in JavaScript.

-- 
John Cowan          http://www.ccil.org/~cowan        cowan@ccil.org
   There was an old man                Said with a laugh, "I
     From Peru, whose lim'ricks all      Cut them in half, the pay is
       Look'd like haiku.  He              Much better for two."
                                             --Emmet O'Brien