Re: [COSE] [Rats] RAM requirements for COSE/CWT

Anders Rundgren <anders.rundgren.net@gmail.com> Wed, 02 March 2022 04:45 UTC

Return-Path: <anders.rundgren.net@gmail.com>
X-Original-To: cose@ietfa.amsl.com
Delivered-To: cose@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id EAE7A3A1053; Tue, 1 Mar 2022 20:45:45 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.107
X-Spam-Level:
X-Spam-Status: No, score=-2.107 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, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_BLOCKED=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 ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jysR9Sv_4Fzl; Tue, 1 Mar 2022 20:45:41 -0800 (PST)
Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 1C3D03A105A; Tue, 1 Mar 2022 20:45:36 -0800 (PST)
Received: by mail-wr1-x42c.google.com with SMTP id r10so832866wrp.3; Tue, 01 Mar 2022 20:45:35 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to; bh=acd96VP17pCgqBvPUqgKT5zAavoXNEmUAqhtKMfSoOE=; b=Q3Ngb0KyDjQflqYjjqECHVGD/nyFtQgg38FAF1q9Rd8CVWThOzrOOxjzzRH047Mzcm 7Cg7pDSRq/iFmYCWMnEOsTb9XYY0qopitrvyAFk1W+VC3/PzBscALMS0KZhhBYB6MdY/ wLf0mPBhXTnfsDI2FPLw/LHVtNSreRZkBE09DxwBlNbZYl7ZCliRN5MjNKuTp/1Ks4j5 FZ6sgkY+o5BLzOfiijX4tDJZdwXzwLGwBi8UMV77spHo/Gw9akDBliibTvJp2GqvuDwa f/lIkuJFWjWLcYjrRw/JfJBzqcH9TMa540dUPKXVmb/BIdwQBMlyuivrgjHvm0QjsMFv 6aTg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to; bh=acd96VP17pCgqBvPUqgKT5zAavoXNEmUAqhtKMfSoOE=; b=tQ00jhZ87aDuVRlGpelBrw8HKF4zB5UN9UQEvyMWpczHXerCt6IfE864AFbTnR4WrH ATLtWoFQGhGLv4hSpa5OTU2sJ2g9fmZhjPA4ZSBMgZpIdrnIuFfmJ8NLdL+zraNDyiJM 2IXih0DRwdD+X60nUB1AZSDTejWeXwGrDk7/XgYq5GRTrUzLYonj+waBbN/Dpb4jBnVK jnUXOIUy4iNcfq26b5C651ZShxxKDIqP6ILKkwRrZuldClv3FO5zMh377kYVjdJBMSLX qfiJ2q8UO8KtrfS29Sq3e3zQJX8Lii4i9eZpct3b9b5Ybn6C4TfX9xifyQ9OV7AKCTBD 6Xxw==
X-Gm-Message-State: AOAM5305nSabfwhhC2k7dEfOk0Ydwdd8KrSS896cQWTmTMluzmaFu6uW ZSUp+8SkA4L8ExD1W30AEKc=
X-Google-Smtp-Source: ABdhPJxGKk9JDTtofwOIKauJSDQPbsya9xMdTTdiYdTvvmiZyKHgB8uutiWSlvso6NGxlMyWlUaFTA==
X-Received: by 2002:a5d:608e:0:b0:1f0:24ce:d429 with SMTP id w14-20020a5d608e000000b001f024ced429mr1746654wrt.666.1646196334217; Tue, 01 Mar 2022 20:45:34 -0800 (PST)
Received: from [192.168.1.67] (25.131.146.77.rev.sfr.net. [77.146.131.25]) by smtp.googlemail.com with ESMTPSA id e4-20020a05600c218400b003818133ab4dsm4196543wme.14.2022.03.01.20.45.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Mar 2022 20:45:33 -0800 (PST)
Content-Type: multipart/alternative; boundary="------------LJSYqD2duKjt8yLuxgKFJnow"
Message-ID: <b7e38294-314b-6866-a85c-e9c78feced69@gmail.com>
Date: Wed, 2 Mar 2022 05:45:31 +0100
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1
Content-Language: en-US
To: Laurence Lundblade <lgl@island-resort.com>, Carsten Bormann <cabo@tzi.org>
Cc: "rats@ietf.org" <rats@ietf.org>, "cose@ietf.org" <cose@ietf.org>, cbor@ietf.org
References: <e8995f0c-ad85-f702-da6b-051ffdc4cb08@gmail.com> <DBBPR08MB5915B874FD16107A7B0105AAFA3A9@DBBPR08MB5915.eurprd08.prod.outlook.com> <1a16c80d-40cd-baba-b1ce-2033dd0db294@gmail.com> <D22D0D63-F76C-48B3-A034-F8B5B2BB6005@tzi.org> <2c8be442-9899-d117-155c-f6f2096b7055@gmail.com> <92C7CF7C-ED23-41B3-AB32-8438C4C88C20@tzi.org> <14c8d106-3b4b-f973-94b8-018852ff4769@gmail.com> <8C2C6592-D5B9-430A-B878-E1009E9BCF22@tzi.org> <AB9F0C55-9C23-43F1-A83F-91D4159C888F@island-resort.com> <59939C29-5370-4385-AE61-A21ADDC0D194@tzi.org> <ED025590-3CA0-42B8-B50E-030D94FA88D6@island-resort.com> <E74C7303-E7D5-45EA-886C-158DB6D83844@tzi.org> <E5AD55D7-33B2-4E50-83EA-5BD1C1462F01@island-resort.com> <2A13AF29-6309-4FA3-9A84-59D4E0C8F089@tzi.org> <D20BAD71-EF8D-4849-9E90-6C19EF879896@island-resort.com>
From: Anders Rundgren <anders.rundgren.net@gmail.com>
In-Reply-To: <D20BAD71-EF8D-4849-9E90-6C19EF879896@island-resort.com>
Archived-At: <https://mailarchive.ietf.org/arch/msg/cose/IjYwxHqWr4p2PZhxnVwxDLLX6FM>
Subject: Re: [COSE] [Rats] RAM requirements for COSE/CWT
X-BeenThere: cose@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: CBOR Object Signing and Encryption <cose.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/cose>, <mailto:cose-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/cose/>
List-Post: <mailto:cose@ietf.org>
List-Help: <mailto:cose-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/cose>, <mailto:cose-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 02 Mar 2022 04:45:46 -0000

On 2022-03-01 23:21, Laurence Lundblade wrote:
> Got it. Made PR to remove half-precision exclusion <https://github.com/ietf-rats-wg/eat/pull/172> from location. Thanks for the discussion and foot notes!
>
> Checked a few decoders and can see that half-precision decoding is often supported.

Encoders can also provide full support (including subnormal values) for half-precision at the expense of 100-150 bytes of code:
https://github.com/cyberphone/D-CBOR/blob/main/lib/d-cbor-ieee754.c

Anders


>
> LL
>
>> On Feb 23, 2022, at 1:08 PM, Carsten Bormann <cabo@tzi.org> wrote:
>>
>>>>
>>>> This discussion was more about lat/lon.
>>>> cti (label 7) is a byte string, so there is no such problem there.
>>>
>>> Lat/long needs double precision float to be useful to beings the size of humans on a planet of earth's size. Half-precision has so little precision on a planet of earth's size that it is useless for location.
>>
>> That is not what this is about.
>>
>> Saying “You need 16 bits to express the unsigned integer weight of a street vehicle in kg” does not mean that I can’t encode the weight of my bike in 8 bits.
>> What the current text in EAT says is equivalent to "you can’t ever use 8 bits because some vehicles need 16".  That is not smart.
>>
>>> I mis-remembered “iat” as “cti”. Iat is a time stamp. A uint64 can represent everything needed for a time stamp, 1 second precision and +/- 500 million years. Float adds no value.
>>
>> Right, but that is OK: It is a restriction at the data model level.  You are asking the application not to feed floats into the generic encoder.
>>
>> (Note that we strengthened the little wall between integer and floating point for RFC 8949, after seeing that RFC 7049 was confusing people a lot.)
>>
>>>
>>> So EAT
>>> - disallows half-precision in location, but allows doubles to relieve a decoder from implementing half-precision
>>
>> Bad.  Half-precision (binary16) is not a different type at the data model level, it is just an efficient way to represent certain numbers in your data model.
>> Binary16 has a significand [sic] precision of 11 bits.  Binary32 has 24 bits.
>> So if you feed random binary32 lat/lon (~ meter precision) to your generic encoder, every 8192th will be encoded in half-precision (*).
>>
>> Since lat/lon values are probably approximately evenly distributed, that by itself is not a reason to implement half-precision.
>> The fact that CBOR preferred encoding does employ half-precision is.
>> Deviating from that by disallowing binary16 is expensive: You no longer can employ generic encoders.
>>
>> Don’t do that.
>>
>>> - disallows float for iat to relieve a decoder from implementing float, assuming it is not implementing location (many EAT implementations will not support location)
>>
>> Good(**).  That selection of integer second timestamps is a part of your data model.
>> You can do that, and no generic encoder will suddenly turn your integer iat number into a float.
>> (Again, with RFC 7049, it possibly could have, but we fixed that.)
>>
>> Grüße, Carsten
>>
>> (*) Note that a similar thing happens in JSON: numbers that happen to be whole numbers will be encoded without fractional parts (10.0 becomes 10).
>> In certain decoder implementations, that makes them a different “type" than 10.0 or 1e1 or 0.1e2 etc., causing breakage.
>> But the JSON data model only has numbers, not integers as a separate, incompatible type, so these decoders are broken with applications that simply expect numbers.
>> (Find ISO 6093:1985 for some fascinating history in this space :-)
>>
>> (**) ((I’m not making any representation on whether applications need to know with a precision of smaller than a second when your EAT was issued.
>> I really can’t imagine that, but that is proof by lack of imagination; I do assess that the cost of enabling that is higher than the benefits.
>> But that is true until someone has a convincing counterexample…
>> Consolation is that these people can introduce a float iat = “fiat” :-)))
>>
>
>
> _______________________________________________
> RATS mailing list
> RATS@ietf.org
> https://www.ietf.org/mailman/listinfo/rats