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

"lgl island-resort.com" <lgl@island-resort.com> Mon, 08 April 2024 21:29 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 97A8AC14F74A for <cbor@ietfa.amsl.com>; Mon, 8 Apr 2024 14:29:43 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -6.897
X-Spam-Level:
X-Spam-Status: No, score=-6.897 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001, 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 OI5L4blTD1rU for <cbor@ietfa.amsl.com>; Mon, 8 Apr 2024 14:29:39 -0700 (PDT)
Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2096.outbound.protection.outlook.com [40.107.102.96]) (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 5AF1DC14F6E1 for <cbor@ietf.org>; Mon, 8 Apr 2024 14:29:39 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wc7Rlpcy6RnS4EwE+F30Ssl9SWhUhDozoIJCObWxIYJS7KvlNJasU/eX8Iw0VX6736ipOm5F82g/3NZZnbD1w8nJWVpw40kCEHrpX26ymRL5VynVHRcmGaEyXuj51IFy0x79aTkFrYUDsae+TbaezvktGdOSUF7l8Agjl9GdisCy06EP8W50URdWsEauiRO6zYD1FTP46pYwIJVGTn9f1xkE9afNNGKMJX8Y2IIPlvA+U20Gw6VI9j9zx/fhxi/UJ87OskiXAQTroU0ew6P/W1HhLRjxOJv/0Ku9ruHGJeJU6sbCb3Xme95QVzZ61CVPYveGyDBX5N5Bv+AUKUZdag==
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=ROVLbk+s//393Gi11ZxgL3L1BGh8JJlOR+IgdQIEUCw=; b=A7EedqaDJkaajIQEd2Vjt2T8eygTGGBUJpoR8RFLTBnn9jxLzwdopbZua6YIWp9c/64fpHto/dJc2hcvpq/XAbFeO78UpjFiH6uhs1p9h7qdu4XQFes0tJZXbO7RgfdSAmCXEM8PU9WUslPJJGeu0dhhcHDbfL12mWO2kq7SpRlPTmVLfaSadA4M80OEhYKKwh6TcIvACQzOdudyTt6Ip4T8m3+/bF4xtfAcbEGfsdFw1K5GfDJZ6MnR2V+DVoF0UkWiJlSBjfeW+GhTRY2V8BXM7SHiYQSqopzjZa9KbrBdLyX3n1fTcBxoQ1J+6wCn6h2UUJ47iMc2rD7MtrRPJg==
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 SA1PR22MB4336.namprd22.prod.outlook.com (2603:10b6:806:38e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Mon, 8 Apr 2024 21:29:36 +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; Mon, 8 Apr 2024 21:29:36 +0000
From: "lgl island-resort.com" <lgl@island-resort.com>
To: Carsten Bormann <cabo@tzi.org>
CC: "cbor@ietf.org" <cbor@ietf.org>
Thread-Topic: [Cbor] 65-bit negatives, big nums conflict between CDE and dCBOR drafts?
Thread-Index: AQHah5kQOMh6PuR0JUmAokyvwEiIELFbRS2AgABAcwCAAAazAIADXCOA
Date: Mon, 08 Apr 2024 21:29:36 +0000
Message-ID: <DFAF11BE-6D5B-404F-A0CE-0DA263835EB0@island-resort.com>
References: <775D5398-1A78-4255-B337-B9B25ED03ED3@island-resort.com> <1aea13ce-9646-41cb-8f1a-5a249d08e693@gmail.com> <32A30872-2701-49E6-AAFE-4E8CC7EA4C31@island-resort.com> <D20445F4-33E9-40E6-8485-7421D7690521@tzi.org>
In-Reply-To: <D20445F4-33E9-40E6-8485-7421D7690521@tzi.org>
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_|SA1PR22MB4336:EE_
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: 7O+kXRVKlLMlrdL+zAiveHpryu2thWHhq9c8p16TL5RIdF7hdYOg2jlEDAyXPtbdbRV4zkkWEkQ8hZbsw0CjMgrXyYevo5G+4/JJS31iSpoGYFGut2aBffL0LrdcNNQ2EYPqbKtU+EKvmpkyuj0yk5ZNYEvoOItG1sU5dOOE6WvyEyCVWDhc9NCqAnvNVBM+swPF+53OJQfoWM5ZMsDpmrHVcLuJNudTI5pJ453kiQLlGkwzX9MDYsW1RqeHclE5pIyvncvt6tLnWsVdiKcvkxMdM47quNGoHexJztjaNUqyL6xxNcu83ObFWz/BAjmbuOmljWHBDsf54wmygBEu9KkjWB3CAHFznDWC2xFGXaPxmbi5tIY5Eqd++M4g1WSezr9dssJTAkhX0rN/9/VcJ9XRk0Ip/5WJig1YDDKg22/csEUQ1At64GSx5E/wFKMqQ+TMUrsFKv1LXXPSKaP+CUB/5u29uGslPODP/r8kUawHqzRm+Ty5Yyw/1hrd5THKJ0wXK8X2gRWXbfho6vYEIHGO4/v0+/1p7+BFs4j2h7mSemzCoAsfdw9cUOnbwVn+qYJgvoeRaVVf6bDFOYu15QPDf90b3skgg3U8u4BFyZU=
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)(1800799015)(376005)(366007); DIR:OUT; SFP:1102;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0: 55BGFgoSk1v5oKv5wJGevpYt/tU43EGnJrC4jaDKZEZiU3ZChhgV508wM57zabLeMQ3U4Z0nVUos0jlfgn/aJSvKhkp9i6Iu5sSDfKeUdgSkFoCtVN17b5Hjpvc7zipvkoP7CJrcxhc6qYTsVTT4QWpmcyq0Rf/jO3jtn6Gv2ryuwr/N3tVfA1LCkJ5Vm07yNoh/MG+HEOfEYVGbvuJXnx36RDJN3xd7YJkCB7vXENyY9xxxCGj1igYurutNmY8UaLV3SJG7Pwt4pb6Px2wNGV80UvjJhRmlm83QxvqvRgrfFogF7LvJ0J9E29mN2dUwLlg4T41RPVQ0kNZ0geOuc0hmzJb4cE1efLC/2LBZPDb4cM8uMIBfpC0Px4Ssv8BXJUEG5uqPgLHxSfFLoPR/Rwn/oKcNWg390QCOkooi1wM3N+1zw3LInX8LapQlth7GCSHXqQp3nDspHyDwfnlzUmKvJsvRzPamEMuWHvZfowbft3I/m0LJ+ODGSGTKqIjMeahw441Lz0HiEBkX/Kx5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Content-Type: multipart/alternative; boundary="_000_DFAF11BE6D5B404FA0CE0DA263835EB0islandresortcom_"
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: f9c1b24b-162f-4efd-1cd0-08dc5812fd3d
X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Apr 2024 21:29:36.0517 (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: bXLAveFql+fwJ88EALPn+HL5Mvs5lf+OgWjsJIIAtXXT0EjTpuQKnakoSX4GGXneO2TxxiC2+rQ/t0+jTRZjlw==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR22MB4336
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/VteX4SJVeNU4nzT2haiW_YWjXlk>
Subject: Re: [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: Mon, 08 Apr 2024 21:29:43 -0000

Right. It’s a requirement. Missed it because it is not mentioned in the section on preferred serialization and I didn’t think to grep RFC 8949 for “preferred".

(My plan is to read the cbor-diag ruby code in addition to RFC 8949 next time; have started checking other CBOR implementations; so far only cbor-diag and QCBOR implement the big number tags).


How should -2^64 be encoded in dCBOR?

Preferred serialization (both RFC 8949 and draft-ietf-cbor-cde-02) requires it to be a type 1 65-bit negative integer. This is in conflict with the prohibition of 65-bit negatives in dCBOR. It is a conflict because dCBOR requires compliance with CDE which requires compliance with preferred serialization.

Clearly the dCBOR inventors expected it would be encoded as a float.

However, I think the answer here has to be that dCBOR has to drop the prohibition of 65-bit negatives and that implementations will have to deal with the special case.

The alternative is to change the requirement in RFC 8949 with errata or a new RFC or something. The problem here is not that big. It’s just more code for a special case that some of us have to write.



The pseudo-normative rules for Preferred Serialization I previously shared need to be amended:

If big numbers (tags 2 and 3) are supported, integers that can be encoded as type 0 and 1 MUST NOT be encoded as tag 2 or 3.

If integers more negative than -2^63 are supported, then decoders MUST accept and correctly process the range [-2^64, -2^63 - 1] encoded as type 1.



A few more thoughts.

Any library that does preferred serialization and supports integers beyond -2^63 MUST send 65-bit negs. Some decoders won’t be prepared for this. QCBOR 1.x for example. But, it’s the law of the land.

It’s super easy to unify with big nums in Ruby or Python because the languages support big integers. The cbor-diag ruby code is super clean and simple.

This begs the question as to why big floats aren’t unified with regular floats in preferred serialization. Python has big floats. Ruby, however, has big decimals.

There’s no more rules for Preferred Serialization, right? Grep of RFC 8949 doesn’t turn up any.

There’s another interesting question for me — what should an implementation that supports both tag 2/3 AND dCBOR do for 2^66 and such Dunno yet.

LL





On Apr 6, 2024, at 11:10 AM, Carsten Bormann <cabo@tzi.org> wrote:

Hi Laurence,

On 6. Apr 2024, at 19:47, lgl island-resort.com <lgl@island-resort.com> wrote:


On Apr 6, 2024, at 6:56 AM, Anders Rundgren <anders.rundgren.net@gmail.com> wrote:

Although I personally don't find the CBOR int/bignum arrangement ideal, this boat has (since long) already sailed and nobody died.

It looks to me that there is a new requirement in draft-ietf-cbor-cde-02 that isn’t in RFC 7049 (canonical CBOR) or RFC 8949 (Preferred Serialization and CDE). The requirement is that no value that can fit into an int64 or uint64 can be sent as a tag 3. That implies 65-bit negatives ints must be sent.

This is not a “new requirement” [1].

[1]: https://www.rfc-editor.org/rfc/rfc8949.html#section-3.4.3

Grüße, Carsten