Added noble-curves.js
This commit is contained in:
@@ -9,8 +9,7 @@ self.addEventListener("install", (event) => {
|
|||||||
importScripts(
|
importScripts(
|
||||||
"safari-notifications.js",
|
"safari-notifications.js",
|
||||||
"nacl.js",
|
"nacl.js",
|
||||||
"sw-bn.js",
|
"noble-curves.js",
|
||||||
"secp256k1.js",
|
|
||||||
);
|
);
|
||||||
console.log("scripts imported", event);
|
console.log("scripts imported", event);
|
||||||
});
|
});
|
||||||
|
|||||||
4772
sw_scripts/noble-curves.js
Normal file
4772
sw_scripts/noble-curves.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -282,18 +282,13 @@ function bufferFromBase64(base64) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return async function(data) {
|
return async function(data) {
|
||||||
const privateKey = Secp256k1.uint256(privateKeyBytes, 16);
|
|
||||||
const hash = await sha256(data);
|
const hash = await sha256(data);
|
||||||
console.error("sha256", hash);
|
const signature = nobleCurves.secp256k1.sign(hash, privateKeyBytes);
|
||||||
const digest = Secp256k1.uint256(hash, 16);
|
|
||||||
|
|
||||||
const signature = Secp256k1.ecsign(privateKey, digest);
|
|
||||||
const sigR = Secp256k1.uint256(signature.r,16);
|
|
||||||
const sigS = Secp256k1.uint256(signature.s,16);
|
|
||||||
return toJose({
|
return toJose({
|
||||||
r: leftpad(signature.r.toString(16)),
|
r: leftpad(signature.r.toString(16)),
|
||||||
s: leftpad(signature.s.toString(16)),
|
s: leftpad(signature.s.toString(16)),
|
||||||
recoveryParam: signature.v,
|
recoveryParam: signature.recovery,
|
||||||
}, recoverable);
|
}, recoverable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -443,6 +438,8 @@ async function getNotificationCount() {
|
|||||||
const msg = decoder.decode(decrypted);
|
const msg = decoder.decode(decrypted);
|
||||||
const identifier = JSON.parse(JSON.parse(msg));
|
const identifier = JSON.parse(JSON.parse(msg));
|
||||||
|
|
||||||
|
console.log(identifier);
|
||||||
|
|
||||||
const headers = {
|
const headers = {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user