get rid of create-hash, use noble hashes.

This commit is contained in:
fiatjaf
2022-12-19 19:50:41 -03:00
parent 39aca167fb
commit 897919be3b
2 changed files with 3 additions and 6 deletions

View File

@@ -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')
} }

View File

@@ -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": [