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

Wolf McNally <wolf@wolfmcnally.com> Thu, 11 April 2024 02:49 UTC

Return-Path: <wolf@wolfmcnally.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 DDE7CC14F6A5 for <cbor@ietfa.amsl.com>; Wed, 10 Apr 2024 19:49:23 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.894
X-Spam-Level:
X-Spam-Status: No, score=-1.894 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, URIBL_DBL_BLOCKED_OPENDNS=0.001, URIBL_ZEN_BLOCKED_OPENDNS=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=wolfmcnally-com.20230601.gappssmtp.com
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 1EUTK2AwFz3F for <cbor@ietfa.amsl.com>; Wed, 10 Apr 2024 19:49:19 -0700 (PDT)
Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 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 F0523C14F61A for <cbor@ietf.org>; Wed, 10 Apr 2024 19:49:19 -0700 (PDT)
Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1e3f17c6491so36436695ad.2 for <cbor@ietf.org>; Wed, 10 Apr 2024 19:49:19 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wolfmcnally-com.20230601.gappssmtp.com; s=20230601; t=1712803759; x=1713408559; darn=ietf.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=UC9+OdmjY+J1uB+54y6iv8Gxpvw/SgiNmEREN0H7tOA=; b=JAiD/dzKx+ciWhWAtdhCHxdaHi2FR6IUP1c7yE4XH1oIEB2tLI9Y30zsx5Af4vcPlD vcgILl1VEG5tZM3Nm6+9R5jkQmJfxspFWK3t0VitLWwLIxNzFCJgwd/HuL8GVrNeTzs3 CdLB4dTby3bmMTSbxxoFsa8M3mv+wWgKpwrRAG5vmW6CLhtybqvyN8/zWknfElaTHrCr 8U0rabzl9ZSFqGHK1WPXR509SlG8RSvGEo8/9utbOFndvEi7xXbHz8vAQrBye6ifxmc3 v+VhX2gXq89cdpXEe3bYannNe9Lp/JX2JZlmXZbuyzPbXg2hYbequdaFelcRmSV3JHsm b4bA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712803759; x=1713408559; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UC9+OdmjY+J1uB+54y6iv8Gxpvw/SgiNmEREN0H7tOA=; b=bXmsvj9A8B3GxcgorGz1OSBFT4G6aEbO8SGvG1LrtLg0WVxslmyT4w9cVOoKQux/Pv SzJ6ChTtszIpHD/iBP2AeYWuXJPAp0je1x8gXLHlCCPacPtrFij7EuDP3tyau6cs6gwZ hL/KlOEMBE5BrRanRYu67Z0s41iA3mRki2P4KXzaBA3YVodgBnNVHKl0NufuK0d8hdb+ eXxLSW2cDWiTUThPjU8Ar+U7WSFa587+RDDalKthplHF1cGYsZcIDgD6tW5sxQ6w4Jlj pteTVI2fgHs53LgDoj99gGqaVfYR/vu6YVdWvgqhCMXmhU+Xp8PNBo3igf4Q/hxT0iCH 4D3A==
X-Forwarded-Encrypted: i=1; AJvYcCXim2qmMqMzTqguBQFkQzDQS5i5ebCOXp29tINwoiQiKlqGRzKKezDzcEKOs1VDo+WsJCrC/XU6inIBvkfV
X-Gm-Message-State: AOJu0YzKInUDHjoTYl3WzBRoRcNJtamT0BPtP0q2h5UIUrqWY9EZ5a2s AOAVPVIZMhHKOW1EJbNgbAFY47HnuLJVhtQTFSNqXiyPO2hfJMHdeIxDK9kzV5QUeFJygC+5jxo 2tJA=
X-Google-Smtp-Source: AGHT+IFQBIu/y0LPK/nmNFsglCVFM6OTZCwcUgOuntbyyFx9oD0LhMAKHVMtXAu/pIu+L3ejx1gUWQ==
X-Received: by 2002:a17:903:230d:b0:1e3:e563:57ed with SMTP id d13-20020a170903230d00b001e3e56357edmr6033079plh.36.1712803758983; Wed, 10 Apr 2024 19:49:18 -0700 (PDT)
Received: from smtpclient.apple ([91.196.220.108]) by smtp.gmail.com with ESMTPSA id y8-20020a170902d64800b001db37fd26bcsm261466plh.116.2024.04.10.19.49.18 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2024 19:49:18 -0700 (PDT)
From: Wolf McNally <wolf@wolfmcnally.com>
Message-Id: <7B0A1950-57B1-4403-91CD-D62A744C164A@wolfmcnally.com>
Content-Type: multipart/alternative; boundary="Apple-Mail=_4F6361C9-6CB2-4BC7-9C70-9FEB01BB1CEC"
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.500.171.1.1\))
Date: Wed, 10 Apr 2024 19:49:07 -0700
In-Reply-To: <6D227DA9-0275-4C14-A771-A1F374958442@island-resort.com>
Cc: Carsten Bormann <cabo@tzi.org>, "cbor@ietf.org" <cbor@ietf.org>, Christopher Allen <christophera@lifewithalacrity.com>, Shannon Appelcline <shannon.appelcline@gmail.com>
To: "lgl island-resort.com" <lgl@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> <DFAF11BE-6D5B-404F-A0CE-0DA263835EB0@island-resort.com> <41F8F4E2-9C51-4D83-B698-C47B75876E8C@wolfmcnally.com> <6D227DA9-0275-4C14-A771-A1F374958442@island-resort.com>
X-Mailer: Apple Mail (2.3774.500.171.1.1)
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/9lEL_7fjkgUPKTmIOn3QCT88uJQ>
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: Thu, 11 Apr 2024 02:49:23 -0000

LL,

> On Apr 10, 2024, at 6:56 PM, lgl island-resort.com <lgl@island-resort.com> wrote:
>> On Apr 10, 2024, at 12:29 AM, Wolf McNally <wolf@wolfmcnally.com> wrote:
>> 
>> Further, it was never our expectation that -2^64 would be encoded as a float, and in fact we deliberately set no such expectations.
> 
> It seems so by implication. The choices are float, type 1 or tag 3. It couldn’t be type 1 because of (former) prohibition of 65-bit negatives. It couldn’t be tag 3 because that’s not part of dCBOR.

Indeed. And now as of I-D 09, the prohibition is indeed “former."

>> So if dCBOR’s current proscription of type 1 negative 65-bit integers indeed conflicts with this, then it must go. Obviously, this leaves a dangling range of basic integers expressible in dCBOR that are not expressible in either signed or unsigned 64-bit machine integers and which dCBOR (indeed all CBOR) implementations that do not support wider integers will have to reject.
> 
> A lot of basic decoders like tinyCBOR return the type and the value, so they’ll return “type 1” and a “uint64”. It’s up to the app to figure out what to do next for this range of values. Apps can error out, invoke a big number library, manually handle it or maybe they don’t have to do anything put print it out or translate it to JSON.

Generally, our implementations keep an internal CBOR representation, and our API allows direct interrogation of that representation if you want to know it, or they just let you specify an extraction type, and if the stored type can be converted to the extraction type with no loss, then it’s simply returned as that type. If loss would be incurred in extraction, then the API refuses.

> Protocols that want to clearly and specifically spare the native code implementer trouble can do this in CDDL:
> 
>    xxx = int .gt -9223372036854775809
> 
> Might even be considered good CDDL hygiene to constrain the ranges of integers in a protocols.

I agree that is a best practice.

~ Wolf