add payload-to-id.ts
This commit is contained in:
parent
1499d879c9
commit
5a9ca4b3dd
|
@ -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