File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ export const isEventMatchingFilter = (filter: SubscriptionFilter) => (event: Eve
103103}
104104
105105export const getEventHash = async ( event : Event | UnidentifiedEvent | UnsignedEvent ) : Promise < string > => {
106- const id = await secp256k1 . utils . sha256 ( Buffer . from ( JSON . stringify ( serializeEvent ( event ) ) ) )
106+ const id = await secp256k1 . utils . sha256 ( new Uint8Array ( Buffer . from ( JSON . stringify ( serializeEvent ( event ) ) ) ) )
107107
108108 return Buffer . from ( id ) . toString ( 'hex' )
109109}
@@ -160,15 +160,15 @@ export const encryptKind4Event = (
160160 receiverPubkey : Pubkey ,
161161) => ( event : UnsignedEvent ) : UnsignedEvent => {
162162 const key = secp256k1
163- . getSharedSecret ( senderPrivkey , `02${ receiverPubkey } ` , true )
163+ . getSharedSecret ( typeof senderPrivkey === 'string' ? senderPrivkey : new Uint8Array ( senderPrivkey ) , `02${ receiverPubkey } ` , true )
164164 . subarray ( 1 )
165165
166166 const iv = getRandomValues ( new Uint8Array ( 16 ) )
167167
168168 // deepcode ignore InsecureCipherNoIntegrity: NIP-04 Encrypted Direct Message uses aes-256-cbc
169169 const cipher = createCipheriv (
170170 'aes-256-cbc' ,
171- Buffer . from ( key ) ,
171+ new Uint8Array ( key ) ,
172172 iv ,
173173 )
174174
You can’t perform that action at this time.
0 commit comments