Re: [Cbor] Announcement: draft-mcnally-deterministic-cbor-03

Wolf McNally <wolf@wolfmcnally.com> Mon, 07 August 2023 20:22 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 B7A99C151073 for <cbor@ietfa.amsl.com>; Mon, 7 Aug 2023 13:22:17 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.904
X-Spam-Level:
X-Spam-Status: No, score=-1.904 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, T_SCC_BODY_TEXT_LINE=-0.01, 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.20221208.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 TkVKTOIZ9IaU for <cbor@ietfa.amsl.com>; Mon, 7 Aug 2023 13:22:13 -0700 (PDT)
Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) (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 99620C151081 for <cbor@ietf.org>; Mon, 7 Aug 2023 13:21:59 -0700 (PDT)
Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-686f25d045cso3489063b3a.0 for <cbor@ietf.org>; Mon, 07 Aug 2023 13:21:59 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wolfmcnally-com.20221208.gappssmtp.com; s=20221208; t=1691439719; x=1692044519; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=Nyb2AwJlgGltYUQ4iUt0xF8p8UlhwEz7mB9LeaNb+zg=; b=jJN/TfCAhAuwI03mwRSq0qQ9H2FNxW0M3f8osQP8fGY2+6nYmDqWRIf+0mhukbvqfF 6Nd54tT53nws97Ug6SAov1qPd8+QrF2ICpLc/ulgLjxTLZ2Ou61JhzWE2Phd5cR63aDN aj61+kOBnwC4Rv+a5y+CJrf+pYGyJuUS7zuZV/mfaiotWgfW3XB/stVzyFCswOJH6TAr zOmldS0xOE5eJLUu7wlx5AuFv4zMp8eOtY44a46Q4Lnzm+jfnsQCIrEsk1QMJq8E//0c efL7qaERvvrNnV4HThuV7IWyzT1w0KwaLUAgAKP75HcNtFY2fBxHFuvTI1PKR+X1GwOy 6zfg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691439719; x=1692044519; 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=Nyb2AwJlgGltYUQ4iUt0xF8p8UlhwEz7mB9LeaNb+zg=; b=ColbvtQPBHvRNxvW3qfhu5x5Myeg7uFzoCepGhUlNSNYgkAAynXU13H02L824MLS9q Nlqa1KFOn8Hc5lCAubShkrMftv70cpL/hQ2/j0NplHuJPOy+EiatuIvwTkZk7DEMpcKk Aa55yj9Jt9kYzLz/YQosDwFUpfRH8UP6tdxXczlcVbCyw8b1yMA6dI20RZoqIE41NTnl D69+CUZUQ+en/nbdwmuyStRd9p5PJ2b6o9qNRMn517VimQQRWfP5qKHmzQHN+2eCmNvI uSDNG8RmHPwhJCV8TZwsBia/P0r1JjnLbW++yXKuFAZ+RR9fbIeqM9lb4M4xu7dzg4tx udNA==
X-Gm-Message-State: AOJu0Yy1DnKyzLuvBpM6wtScnIc79dH3W7GMFJJuADSQ3jBRHCxectfM 8fQ4h6+ZaXXRML+3JawDfvW6cA==
X-Google-Smtp-Source: AGHT+IEJE5587vckk4wc2P+iQOJQSRgGullbVhN31LXy0/TOzrc8O9MQ86mFnncbXdvtXAUi/j6zNw==
X-Received: by 2002:a05:6a20:948f:b0:132:965d:5323 with SMTP id hs15-20020a056a20948f00b00132965d5323mr8488771pzb.33.1691439718941; Mon, 07 Aug 2023 13:21:58 -0700 (PDT)
Received: from smtpclient.apple (ip70-180-193-108.lv.lv.cox.net. [70.180.193.108]) by smtp.gmail.com with ESMTPSA id 18-20020a631252000000b0056428865aadsm5162720pgs.82.2023.08.07.13.21.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2023 13:21:58 -0700 (PDT)
From: Wolf McNally <wolf@wolfmcnally.com>
Message-Id: <CFBE7F50-E83C-4D4C-B8F2-588D2DF97029@wolfmcnally.com>
Content-Type: multipart/alternative; boundary="Apple-Mail=_E6EAA0D3-1788-47EC-98E2-466C1915DDFA"
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\))
Date: Mon, 07 Aug 2023 13:21:46 -0700
In-Reply-To: <D447189D-D994-4845-BA8E-752AABC9274B@tzi.org>
Cc: cbor@ietf.org, Carsten Bormann <cabo@tzi.org>
To: Joe Hildebrand <hildjj@cursive.net>
References: <169130970676.57946.2391787665439799751@ietfa.amsl.com> <E0D91ECB-F88B-4A38-A4BC-9CBCD488E475@wolfmcnally.com> <4CF6297F-5873-4245-939B-D2665F000B10@cursive.net> <D1E26143-3328-4A28-80CA-2D7E040FE25B@cursive.net> <D447189D-D994-4845-BA8E-752AABC9274B@tzi.org>
X-Mailer: Apple Mail (2.3731.700.6)
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/MZavHamd0Le9sw5O8cnm14cAXZI>
Subject: Re: [Cbor] Announcement: draft-mcnally-deterministic-cbor-03
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, 07 Aug 2023 20:22:17 -0000

Joe,

Carsten’s explanation comports with my understanding, and is reflected in RFC 8949 §4.2.1 on determinism where it says, "Preferred serialization MUST be used. In particular, this means that arguments (see Section 3) for integers, lengths in major types 2 through 5, and tags MUST be as short as possible…”

This is reiterated in the dCBOR I-D §2.1: "dCBOR encoders … MUST encode variable-length integers using the shortest form possible.” The I-D also extends this with an explicit validation requirement: "In addition, dCBOR decoders … MUST reject any variable length integers that are not encoded in the shortest form possible."

https://www.ietf.org/archive/id/draft-mcnally-deterministic-cbor-04.html#section-2.1-3.1

~ Wolf

> On Aug 7, 2023, at 9:12 AM, Carsten Bormann <cabo@tzi.org> wrote:
> 
> On 2023-08-07, at 18:00, Joe Hildebrand <hildjj@cursive.net> wrote:
>> 
>> One more thing, there may need to be another note that says that the integer descriptors for complex types (array, map, tag, byte string, utf8 string) MUST follow the rules for mt 0/1.  It's implied strongly and probably difficult to implement any other way, but 
>> might be worth mentioning.
> 
> Hi Joe,
> 
> descriptor is not a word we use in RFC 8949.
> We have something that is used with all of these, which is by definition an unsigned integer: The argument [1].
> 
> The argument can represent any integral number between 0 and 2**64-1.
> 
> The argument is directly used as the mt0 value (the mt1 value is -argument-1, or, in C integer arithmetic, ~argument).  For mt2 and mt3, the argument gives the length of the string in bytes.  For mt4, the number of elements in the array.  mt5, number of pairs in the map.  mt6, the tag number.  mt7 is a bit more complicated.
> 
> So, by definition, the argument already behaves like an mt0, because mt0 is defined by the argument...
> 
> Grüße, Carsten
> 
> [1]: https://www.rfc-editor.org/rfc/rfc8949.html#name-specification-of-the-cbor-e
>