Re: [jose] Performance of Canonical JSON

Anders Rundgren <anders.rundgren.net@gmail.com> Sun, 09 December 2018 10:22 UTC

Return-Path: <anders.rundgren.net@gmail.com>
X-Original-To: jose@ietfa.amsl.com
Delivered-To: jose@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 8AD6C126DBF for <jose@ietfa.amsl.com>; Sun, 9 Dec 2018 02:22:16 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2
X-Spam-Level:
X-Spam-Status: No, score=-2 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com
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 NzmRg9PZ8ANi for <jose@ietfa.amsl.com>; Sun, 9 Dec 2018 02:22:14 -0800 (PST)
Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 1DA0E12426A for <jose@ietf.org>; Sun, 9 Dec 2018 02:22:14 -0800 (PST)
Received: by mail-wm1-x331.google.com with SMTP id n190so8183464wmd.0 for <jose@ietf.org>; Sun, 09 Dec 2018 02:22:14 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=OtyDiD3QpcrQoRsVmxuuGshQ0lVayoRmI2wUF74cXSs=; b=TpA5p1NtEaWvDgupoU2TkZ+KtGRQZoSe2z4su2YtJVFnqoWoXy4DpFqtsVgyr9IMjJ GTOXp9+3lA2hVJWAesreHCoXnTp954DCf857X6PJht1zqF+yPhzMrQ+WIpLxJEoxmxjC QABJTpycOoqiPAPYYvCBbrZZVH9rChDpK1j17YFHKxQJy5jWP9sai/+SSktxa1P5YV+w jL5pufWx0nmzS2dpFsL82gfCXbaxSFWt7CQqFzjE6pdmkZnKXNPfwybIt7/KpSfCsBcB fdpp9Xr6wmzsnhMUHMGP7pay/Eo9XyOIvUinnwd/LbPb4j3I+nbNvf9fGbi2ye5JMnsD 49Yw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=OtyDiD3QpcrQoRsVmxuuGshQ0lVayoRmI2wUF74cXSs=; b=BUpP0yyKcxmfi9rwMa1kZ48WYkA9wbWSm0QkE7tElaDGlRqOAEwe4CryA93y6rLAVZ 5rR7nPs09KFuhdsGzDnLbpNJC9N5OrByM8BEkS7OqwO6BSbBRaseqJzQ3SQsIZj/WFCH 9rL9RTS/ouZ86uSEqXFD9b5Es1G7u7vk7NQZvhIMnPC1FrEr0tMppGdnd9M2LSzK8tM0 /IC1inR/CyNltAIJVCsbhtLCHVCf0ybq2ZDcaXNqKMbXYkRk53wkfyYl3GkOO4+gyuT+ nCpUhia2Zie3Tl0K4kPCL5+e28ma/Dx0QclSrTu2uA4LrYzZPbeuPE3LvxcbSMQRT1jX vs2A==
X-Gm-Message-State: AA+aEWajXxVKwTJbDFVO/kokT2vsVeoaH9MrgeK1addQTaZqHYspoGQJ xYG0d6baBSVhpSTNxehW+NElN2Oq
X-Google-Smtp-Source: AFSGD/Vva6LW4QnJwRthTKrixi4auoyBbo5UtZrrkCFNbmcm7Cj6a13LMQ2UPBjmhmMZ3/BX8fDCaA==
X-Received: by 2002:a7b:cd85:: with SMTP id y5mr6805957wmj.129.1544350931763; Sun, 09 Dec 2018 02:22:11 -0800 (PST)
Received: from [192.168.1.79] (25.131.146.77.rev.sfr.net. [77.146.131.25]) by smtp.googlemail.com with ESMTPSA id s1sm10364666wro.9.2018.12.09.02.22.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Dec 2018 02:22:10 -0800 (PST)
To: Bret Jordan <jordan.ietf@gmail.com>
Cc: "jose@ietf.org" <jose@ietf.org>
References: <3466a48c-115d-3810-4c94-0e213ba407fd@gmail.com> <3386D76C-D8FA-43CA-9B4A-B171C6B61267@gmail.com>
From: Anders Rundgren <anders.rundgren.net@gmail.com>
Message-ID: <2121e4c8-2abd-4478-98b6-a2b3a7029bbc@gmail.com>
Date: Sun, 9 Dec 2018 11:22:07 +0100
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.3.3
MIME-Version: 1.0
In-Reply-To: <3386D76C-D8FA-43CA-9B4A-B171C6B61267@gmail.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
Archived-At: <https://mailarchive.ietf.org/arch/msg/jose/alVqg1qf_6OtYX2thaYfIVyxy7s>
Subject: Re: [jose] Performance of Canonical JSON
X-BeenThere: jose@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Javascript Object Signing and Encryption <jose.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/jose>, <mailto:jose-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/jose/>
List-Post: <mailto:jose@ietf.org>
List-Help: <mailto:jose-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/jose>, <mailto:jose-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sun, 09 Dec 2018 10:22:16 -0000

On 2018-12-07 19:25, Bret Jordan wrote:
> Thanks for the test data. Are you going to request a side meeting for Prague?

That's a good question. Since few have read the existing (somewhat constrained), serialization-only proposal [1], I'm considering other alternatives [4,5]

As you know REST [2] is currently held as the only "real" way architecting Web applications.  In spite of that, there is no standard for signing REST requests but signed REST requests are still used in the wild including by Amazon [3].

A rebooted JSON WG would likely settle on a full-fledged counterpart to XML's "CN14" which I have no interest in because it presumes that the canonicalization process is schema driven for both parsing and serialization, making deployment much more complex.

Anyway, IF there actually is GENUINE interest in a BoF session in Prague, could you guys on the list indicate your interest?

Thanx,
Anders

1] https://tools.ietf.org/html/draft-rundgren-json-canonicalization-scheme-01

2] https://en.wikipedia.org/wiki/Representational_state_transfer

3] https://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html

4] https://www.rfc-editor.org/about/independent/

5] Ignoring the standards process and rather let associated applications like https://cyberphone.github.io/doc/two-visions-4-mobile-payments.pdf set a de-facto standard.



> 
> Bret
> 
> Sent from my Commodore 128D
> 
> PGP Fingerprint: 63B4 FC53 680A 6B7D 1447  F2C0 74F8 ACAE 7415 0050
> 
> On Dec 7, 2018, at 9:23 AM, Anders Rundgren <anders.rundgren.net@gmail.com <mailto:anders.rundgren.net@gmail.com>> wrote:
> 
>> Since XML Canonicalization has a reputation of not only being brittle but also terribly slow, I tested JCS [1] with the following JSON file:
>> {
>>   "1": {"f": {"f": "hi","F": 5} ,"\n": 56.0},
>>   "10": { },
>>   "": "empty",
>>   "a": { },
>>   "111": [ {"e": "yes","E": "no" } ],
>>   "A": { }
>> }
>>
>> Expected output: {"":"empty","1":{"\n":56,"f":{"F":5,"f":"hi"}},"10":{},"111":[{"E":"no","e":"yes"}],"A":{},"a":{}}
>>
>> Since JCS only is a serialization concept (parsing is unaffected), I compared the execution speed of standard serialization versus canonicalized serialization.
>>
>> Using https://www.npmjs.com/package/canonicalize the performance penalty was about 2.4 compared to JSON.stringify().
>> Using my homegrown JSON tools written in Java having an integrated "canonicalize" serializer option the performance penalty was about 1.4
>>
>> Anders
>>
>> 1] https://tools.ietf.org/html/draft-rundgren-json-canonicalization-scheme-01
>>
>> _______________________________________________
>> jose mailing list
>> jose@ietf.org <mailto:jose@ietf.org>
>> https://www.ietf.org/mailman/listinfo/jose