@hive-p2p/server 1.0.51 → 1.0.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/arbiter.mjs +10 -5
- package/package.json +1 -1
- package/services/cryptos.mjs +2 -1
package/core/arbiter.mjs
CHANGED
|
@@ -101,11 +101,16 @@ export class Arbiter {
|
|
|
101
101
|
}
|
|
102
102
|
/** @param {string} from @param {import('./gossip.mjs').GossipMessage} message @param {Uint8Array} serialized */
|
|
103
103
|
#signatureControl(from, message, serialized) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
104
|
+
try {
|
|
105
|
+
const { pubkey, signature, signatureStart } = message;
|
|
106
|
+
const signedData = serialized.subarray(0, signatureStart);
|
|
107
|
+
const signatureValid = this.cryptoCodex.verifySignature(pubkey, signature, signedData);
|
|
108
|
+
if (signatureValid) return this.adjustTrust(from, TRUST_VALUES.VALID_SIGNATURE, 'Gossip signature valid');
|
|
109
|
+
} catch (error) {
|
|
110
|
+
if (this.verbose > 1) console.error(`%c(Arbiter: ${this.id}) Error during signature verification from ${from}:`, LOG_CSS.ARBITER, error);
|
|
111
|
+
if (this.verbose > 2) console.log(`%c(Arbiter) signatureControl() error details: ${message}`, LOG_CSS.ARBITER);
|
|
112
|
+
}
|
|
113
|
+
this.adjustTrust(from, TRUST_VALUES.WRONG_SIGNATURE, 'Gossip signature invalid');
|
|
109
114
|
}
|
|
110
115
|
/** GOSSIP only @param {string} from @param {import('./gossip.mjs').GossipMessage} message */
|
|
111
116
|
#hopsControl(from, message) {
|
package/package.json
CHANGED
package/services/cryptos.mjs
CHANGED
|
@@ -7,7 +7,8 @@ const [ed_, {sha512}] = await Promise.all([
|
|
|
7
7
|
import(IS_BROWSER ? '../libs/ed25519-custom.js' : '@noble/hashes/sha2.js')
|
|
8
8
|
]);
|
|
9
9
|
/** @type {import('@noble/ed25519')} */
|
|
10
|
-
const ed25519 = ed_;
|
|
10
|
+
const ed25519 = ed_.default || ed_;
|
|
11
|
+
ed25519.hashes.sha512 = sha512;
|
|
11
12
|
export { ed25519, sha512 };
|
|
12
13
|
|
|
13
14
|
//-----------------------------------------------------------------------------
|