Re: [Cbor] Self Described CBOR - Little Endian

Joe Hildebrand <hildjj@cursive.net> Wed, 24 March 2021 20:06 UTC

Return-Path: <hildjj@cursive.net>
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 7FAB93A34E9 for <cbor@ietfa.amsl.com>; Wed, 24 Mar 2021 13:06:45 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.697
X-Spam-Level:
X-Spam-Status: No, score=-1.697 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001, URIBL_BLOCKED=0.001] autolearn=no autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=neutral reason="invalid (public key: not available)" header.d=cursive.net
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 P7dMXfPcrh5R for <cbor@ietfa.amsl.com>; Wed, 24 Mar 2021 13:06:40 -0700 (PDT)
Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) (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 C8AFE3A34F7 for <cbor@ietf.org>; Wed, 24 Mar 2021 13:06:40 -0700 (PDT)
Received: by mail-il1-x133.google.com with SMTP id j11so118418ilu.13 for <cbor@ietf.org>; Wed, 24 Mar 2021 13:06:40 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cursive.net; s=google; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=5ayziJhj6jrb9RvgzyvvGnKXiq4nO/ibhblmSrFjMZE=; b=EWQ7VT345Grx/2fjSipaI4xuNh96CtmN4li11wRoKNvs1e8h6Gh18glbppUYHn/RQC +945vmue0rRTHgQ3KqiWN2wHdnM/iIwGMoy68f06XDxJC5dC9rcKYOuuir8NW+n16G10 A1xX+2OKVuetfksYbNUEKYKQGRvvHhJjCtdPc=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=5ayziJhj6jrb9RvgzyvvGnKXiq4nO/ibhblmSrFjMZE=; b=P+L4o/ypdji1C1ZLtaRGCVNT3M1yNA+O0yKwMahyVhPLD55T3hrw4+K0oHYYVOCPUZ QxTvhdWf8ot0gFffwW0GpC+m9+q4Gt2pdEIn+Cew/hwwdaBbCaswVgzmfYfPn4gL0jdH pGGZLL1KaL3+8eYat9ma46wrf/csn7O5wW1JcWfZsqWpTsGM/BfqX2+NUARWSusStCv+ v791R18I+yG+RJW/hzjA008mcT5D51qE1grHWvTKi/+a5I/5v3dLVq/AkT4MGzjH7KwT k3piHKfZQWFjplWwDTb7rFwV+HRdyciP0DDuSu7w/3E/wF1x5/ZS7o8QofKsNEF/jRCZ l45A==
X-Gm-Message-State: AOAM5300/BMN3zTOJqMEdJRYcenX5nFdbjL3ojVee4H0v4CGFBD3L5Pc zhWN2HRqMgl5jK4TO+8zEOsNvg==
X-Google-Smtp-Source: ABdhPJxTRyNttsb0IrYciyulDG4nL1ZqInsyxrfFd50z/4IHr5L3vH+ogSAVwI+IM9xbWm4PoPjYqQ==
X-Received: by 2002:a92:ddd0:: with SMTP id d16mr4081101ilr.52.1616616399841; Wed, 24 Mar 2021 13:06:39 -0700 (PDT)
Received: from ?IPv6:2601:282:200:11c0:b1f4:81d1:7d97:eaa9? ([2601:282:200:11c0:b1f4:81d1:7d97:eaa9]) by smtp.gmail.com with ESMTPSA id d22sm1485191iof.48.2021.03.24.13.06.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Mar 2021 13:06:39 -0700 (PDT)
Content-Type: text/plain; charset=utf-8
Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\))
From: Joe Hildebrand <hildjj@cursive.net>
In-Reply-To: <BY5PR20MB2898CBA491A4C0AED983C81CD2649@BY5PR20MB2898.namprd20.prod.outlook.com>
Date: Wed, 24 Mar 2021 14:06:38 -0600
Cc: "cbor@ietf.org" <cbor@ietf.org>
Content-Transfer-Encoding: quoted-printable
Message-Id: <31C92F28-636E-429D-9265-3248509B60F7@cursive.net>
References: <BY5PR20MB2898CBA491A4C0AED983C81CD2649@BY5PR20MB2898.namprd20.prod.outlook.com>
To: alex thompson <pierogitus@hotmail.com>
X-Mailer: Apple Mail (2.3654.60.0.2.21)
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/hLG22Fau6e9w_G4rRs_JWN3R2Cc>
Subject: Re: [Cbor] Self Described CBOR - Little Endian
X-BeenThere: cbor@ietf.org
X-Mailman-Version: 2.1.29
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: Wed, 24 Mar 2021 20:06:46 -0000

Coincidentally, I just got a very small generic WASM decoder working:

https://github.com/hildjj/cbor-wasm

Inspired by https://github.com/quartzjer/cb0r/, but works synchronously in streaming mode, like expat.

— 
Joe Hildebrand

> On Mar 22, 2021, at 10:50 PM, alex thompson <pierogitus@hotmail.com> wrote:
> 
> ​Given the prevalence of little endian hardware and the existence of the LE typed array tags it would be useful to opt-in to LE encoding of the additional information bytes as well. This would simplify decoders that are specific to LE platforms, particularly WebAssembly which is all LE and hasn’t defined a swap instruction.
> 
> The opt-in could be self described with tag 55798 (has the same non-unicode magic number characteristic as 55799). The beginning of a stream would default to BE so tag 55798 itself would appear as 0xd9d9f6. Then any following tags and descendant items would be LE.
> 
> For completeness, 55798 and 55799 could be nested within one another, switching the endianness as the decoder traverses a tree of items. Nested tags 24 and 63 would pass on their endianness to their embedded items. No effect on typed array tags 64-87.
> 
> It would be a breaking change for generic decoders since ignoring 55798 wouldn’t work as expected but I think the impact is very manageable and fits with CBOR’s stated goals of small code size and extensibility.
> 
> Alex
> _______________________________________________
> CBOR mailing list
> CBOR@ietf.org
> https://www.ietf.org/mailman/listinfo/cbor