fix: use base64url WITH padding

This commit is contained in:
Richard Ramos 2023-03-28 09:38:46 -04:00 committed by RichΛrd
parent ead21e71b6
commit 6666080651
6 changed files with 13 additions and 22 deletions

View File

@ -20,7 +20,8 @@
"ciphertext",
"preshared",
"libp2p",
"Authcode"
"Authcode",
"base64urlpad"
],
"flagWords": [],
"ignorePaths": [

View File

@ -37,7 +37,6 @@
"@waku/proto": "^0.0.2",
"bn.js": "^5.2.1",
"eventemitter3": "^5.0.0",
"js-base64": "^3.7.3",
"p-event": "^5.0.1",
"pkcs7-padding": "^0.1.1",
"uint8arraylist": "^2.3.2",
@ -8766,7 +8765,6 @@
"gh-pages": "^3.2.3",
"husky": "^7.0.4",
"ignore-loader": "^0.1.2",
"js-base64": "^3.7.3",
"jsdom": "^19.0.0",
"jsdom-global": "^3.0.2",
"karma": "^6.3.12",

6
package-lock.json generated
View File

@ -19,7 +19,6 @@
"@waku/proto": "^0.0.2",
"bn.js": "^5.2.1",
"eventemitter3": "^5.0.0",
"js-base64": "^3.7.3",
"p-event": "^5.0.1",
"pkcs7-padding": "^0.1.1",
"uint8arraylist": "^2.3.2",
@ -6855,11 +6854,6 @@
"url": "https://github.com/chalk/supports-color?sponsor=1"
}
},
"node_modules/js-base64": {
"version": "3.7.4",
"resolved": "https://registry.npmjs.org/js-base64/-/js-base64-3.7.4.tgz",
"integrity": "sha512-wpM/wi20Tl+3ifTyi0RdDckS4YTD4Lf953mBRrpG8547T7hInHNPEj8+ck4gB8VDcGyeAWFK++Wb/fU1BeavKQ=="
},
"node_modules/js-sdsl": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.3.0.tgz",

View File

@ -125,7 +125,6 @@
"@waku/proto": "^0.0.2",
"bn.js": "^5.2.1",
"eventemitter3": "^5.0.0",
"js-base64": "^3.7.3",
"p-event": "^5.0.1",
"pkcs7-padding": "^0.1.1",
"uint8arraylist": "^2.3.2",

View File

@ -108,7 +108,6 @@ export class HandshakeState {
// Uses the cryptographic information stored in the input handshake state to generate a random message nametag
// In current implementation the messageNametag = HKDF(handshake hash value), but other derivation mechanisms can be implemented
toMessageNametag(): MessageNametag {
console.log("HELLO!");
const [output] = HKDF(this.ss.h, new Uint8Array(), 32, 1);
return output.subarray(0, MessageNametagLength);
}

View File

@ -1,4 +1,4 @@
import { decode, encodeURI, fromUint8Array, toUint8Array } from "js-base64";
import { fromString, toString } from "uint8arrays";
import { bytes32 } from "./@types/basic.js";
@ -16,11 +16,11 @@ export class QR {
// Serializes input parameters to a base64 string for exposure through QR code (used by WakuPairing)
toString(): string {
let qr = encodeURI(this.applicationName) + ":";
qr += encodeURI(this.applicationVersion) + ":";
qr += encodeURI(this.shardId) + ":";
qr += fromUint8Array(this.ephemeralKey, true) + ":";
qr += fromUint8Array(this.committedStaticKey, true);
let qr = toString(fromString(this.applicationName), "base64urlpad") + ":";
qr += toString(fromString(this.applicationVersion), "base64urlpad") + ":";
qr += toString(fromString(this.shardId), "base64urlpad") + ":";
qr += toString(this.ephemeralKey, "base64urlpad") + ":";
qr += toString(this.committedStaticKey, "base64urlpad");
return qr;
}
@ -52,11 +52,11 @@ export class QR {
if (values.length != 5) throw new Error("invalid qr string");
const applicationName = decode(values[0]);
const applicationVersion = decode(values[1]);
const shardId = decode(values[2]);
const ephemeralKey = toUint8Array(values[3]);
const committedStaticKey = toUint8Array(values[4]);
const applicationName = toString(fromString(values[0], "base64urlpad"));
const applicationVersion = toString(fromString(values[1], "base64urlpad"));
const shardId = toString(fromString(values[2], "base64urlpad"));
const ephemeralKey = fromString(values[3], "base64urlpad");
const committedStaticKey = fromString(values[4], "base64urlpad");
return new QR(applicationName, applicationVersion, shardId, ephemeralKey, committedStaticKey);
}