MCPcopy Index your code
hub / github.com/cameri/nostream / getEventHash

Function getEventHash

src/utils/event.ts:108–112  ·  view source on GitHub ↗
(event: Event | UnidentifiedEvent | UnsignedEvent)

Source from the content-addressed store, hash-verified

106 }
107
108export const getEventHash = async (event: Event | UnidentifiedEvent | UnsignedEvent): Promise<string> => {
109 const id = await secp256k1.utils.sha256(Buffer.from(JSON.stringify(serializeEvent(event))))
110
111 return Buffer.from(id).toString('hex')
112}
113
114export const isEventIdValid = async (event: Event): Promise<boolean> => {
115 return event.id === (await getEventHash(event))

Callers 2

isEventIdValidFunction · 0.85
identifyEventFunction · 0.85

Calls 2

toStringMethod · 0.80
serializeEventFunction · 0.70

Tested by

no test coverage detected