mirror of
https://github.com/nostr-protocol/nips.git
synced 2024-12-23 00:45:53 -05:00
NIP-04: fix bug in code sample
The code sample assumed that a `Uint8Array` was actually a hex string.
This commit is contained in:
parent
8b70e83b37
commit
b2c21ab10c
4
04.md
4
04.md
|
@ -23,12 +23,12 @@ import crypto from 'crypto'
|
||||||
import * as secp from 'noble-secp256k1'
|
import * as secp from 'noble-secp256k1'
|
||||||
|
|
||||||
let sharedPoint = secp.getSharedSecret(ourPrivateKey, '02' + theirPublicKey)
|
let sharedPoint = secp.getSharedSecret(ourPrivateKey, '02' + theirPublicKey)
|
||||||
let sharedX = sharedPoint.slice(2, 67)
|
let sharedX = sharedPoint.slice(1, 33)
|
||||||
|
|
||||||
let iv = crypto.randomFillSync(new Uint8Array(16))
|
let iv = crypto.randomFillSync(new Uint8Array(16))
|
||||||
var cipher = crypto.createCipheriv(
|
var cipher = crypto.createCipheriv(
|
||||||
'aes-256-cbc',
|
'aes-256-cbc',
|
||||||
Buffer.from(sharedX, 'hex'),
|
Buffer.from(sharedX),
|
||||||
iv
|
iv
|
||||||
)
|
)
|
||||||
let encryptedMessage = cipher.update(text, 'utf8', 'base64')
|
let encryptedMessage = cipher.update(text, 'utf8', 'base64')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user