Skip to content

Commit a5be14d

Browse files
committed
security patch 0.6.8
1 parent 21a0fc7 commit a5be14d

4 files changed

Lines changed: 14 additions & 6 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nostr-nsec-seedphrase",
3-
"version": "0.6.7",
3+
"version": "0.6.8",
44
"description": "A comprehensive TypeScript library for Nostr key management with BIP39 seed phrases, supporting both ESM and CommonJS. Implements NIP-01, NIP-06, NIP-19, and NIP-26 with key generation, event signing, bech32 encoding/decoding, and secure cryptographic operations.",
55
"type": "module",
66
"main": "./dist/index.js",

src/core/crypto.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ export async function getSharedSecret(
9696
try {
9797
const privKeyBytes = hexToBytes(privateKey);
9898
// Nostr uses 32-byte x-only pubkeys; prefix with '02' for compressed format
99-
const sharedPoint = secp256k1.getSharedSecret(privKeyBytes, '02' + publicKey);
99+
const sharedPoint = secp256k1.getSharedSecret(
100+
privKeyBytes,
101+
"02" + publicKey,
102+
);
100103
// Extract x-coordinate only (bytes 1..33), per Nostr NIP-04 convention
101104
const sharedX = sharedPoint.slice(1, 33);
102105
privKeyBytes.fill(0); // zero sensitive material

src/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,11 +434,16 @@ export function configureHMAC(): void {
434434
};
435435

436436
// Safety check: only patch if utils exists and hmacSha256Sync is a known property
437-
if ('utils' in secp256k1 && typeof (secp256k1 as any).utils?.hmacSha256Sync !== 'undefined') {
437+
if (
438+
"utils" in secp256k1 &&
439+
typeof (secp256k1 as any).utils?.hmacSha256Sync !== "undefined"
440+
) {
438441
(secp256k1 as any).utils.hmacSha256 = hmacFunction;
439442
(secp256k1 as any).utils.hmacSha256Sync = hmacSyncFunction;
440443
} else {
441-
logger.log("secp256k1.utils.hmacSha256Sync not found; HMAC configuration skipped (library may handle HMAC internally)");
444+
logger.log(
445+
"secp256k1.utils.hmacSha256Sync not found; HMAC configuration skipped (library may handle HMAC internally)",
446+
);
442447
}
443448

444449
logger.log("Configured HMAC for secp256k1");

0 commit comments

Comments
 (0)