Browse Source

WIP: fixing secp256k1 and BN

home-view-notification-improvements
Matthew Raymer 1 year ago
parent
commit
267ed40946
  1. 15
      sw_scripts/additional-scripts.js
  2. 15
      sw_scripts/sw-bn.js

15
sw_scripts/additional-scripts.js

@ -6,7 +6,12 @@ importScripts(
self.addEventListener("install", (event) => { self.addEventListener("install", (event) => {
console.log("Install event fired."); console.log("Install event fired.");
importScripts("safari-notifications.js", "nacl.js"); importScripts(
"safari-notifications.js",
"nacl.js",
"sw-bn.js",
"secp256k1.js",
);
console.log("scripts imported", event); console.log("scripts imported", event);
}); });
@ -50,4 +55,12 @@ self.addEventListener("fetch", (event) => {
console.log(event.request); console.log(event.request);
}); });
self.addEventListener("error", (event) => {
console.error("Error in Service Worker:", event.message);
console.error("File:", event.filename);
console.error("Line:", event.lineno);
console.error("Column:", event.colno);
console.error("Error Object:", event.error);
});
workbox.precaching.precacheAndRoute(self.__WB_MANIFEST); workbox.precaching.precacheAndRoute(self.__WB_MANIFEST);

15
sw_scripts/sw-bn.js

@ -1,4 +1,3 @@
(function (exports) {
"use strict"; "use strict";
// Utils // Utils
@ -39,7 +38,7 @@
this._init(number || 0, base || 10, endian || "be"); this._init(number || 0, base || 10, endian || "be");
} }
} }
exports.BN = BN; self.BN = BN;
BN.BN = BN; BN.BN = BN;
BN.wordSize = 26; BN.wordSize = 26;
@ -452,10 +451,10 @@
var groupBases = [ var groupBases = [
0, 0, 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, 0, 0, 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216,
43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625, 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625, 16777216,
16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632, 6436343, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632, 6436343, 7962624,
7962624, 9765625, 11881376, 14348907, 17210368, 20511149, 24300000, 9765625, 11881376, 14348907, 17210368, 20511149, 24300000, 28629151, 33554432,
28629151, 33554432, 39135393, 45435424, 52521875, 60466176, 39135393, 45435424, 52521875, 60466176,
]; ];
BN.prototype.toString = function toString(base, padding) { BN.prototype.toString = function toString(base, padding) {
@ -2380,8 +2379,7 @@
for (var j = m - 1; j >= 0; j--) { for (var j = m - 1; j >= 0; j--) {
var qj = var qj =
(a.words[b.length + j] | 0) * 0x4000000 + (a.words[b.length + j] | 0) * 0x4000000 + (a.words[b.length + j - 1] | 0);
(a.words[b.length + j - 1] | 0);
// NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max
// (0x7ffffff) // (0x7ffffff)
@ -3542,4 +3540,3 @@
var res = this.imod(a._invmp(this.m).mul(this.r2)); var res = this.imod(a._invmp(this.m).mul(this.r2));
return res._forceRed(this); return res._forceRed(this);
}; };
})(self);

Loading…
Cancel
Save