mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-10 09:08:50 +00:00
get rid of create-hash, use noble hashes.
This commit is contained in:
6
event.ts
6
event.ts
@@ -1,7 +1,7 @@
|
|||||||
import {Buffer} from 'buffer'
|
import {Buffer} from 'buffer'
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import createHash from 'create-hash'
|
|
||||||
import * as secp256k1 from '@noble/secp256k1'
|
import * as secp256k1 from '@noble/secp256k1'
|
||||||
|
import {sha256} from '@noble/hashes/sha256'
|
||||||
|
|
||||||
export type Event = {
|
export type Event = {
|
||||||
id?: string
|
id?: string
|
||||||
@@ -35,9 +35,7 @@ export function serializeEvent(evt: Event): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getEventHash(event: Event): string {
|
export function getEventHash(event: Event): string {
|
||||||
let eventHash = createHash('sha256')
|
let eventHash = sha256(Buffer.from(serializeEvent(event)))
|
||||||
.update(Buffer.from(serializeEvent(event)))
|
|
||||||
.digest()
|
|
||||||
return Buffer.from(eventHash).toString('hex')
|
return Buffer.from(eventHash).toString('hex')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,7 @@
|
|||||||
"@scure/bip32": "^1.1.1",
|
"@scure/bip32": "^1.1.1",
|
||||||
"@scure/bip39": "^1.1.0",
|
"@scure/bip39": "^1.1.0",
|
||||||
"browserify-cipher": ">=1",
|
"browserify-cipher": ">=1",
|
||||||
"buffer": ">=5",
|
"buffer": "^6.0.3",
|
||||||
"create-hash": "^1.2.0",
|
|
||||||
"websocket-polyfill": "^0.0.3"
|
"websocket-polyfill": "^0.0.3"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
Reference in New Issue
Block a user