[Cbor] 65-bit negatives, big nums conflict between CDE and dCBOR drafts?

"lgl island-resort.com" <lgl@island-resort.com> Fri, 05 April 2024 20:37 UTC

Return-Path: <lgl@island-resort.com>
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 01150C151091 for <cbor@ietfa.amsl.com>; Fri, 5 Apr 2024 13:37:28 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.9
X-Spam-Level:
X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, HTML_MESSAGE=0.001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_PASS=-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 xyYENAm2IkYW for <cbor@ietfa.amsl.com>; Fri, 5 Apr 2024 13:37:27 -0700 (PDT)
Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2097.outbound.protection.outlook.com [40.107.95.97]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 4A66DC14CF1D for <cbor@ietf.org>; Fri, 5 Apr 2024 13:37:27 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jp4OSZ1kZmGIfVzjR9It1uzTZLR7FN1G/WPPeIoOSYdaXpnXy9B4NepQ9UEHpb5myfHZOxmmulbBQYEh5+akICsULm/6NbbNrBOFnwOKWM0E9h46XXXUtvjdpEsqSG3jNS+fRGeqwMH484psLVUDmrms4SN0nY8NWVX8LqLep06cxZh7NcmdtMPrz/nkDTysrHZkP3gb8x9jzJtODu7J1dsPVjasZqP3trnVout014A9wHzPP5uqHOMGVtA2n+p+SMApBRhChMEF1gtoKu8xE1tklJI6KSecG2TqYX7VKV//DTFOqcQBPwl7jWoz7w7lqVkCArArnHusqN8lZpOB3Q==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=FTfpM5sSRn8fZf6HkPz0X+tuXLUEb7SscYf5sCKirxs=; b=FPsZgYaxW0Tn717g25rf+4B1aakB9+ebsCX1TymdrYbBMevYHgJOCH4MAqUSzOGIpRiSi4ONH7EiCTAwGY8g4p5DDGui8+PMXG1jzOgYyP2wgUtXh3K+aWdCFnv748tDacqpWRI4BhBP1eL9Tz2rIRqy843ZiihBXUFjCFjVwK7iHjLjy5CebLpigPxCA1+rY8nrdX1XYdhqHD7iMu8DHspDhBh0Gn6G8LzJh/NiFuAfd58XtlPfuEKVZo/BOok90QWfUlLk7OOZshWzD+iazr2cRJm3mFTxNkMPUBWN0FnmyiO0dUtyl1m2iFRkYVGyQibufbIk/bfQ+NBB7/KWQQ==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=island-resort.com; dmarc=pass action=none header.from=island-resort.com; dkim=pass header.d=island-resort.com; arc=none
Received: from PH7PR22MB3092.namprd22.prod.outlook.com (2603:10b6:510:13b::8) by BY1PR22MB5682.namprd22.prod.outlook.com (2603:10b6:a03:4b9::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.47; Fri, 5 Apr 2024 20:37:23 +0000
Received: from PH7PR22MB3092.namprd22.prod.outlook.com ([fe80::1cab:7344:221c:bb8e]) by PH7PR22MB3092.namprd22.prod.outlook.com ([fe80::1cab:7344:221c:bb8e%5]) with mapi id 15.20.7409.042; Fri, 5 Apr 2024 20:37:22 +0000
From: "lgl island-resort.com" <lgl@island-resort.com>
To: "cbor@ietf.org" <cbor@ietf.org>
Thread-Topic: 65-bit negatives, big nums conflict between CDE and dCBOR drafts?
Thread-Index: AQHah5kP88K6TY6PqEeKml3voflhDA==
Date: Fri, 05 Apr 2024 20:37:22 +0000
Message-ID: <775D5398-1A78-4255-B337-B9B25ED03ED3@island-resort.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: PH7PR22MB3092:EE_|BY1PR22MB5682:EE_
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: kiv5l7AvM8/HoM5L2RlCIaA2C5OQyuu/XWKPbIfOCYuRpYEvmOD9aOwOPp3C9WDgZxOPuDYX1mNZEG8L/dl+41zWyhHAuHHzh3e0k/S5AQyWOj/30ywb3oWaNzkIZn7X7Lk92eFrJqMOEj7tQZIk5T2OHnHrq6ZpVYjNDvp95/BC9NvJGw5OhHlblVzFW8m1El48VAOUzafvAr+++UFAaiVSV+kIvu3qQzE9XufCxyxJn1nx8qGa/L2YD7a3IeLLTwA4hjKqlTg3jZI9G/C+p78LbrO27sH5zFjLBEZQ987ErmwYrWymsji69AsYszttGE5wj0js6YQOAALbgVS9S4hQXYNNc8gDOEqzrZNpcynxrKB/GAFHDXPeamlrI15KPJjFKHPWIa/8yYqX0o072FXM6togj9WS1lLLNqPDgDb4dkd7Ek1dVbrBklbhZMEt3yTqvApiXMV/mjp5+oBfAwpdyVBRfatxBDoViueqnlgSJUAhfEXOj4C49vtWX7dL1V4l9GoZM7IgHBk+mz+3dGYsthUVOs/evS659S/c7qcvb8YIZdEW7vSEW8sBff9t9jaaFHwu2X8M3RtULhnFLXIyIVLVMw77pouXYp1jWCJC74lYxus/EJvSAW++j2Uzf84AU6eZM2AAUSb5WrXb0rQWXzkt2k6vNEGP1WGgA98=
x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH7PR22MB3092.namprd22.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366007)(1800799015)(376005); DIR:OUT; SFP:1102;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0: TZ1nC9Jo+wMW7ZGZZFGbkGXNQyuyPO2mdgXw13X9YXEeZD1kbbUVaL/i8yJTPP7KQLW425wQw37KIK1b35lxFB/cIh4x2lupUSCzhD1n/SJCvDc9gEpIEk5wVzD0+WqdVqRBs2GdoXjVaKam/Xxu5vQ22ovFnfm+1utFMnU3TaCuZ5TJBWuC+fKRWIyIN+AfBtOy+CckAqSvr3igvu/Ha+eDRyo53Q6+mI5Gx5aTXsma3DmaG67Y364rdMGEemVCg8FHV38KBZFehucXf1nm3M9Urx5mppb9qzCDwG3qDg54PWHuTD2yxTbBqoMEhlv62797cbCfmpdiS4RipmpK6UFoEEJANtToDGwEWFc4S34o/IfZBsOmi7Yh1KaWPGYD1QBTX/roriGB5SrgBKHS7UE0BBCuuQFteTADsA+yrVSU4HUYizU7IgVZka0xfs5jaJFgMiDjKauMSQl2T8ceuHt4gYpyD5Hg7+g3p7Gd+p6pHcPypF+wbDXIaO+ZMeyBHP57uCfB8RMLX2hMfEuo1OiKXISa0B+L1+l7lkoYNku5qLHEaoHgEGjAmjWv9TuNkU7dYzKLZ3dGpl2KxuOONIgH5uAHtucc7EPLviBcax6Ih6223bbEbOO47Z7inCSgRZ4aVmpi2oEJmYDsmz4xrURHi+y6LDSkryPVyeNJcZ2M9gz7BNNfwEpV7zjA4QDT3bvbDoZJXOPHxXqAzEorQWiZcUEHAkjp9+AVufGDlH6JzzuidLWLy79hmOriLSaUUxgWRmwuFZ+5AS6sronxGLSXjqnF2sxo0B1jIo1laAh5VT91auFzLiXLn5SHIHNkWOAfP4V3rNY8bLRItra+I3ypbuk8d7PVHgKW4SuZBsnFT5WhrPVPOocC1TA1w7sP9IASIxyzVSu5Se97d/OQxPH6UuBa3Ec4LAUk2u+7WWjj7jKXREXqv9X13jLzS2qN71ZFzVmVn+LU0Mp6BPaQoIeXXgZXBi/RpezvyIQ66aXF5YrBetGVjN27EaxqLQ0OpmAvzsf298mAk8+ccZml529ojVLsT8QXxDTk3kfI9jllBHX1IpdEq6W9V2YVFdHrQ+yKGT93VuypIciJ9Rz/DrMTHc8EBz7Hoav0FB5jZ5L7l6Yh5jpLGnjvocF2VtPNYpm7mG07WKAP/agwotQ3XxrXAXsdZhkp7NocTDX3KBSREez2/BUet958mISvEetgVTqj6OeNus0Xg3IoR8lQVwwd6KtqGPpM3efAFAhN0uiBHvu1HsqyWG0jynOEF3Agvou09l4UWYPkl23u5Uxh84y+9Ef8o3t5jDjqdYHZO6wUzKD+GERskqhRJzjM0U/Ob6o4i0nSZYsQjuqLeyaNUV0EKwRbev7McolniCDnOkRzc2+CCnsrWoBzdnvRPfeaXPOgRiMQxZ2wdDBW2aaQarY3n7J8eStiGpuC7JVZFns8VitlRGL6TVjym19yj1eANVieT6H2BrN5BCowWc0SuyDZ2dYPgaoLzzqxYoes6c+20pZvfLOwVC8ESQx1vxcNysBJvAvsklTATEXgx2gCtT0MFg1gWomNwh9DfyucyVotuYYgP1JjYssd2ir4z38pWviXKkx1K/aXCiBcOA7bqQ==
Content-Type: multipart/alternative; boundary="_000_775D53981A784255B337B9B25ED03ED3islandresortcom_"
MIME-Version: 1.0
X-OriginatorOrg: island-resort.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: PH7PR22MB3092.namprd22.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: f2e6cd4e-eaf8-41cc-d8d1-08dc55b03272
X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Apr 2024 20:37:22.8277 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: ad4b5b91-a549-4435-8c42-a30bf94d14a8
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: zTnsoL3t1u6OpRjVIq/pr9bpylzyX8ZuHmGEUXLxnFC7lHNiZpn7dxALWJmysi97iYp2UvNhgBc3nfcfHbypTA==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR22MB5682
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/LXZORx6Q-KgzChTeZbQD94bYmOI>
Subject: [Cbor] 65-bit negatives, big nums conflict between CDE and dCBOR drafts?
X-BeenThere: cbor@ietf.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: "Concise Binary Object Representation \(CBOR\)" <cbor.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/cbor>, <mailto:cbor-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/cbor/>
List-Post: <mailto:cbor@ietf.org>
List-Help: <mailto:cbor-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/cbor>, <mailto:cbor-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 05 Apr 2024 20:37:28 -0000

draft-ietf-cbor-cde-02 says:

1. The CBOR Common Deterministic Encoding Profile (CDE) turns this recommendation into a mandate: Integers that can be represented by basic major type 0 and 1 are encoded using the deterministic encoding defined for them, and integers outside this range are encoded using the preferred serialization (Section 3.4.3 of RFC 8949 [STD94]) of tag 2 and 3 (i.e., no leading zero bytes).

There’s no MUST, but it looks to me like CDE requires:
 - type 1 must be used for the 65-bit negative integers range
 - tag 2 and 3 must be used for integer values outside of type 0 and 1

That makes it clear that tag 3 can never be used for 65-bit negative range integers. One could also infer that 2^66 and such must be encoded as a big number, never a float. That is probably not what is intended, though.

Floats aside, CDE is still unifying the integer number space between type 0 and 1 with tag 2 and 3 for the sake of determinism. It is allowing only one representation of all the integer values. It’s a bit like dCBOR's unification of integer and float number spaces.

Is that really what we want to do? It seems simpler not to, but if there are clear use cases, maybe it is a good thing.


On to dCBOR. To comply with CDE, you must either 1) implement 65-bit negative type 1 or 2) declare non-support of that range of negative integers.

It’s pretty clearly that dCBOR does not want to declare non-support of that range of negative integers, so 65-bit negative type 1 integers must be supported. However dCBOR disallows them (and dCBOR requires compliance with CDE) so there is a conflict between the two documents now.

Further, if tag 2 & 3 must be used rather than floats for 2^66 and such, there’s another conflict.


Seems to me we should figure out what CDE should do here first. Figure out whether there is integer number unification or not. If not, then dCBOR is fine as is. If there is integer unification, then dCBOR has to allow 65-bit negatives.

If integer unification is to be required, then CDE implementations have two choices:

1) Avoid it by declaring non-support of integers outside of int64_t/uint64_t.
2) Do the unification work.

The unification work isn’t a lot of code, but does need some thought. Also, with the current text, I think implementors may not realize it needs to be done.

Also, I suspect some non-CDE decoders that support big numbers might be surprised when 65-bit negative type 1 integers arrive. Those reaching for CDE to have better interoperability might not always get what they want.

Wait, there’s more…

We could do integer unification of the number space by requiring the 65-bit negative integer range always be encoded as a tag 3 big number, never as type 1. That is, disallow 65-bit negative type 1 like dCBOR. If we say that those values must be tag 3, then we’re not limiting the data model. And what’s the data model for -2^66? You have to do use tag 3 for it.

LL