mirror of
https://github.com/status-im/wakuconnect-chat-sdk.git
synced 2025-01-12 21:25:03 +00:00
add payload-to-id.ts
This commit is contained in:
parent
0bf7d05344
commit
7bebcc9d30
12
packages/status-js/src/utils/payload-to-id.ts
Normal file
12
packages/status-js/src/utils/payload-to-id.ts
Normal file
@ -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…
x
Reference in New Issue
Block a user