add payload-to-id.ts
This commit is contained in:
parent
0bf7d05344
commit
7bebcc9d30
|
@ -0,0 +1,12 @@
|
|||
import { keccak256 } from 'ethereum-cryptography/keccak'
|
||||
import { bytesToHex } from 'ethereum-cryptography/utils'
|
||||
|
||||
export function payloadToId(
|
||||
publicKey: Uint8Array,
|
||||
payload: Uint8Array
|
||||
): string {
|
||||
const hash = keccak256(new Uint8Array([...publicKey, ...payload]))
|
||||
const hex = bytesToHex(hash)
|
||||
|
||||
return `0x${hex}`
|
||||
}
|
Loading…
Reference in New Issue