Closed ashisherc closed 4 years ago
More details,
trying to encode using BigInt,
cbor.encodeOne(9999998497035121n).toString("hex")
gives the cbor
c2472386f2162b9371
The decoding is as expected but the cbor is weird, eg. decode the cbor below
1B002386F2162B9371
and we get the same output number, 2 different cbor encoding for the exact same output.
c2472386f2162b9371 - this defined tag and bytes
1B002386F2162B9371 - this defined proper uint number
Although the end result is same but is very critical when the cbor is used to get a hash, and we will receive 2 different hashes.
Unable to get this 1B002386F2162B9371 cbor using js.
@hildjj can you please look at this one
I see that all the other integers are working perfectly fine but not the 64 bit integers, is there a way I can properly encode them?
cbor.encodeOne(i, {collapseBigIntegers: true}).toString('hex')
I am encoding number 9999998497035121
This results in cbor fb4341c3790b15c9b8
Which decoding results in 9999998497035120.0 (incorrect number)
I want to encode an unsigned integer, I tried BigNumber and BigInt, non of them are working as expected.