signalapp / libsignal

Home to the Signal Protocol as well as other cryptographic primitives which make Signal possible.
GNU Affero General Public License v3.0
3.55k stars 415 forks source link

bridge: Add back support for bridging u64, now losslessly #405

Closed jrose-signal closed 2 years ago

jrose-signal commented 2 years ago

Follow-up to #404.

jrose-signal commented 2 years ago

What is the plan for node bigint support?

If we decide it's important I could spend some time doing the necessary work on the Neon side; if not, converting from Buffer to bigint on the TypeScript side isn't bad, and converting from bigint to Buffer…probably deserves a helper function. Here's what it looks like in the TS zkgroup port:

if (receiptExpirationTime < 0 || receiptExpirationTime > UINT64_MAX) {
  throw new RangeError(`invalid receipt expiration time ${receiptExpirationTime}`);
}
const receiptExpirationAsBuffer = Buffer.alloc(8);
receiptExpirationAsBuffer.writeBigUInt64BE(receiptExpirationTime);