(event: Event | UnidentifiedEvent | UnsignedEvent)
| 106 | } |
| 107 | |
| 108 | export 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 | |
| 114 | export const isEventIdValid = async (event: Event): Promise<boolean> => { |
| 115 | return event.id === (await getEventHash(event)) |
no test coverage detected