mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-08 16:28:49 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
84e4fb1f92 | ||
|
|
4c785279bc | ||
|
|
6786641b1d | ||
|
|
0396db5ed6 |
@@ -15,7 +15,7 @@ pool.addRelay('ws://some.relay.com', {read: true, write: true})
|
||||
pool.addRelay('ws://other.relay.cool', {read: true, write: true})
|
||||
|
||||
// example callback function for a subscription
|
||||
function onEvent(event, relay) => {
|
||||
function onEvent(event, relay) {
|
||||
console.log(`got an event from ${relay.url} which is already validated.`, event)
|
||||
}
|
||||
|
||||
|
||||
4
event.js
4
event.js
@@ -52,5 +52,7 @@ export function verifySignature(event) {
|
||||
}
|
||||
|
||||
export async function signEvent(event, key) {
|
||||
return secp256k1.schnorr.sign(getEventHash(event), key)
|
||||
return Buffer.from(secp256k1.schnorr.sign(getEventHash(event), key)).toString(
|
||||
'hex'
|
||||
)
|
||||
}
|
||||
|
||||
2
keys.js
2
keys.js
@@ -5,5 +5,5 @@ export function generatePrivateKey() {
|
||||
}
|
||||
|
||||
export function getPublicKey(privateKey) {
|
||||
return secp256k1.schnorr.getPublicKey(privateKey)
|
||||
return Buffer.from(secp256k1.schnorr.getPublicKey(privateKey)).toString('hex')
|
||||
}
|
||||
|
||||
4
nip04.js
4
nip04.js
@@ -37,6 +37,6 @@ export function decrypt(privkey, pubkey, ciphertext) {
|
||||
|
||||
function getNormalizedX(key) {
|
||||
return typeof key === 'string'
|
||||
? key.substr(2)
|
||||
: Buffer.from(key.slice(1)).toString('hex')
|
||||
? key.substr(2, 64)
|
||||
: Buffer.from(key.slice(1, 33)).toString('hex')
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "nostr-tools",
|
||||
"version": "0.21.2",
|
||||
"version": "0.22.0",
|
||||
"description": "Tools for making a Nostr client.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -8,7 +8,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@noble/hashes": "^0.5.7",
|
||||
"@noble/secp256k1": "^1.3.0",
|
||||
"@noble/secp256k1": "^1.5.2",
|
||||
"browserify-cipher": ">=1",
|
||||
"buffer": ">=5",
|
||||
"create-hash": "^1.2.0",
|
||||
|
||||
Reference in New Issue
Block a user