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

Anders Rundgren <anders.rundgren.net@gmail.com> Mon, 08 April 2024 21:54 UTC

Return-Path: <anders.rundgren.net@gmail.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 425C3C14CEE3 for <cbor@ietfa.amsl.com>; Mon, 8 Apr 2024 14:54:19 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.094
X-Spam-Level:
X-Spam-Status: No, score=-2.094 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=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
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.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 pV_VHcYUCcOy for <cbor@ietfa.amsl.com>; Mon, 8 Apr 2024 14:54:15 -0700 (PDT)
Received: from mail-oo1-xc2b.google.com (mail-oo1-xc2b.google.com [IPv6:2607:f8b0:4864:20::c2b]) (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 0F345C14F609 for <cbor@ietf.org>; Mon, 8 Apr 2024 14:54:15 -0700 (PDT)
Received: by mail-oo1-xc2b.google.com with SMTP id 006d021491bc7-5aa2a4dd0ffso657999eaf.0 for <cbor@ietf.org>; Mon, 08 Apr 2024 14:54:15 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712613254; x=1713218054; darn=ietf.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=RHnh2LWZNTUqPN3s3JaVbWC4AZ2Fu3o/0sItPAH9Fcw=; b=lvWfx6tYfsNXrwuEpPron93kzoRg+1I1pPN5oo1u6K7OgH9KJXBWggcAVu1bXWjSYZ tj5VfYfQlVIltGWJandcpha+A7rfCoFT0HqSbYuEFFRwufmpkSDU1Jkja1YxOcKQu/Up iGSq7abdJHbqBifW31MeG6Jp5AVfPl+j395kHLtBjZhM3mD3XuHxCqoTdbtvxNpUxp6y NdWl+GnVU84E6zPvNr8CsEAQNqvvZSTlOWrNjj34Jj9VKw2C2kFen7QJabNxYMicIWwv TlXnYf5Nf23ms5/3kFJ9Zsj7FYyChReAaj5FTZ443bUByIQhigPMn0YBTCcBmLJmM7QT A+KQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712613254; x=1713218054; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=RHnh2LWZNTUqPN3s3JaVbWC4AZ2Fu3o/0sItPAH9Fcw=; b=OhdWnN8QRy9aK/9qaSk+RzPyIIWqUjEzbBcm2LRx6QnShnwerZb7nvGRAeKzej0dsm 2xO3QTndzXl4ldJmkX0NluOq0pxCA63g5ePwp/LbJLFCOcudoFPrPHa6ruvvTAyIXRJY fFDBd4ymiohFBsZeVLaAHgR7KvTdgoIEovhc7frCyV+deIQpdJ/yj0V8uTGjiKBJOj5c D+Dzs+dVgrA8OhVdYRUTk2PpFqVGd50vodqOY7hjQ6EUWTDeeUaD0CPsWnWh0lZbay0b BqripRIONMQuwhrun/EkyltN6eNPKaUoekhkZlbMDHhUfuRC2snRf0VRB62halCxXlDd t3IQ==
X-Forwarded-Encrypted: i=1; AJvYcCXwd3k2hlQePD8FvJQ+YBNLZmNGAdkmIhBvN1uVnFLn0W2NMd5O0Xw06gkfyE/2NG+G1BMpch6mlSC1aXwE
X-Gm-Message-State: AOJu0YwL4IirMoLU3xuDUyAvsO9+mNw7HWHeSRe5+ZqLUeDpuix9/gZi VbHyXO/NljKJGphYYz2ahgF58zd+lYX4Nw42dt/tdmPm/TSMXad1BidQWzDIFxUu2xyqupuh/al BF1zOdiGgAEAiyhbKI+bB6qn+7JQMX69P
X-Google-Smtp-Source: AGHT+IGCGS/vg4qucdY0AmTKejerHNkA4PQPNhOsg7Q6Q0+fSGCrNS50lDOUwISu0/GUzodgOoOz8SlVfGl4iyiIXxg=
X-Received: by 2002:a05:6870:b24f:b0:22a:6a92:a83c with SMTP id b15-20020a056870b24f00b0022a6a92a83cmr407123oam.25.1712613253866; Mon, 08 Apr 2024 14:54:13 -0700 (PDT)
MIME-Version: 1.0
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>
In-Reply-To: <DFAF11BE-6D5B-404F-A0CE-0DA263835EB0@island-resort.com>
From: Anders Rundgren <anders.rundgren.net@gmail.com>
Date: Mon, 08 Apr 2024 23:54:04 +0200
Message-ID: <CADEL5zsrAYG8Pezoo_4FrHynKaHREd03mVgLWovfUTS5dPHUZQ@mail.gmail.com>
To: "lgl island-resort.com" <lgl@island-resort.com>
Cc: Carsten Bormann <cabo@tzi.org>, CBOR <cbor@ietf.org>
Content-Type: multipart/alternative; boundary="000000000000a26ae306159cd854"
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/xfQawpD7SgaczukdfIlwW5mJxOw>
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:54:19 -0000

On Mon, Apr 8, 2024, 23:29 lgl island-resort.com <lgl@island-resort.com>
wrote:

> 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?
>

https://cbor.me



> 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.
>

dCBOR only needs to specify Numeric Reduction.



> 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 spec. is as it is.



>
> 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.
>

I would strongly object to such a change.



> 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.
>

The best would be to drop dCBOR alltogether.  Gordian Envelopes work just
fine using CDE "as is".

Anders



> 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
>
>
> _______________________________________________
> CBOR mailing list
> CBOR@ietf.org
> https://www.ietf.org/mailman/listinfo/cbor
>