mirror of
https://github.com/ipnet-mesh/meshcore-hub.git
synced 2026-03-28 17:42:56 +01:00
59 lines
2.3 KiB
Diff
59 lines
2.3 KiB
Diff
diff --git a/node_modules/@michaelhart/meshcore-decoder/dist/crypto/ed25519-verifier.js b/node_modules/@michaelhart/meshcore-decoder/dist/crypto/ed25519-verifier.js
|
|
index d33ffd6..8d040d0 100644
|
|
--- a/node_modules/@michaelhart/meshcore-decoder/dist/crypto/ed25519-verifier.js
|
|
+++ b/node_modules/@michaelhart/meshcore-decoder/dist/crypto/ed25519-verifier.js
|
|
@@ -36,7 +36,27 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
})();
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.Ed25519SignatureVerifier = void 0;
|
|
-const ed25519 = __importStar(require("@noble/ed25519"));
|
|
+let _ed25519 = null;
|
|
+async function getEd25519() {
|
|
+ if (_ed25519) {
|
|
+ return _ed25519;
|
|
+ }
|
|
+ const mod = await import("@noble/ed25519");
|
|
+ _ed25519 = mod.default ? mod.default : mod;
|
|
+ try {
|
|
+ _ed25519.etc.sha512Async = sha512Hash;
|
|
+ }
|
|
+ catch (error) {
|
|
+ console.debug("Could not set async SHA-512:", error);
|
|
+ }
|
|
+ try {
|
|
+ _ed25519.etc.sha512Sync = sha512HashSync;
|
|
+ }
|
|
+ catch (error) {
|
|
+ console.debug("Could not set up synchronous SHA-512:", error);
|
|
+ }
|
|
+ return _ed25519;
|
|
+}
|
|
const hex_1 = require("../utils/hex");
|
|
const orlp_ed25519_wasm_1 = require("./orlp-ed25519-wasm");
|
|
// Cross-platform SHA-512 implementation
|
|
@@ -90,16 +110,6 @@ function sha512HashSync(data) {
|
|
throw new Error('No SHA-512 implementation available for synchronous operation');
|
|
}
|
|
}
|
|
-// Set up SHA-512 for @noble/ed25519
|
|
-ed25519.etc.sha512Async = sha512Hash;
|
|
-// Always set up sync version - @noble/ed25519 requires it
|
|
-// It will throw in browser environments, which @noble/ed25519 can handle
|
|
-try {
|
|
- ed25519.etc.sha512Sync = sha512HashSync;
|
|
-}
|
|
-catch (error) {
|
|
- console.debug('Could not set up synchronous SHA-512:', error);
|
|
-}
|
|
class Ed25519SignatureVerifier {
|
|
/**
|
|
* Verify an Ed25519 signature for MeshCore advertisement packets
|
|
@@ -116,6 +126,7 @@ class Ed25519SignatureVerifier {
|
|
// Construct the signed message according to MeshCore format
|
|
const message = this.constructAdvertSignedMessage(publicKeyHex, timestamp, appData);
|
|
// Verify the signature using noble-ed25519
|
|
+ const ed25519 = await getEd25519();
|
|
return await ed25519.verify(signature, message, publicKey);
|
|
}
|
|
catch (error) {
|