namebasehq / handshake-id-manager

MIT License
30 stars 7 forks source link

Double base64 encoding for signature #6

Closed Falci closed 3 years ago

Falci commented 3 years ago

This is where the signature happens: https://github.com/namebasehq/handshake-id-manager/blob/dcd7864a57e537c25273bd1ebaa1332f68f0f98b/src/services/IdentityService/cryptography.ts#L93-L105

By the variable name is clear what format is used to export: exportedAsBase64

Later, right before sending it is encoded again: (line 44) https://github.com/namebasehq/handshake-id-manager/blob/dcd7864a57e537c25273bd1ebaa1332f68f0f98b/src/routes/_login/index.svelte#L39-L54

Is this double base64 encoding required?

Note that this is not the final encoding, that happens over the stringified data (line 50);

jeefave commented 3 years ago

The output of crypto is an encoded format and it is re-encoded for transport with the other data in the upper layer. This is not required per se but the crypto lib being written first, I imagine the second encoding has been added later on for consistency sake.

Removing it would be a breaking change. I am gonna update the doc to highlight it. Thank you for pointing this out!