UndergroundVault
UndergroundVault

Reputation: 130

How to send payload and cryptographic signature over WebRTC data channel?

I have a use case where a peer must send a message and signature to another peer using WebRTC Data Channels. Unfortunately the signature generated using WebCrypto is an ArrayBuffer, meaning that when I use JSON.stringify() to send the object the signature is lost.

Is there a way to encode the ArrayBuffer signature that will enable me to transfer the stringifyed object over the Data Channel without compromising the signature on the receiving end?

Upvotes: 0

Views: 331

Answers (2)

rmhrisk
rmhrisk

Reputation: 1856

Consider using https://github.com/dcodeIO/ProtoBuf.js/ and encoding the ASCII as binary.

Upvotes: 0

Philipp Hancke
Philipp Hancke

Reputation: 17360

Are you setting the datachannels binaryType to 'arraybuffer'? Then you should be able to transfer without using JSON.stringify.

Upvotes: 0

Related Questions