[Cbor] Re: Illogical handling of CBOR keys
Carsten Bormann <cabo@tzi.org> Wed, 24 July 2024 20:42 UTC
Return-Path: <cabo@tzi.org>
X-Original-To: cbor@ietfa.amsl.com
Delivered-To: cbor@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 6E7ABC14F6FE for <cbor@ietfa.amsl.com>; Wed, 24 Jul 2024 13:42:02 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.907
X-Spam-Level:
X-Spam-Status: No, score=-1.907 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_DBL_BLOCKED_OPENDNS=0.001, URIBL_ZEN_BLOCKED_OPENDNS=0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hnmSZrVboCDx for <cbor@ietfa.amsl.com>; Wed, 24 Jul 2024 13:41:58 -0700 (PDT)
Received: from smtp.zfn.uni-bremen.de (smtp.zfn.uni-bremen.de [IPv6:2001:638:708:32::21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 63785C14F6FD for <cbor@ietf.org>; Wed, 24 Jul 2024 13:41:58 -0700 (PDT)
Received: from smtpclient.apple (p5089ae14.dip0.t-ipconnect.de [80.137.174.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.zfn.uni-bremen.de (Postfix) with ESMTPSA id 4WTmCS0QJZzDCbY; Wed, 24 Jul 2024 22:41:56 +0200 (CEST)
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\))
From: Carsten Bormann <cabo@tzi.org>
In-Reply-To: <6de79105-257b-4af7-aa9a-b74db488dfa1@gmail.com>
Date: Wed, 24 Jul 2024 22:41:43 +0200
Content-Transfer-Encoding: quoted-printable
Message-Id: <E1C65C14-69EC-4ED5-A645-9D701AC054BC@tzi.org>
References: <6de79105-257b-4af7-aa9a-b74db488dfa1@gmail.com>
To: Anders Rundgren <anders.rundgren.net@gmail.com>
X-Mailer: Apple Mail (2.3774.600.62)
Message-ID-Hash: HT72OW5NYRYFA5D53GSE22ZKBBSTP63A
X-Message-ID-Hash: HT72OW5NYRYFA5D53GSE22ZKBBSTP63A
X-MailFrom: cabo@tzi.org
X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-cbor.ietf.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header
CC: "cbor@ietf.org" <cbor@ietf.org>
X-Mailman-Version: 3.3.9rc4
Precedence: list
Subject: [Cbor] Re: Illogical handling of CBOR keys
List-Id: "Concise Binary Object Representation (CBOR)" <cbor.ietf.org>
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/GCMW169IqC5LozE54vYbhjtR8UY>
List-Archive: <https://mailarchive.ietf.org/arch/browse/cbor>
List-Help: <mailto:cbor-request@ietf.org?subject=help>
List-Owner: <mailto:cbor-owner@ietf.org>
List-Post: <mailto:cbor@ietf.org>
List-Subscribe: <mailto:cbor-join@ietf.org>
List-Unsubscribe: <mailto:cbor-leave@ietf.org>
Hi Anders, thanks for the detailed feedback. On 24. Jul 2024, at 21:39, Anders Rundgren <anders.rundgren.net@gmail.com> wrote: > > Related to CDE. > > https://www.rfc-editor.org/rfc/rfc8949#section-5.6 > > According to this section 0.0 and -0.0 are equivalent but only when used as keys. In CBOR, 0.0 and -0.0 cannot be both used as keys in a single valid map item. This reacts to the fact that many map implementations provided by platforms do not provide ways to do this, and requiring a CBOR implementation to provide their own map implementation sounded unreasonable. > This does not make sense in a high-level encoder/decoder design where keys are just CBOR data items: > https://cyberphone.github.io/javaapi/org/webpki/cbor/CBORMap.html#set(org.webpki.cbor.CBORObject,org.webpki.cbor.CBORObject) > Question: does CDE compliance require you to follow this rule? No, CBOR compliance requires you to follow this rule. A map with both keys -0.0 and 0.0 is not valid CBOR (we decided to make this compromise as, if it were valid, it wouldn’t be very interoperable). > According to the same section, JavaScript values 1 and 1.0 are equivalent which either imply numeric reduction or some special handling of keys. What you are alluding to here is a statement of fact about JavaScript, not about CBOR. It alerts the protocol designer to consider that implementations would likely need to do something unnatural (e.g., mapping all integers to Bigint) to support a protocol that relies on the ability to use both integer and floating point values in the same place. > In the TC 39 proposal, Do you have a TC 39 link? > keys are just CBOR data items: > https://cyberphone.github.io/CBOR.js/doc/#cbor.map.set (Wrapper objects, as you seem to call them.) That is certainly one way to handle JavaScript’s number system. Using encoded CBOR data items (byte strings) as keys in a map can also help. I’m sure Joe has a few more in mind... > Since CDE compliance requires integer and floating point values to be separated, I assume that this is not really applicable. I can’t parse this. What is “this”? Grüße, Carsten
- [Cbor] Illogical handling of CBOR keys Anders Rundgren
- [Cbor] Re: Illogical handling of CBOR keys Carsten Bormann
- [Cbor] Re: Illogical handling of CBOR keys Anders Rundgren