interledgerjs / btp-packet

Packet parser for Bilateral Transfer Protocol
1 stars 3 forks source link

sequence-of prefix, 2 or 8 bytes? #1

Closed michielbdejong closed 7 years ago

michielbdejong commented 7 years ago

http://www.oss.com/asn1/resources/books-whitepapers-pubs/Overview%20of%20OER.pdf says the quantity field of a sequence-of type is encoded as an unsigned binary integer in eight octets, doesn't that contradict what was implemented in https://github.com/interledgerjs/clp-packet/blob/master/index.js#L85-L86?

michielbdejong commented 7 years ago

As discussed on Slack with @sharafian, it’s a typo in the document, it should read 'see section 2.2, case 5', not case 4.

michielbdejong commented 7 years ago

I contacted oss support to ask about this.

michielbdejong commented 7 years ago

For now, let's keep it as a VarInt, if the number of elements in the sequence-of < 256, then 1 byte length '1' and then 1 byte with that number of elements.

michielbdejong commented 7 years ago

Got a reply:

Dear Mr. de Jong:

Yes, you are correct. We will fix the overview document.

Thank you for letting us know.

So we can definitely stick with VarInt (section 2.2, case 5) which is also what makes much more sense than UInt64 (section 2.2, case 4). Nice! :)

michielbdejong commented 7 years ago

From the wording in section 17.2 of http://www.itu.int/rec/T-REC-X.696-201408-S it's also clearer that the quantity of a sequence-of should definitely be a VarInt.