Subject: Re: [Cbor] draft-ietf-cbor-network-addresses: tag validity; deterministic encoding

From: Brian E Carpenter <[email-masked]>
Date: Wed, 3 Nov 2021 17:07:46 +1300

On 15-Oct-21 17:50, Carsten Bormann wrote:
> On 15. Oct 2021, at 06:35, Brian E Carpenter <[email-masked]> wrote:
>>
>> So, my ugly code is in the functions build5254() and detag5254() in https://github.com/becarpenter/graspy/blob/master/pfxm4.py
> 
> Nice.
> 
> After line 122, there needs to be the Python equivalent of a
> 
> prefix.sub!(/\x00*\z/, ‘’)

I took an executive decision to throw an exception for covert bits, rather than silently zero them, and in fact changed all my error returns to ValueError exceptions. I believe that's more Pythonesque.
  
> (Why not mix floating point calculations and a regex in the same five lines of code :-)

Because it makes my head hurt, that's why not.
> 
> Before line 146, you’d need to check whether the size really is 
`asize`.

Yes, or that the type really is 'bytes' since Python won't check that for 
me.

> I think the while loop in 154 needs to be before 151.

I don't think it matters. Either way, the zero bytes get concatenated.
  
> If v[0] == 128 and prefix is 16 bytes, what does prefix[v[0]//8] yield in Python?

IndexError: index out of range

Good catch. In my app, that is a case that would never happen.

I've fixed my code, but will let my test app run for a few hours before I 
post the update to github.

    Brian

---

From: Brian E Carpenter <[email-masked]>
Date: Fri, 5 Nov 2021 10:03:32 +1300

I've fixed the code, run some unit tests and exercised it thoroughly in my GRASP app, and separated the code out as https://github.com/becarpenter/graspy/blob/master/tag5254.py. It's under a BSD licence if anyone is interested.

Is there a generic place for small items of CBOR-related code? This doesn't seem to deserve a repo on its own.

Regards
    Brian

---

From: Carsten Bormann <[email-masked]>
Date: Thu, 4 Nov 2021 22:22:34 +0100

> Is there a generic place for small items of CBOR-related code? This doesn't seem to deserve a repo on its own.

The GitHub.com/cbor organization seems appropriate for this.
We could create a repo for tag-related implementations.

Grüße, Carsten

---

From: Brian E Carpenter <[email-masked]>
Date: Fri, 5 Nov 2021 11:18:22 +1300

> We could create a repo for tag-related implementations.

That would be fine. Could we agree on an open source licence?
I've been using BSD Revised (3-clause).

    Brian

---

From: Carsten Bormann <[email-masked]>
Date: Fri, 5 Nov 2021 02:45:01 +0100

> That would be fine. Could we agree on an open source licence?

That is always difficult.

> I've been using BSD Revised (3-clause).

I personally prefer MIT.
Some organizations prefer to produce Apache-2, which also should fit here.
0BSD (https://spdx.org/licenses/0BSD.html) or less-than-3-clause BSDs should work too.

So, from https://spdx.org/licenses/, it should be an OSI-approved license that is not contagious.

Grüße, Carsten

---

From: Brian E Carpenter <[email-masked]>
Date: Fri, 5 Nov 2021 15:47:00 +1300

> So, from https://spdx.org/licenses/, it should be an OSI-approved license that is not contagious.

Agreerd, but they don't list 'contagious', do they?

I picked BSD just to align with the IETF Trust, but I can see why you like MIT. If we do start such a repo, I will of course relicence my code accordingly.

     Brian