Created
August 26, 2022 17:57
-
-
Save loon3/1df4bbc4aa6772404f78c94e99d9f950 to your computer and use it in GitHub Desktop.
ECIES Bitcoin Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { encrypt, decrypt } from 'eciesjs' | |
var bitcoinjs = require('bitcoinjs-lib') | |
let aliceKeyPriv = bitcoinjs.ECPair.fromWIF("5KAHnHT2x4XMFnjVZZJNkbmDKB8qtTZrqmotNwe4F8g31nvnpTN").privateKey | |
let aliceKeyPub = bitcoinjs.ECPair.fromWIF("5KAHnHT2x4XMFnjVZZJNkbmDKB8qtTZrqmotNwe4F8g31nvnpTN").publicKey | |
let data = Buffer.from('this is a test') | |
let final = decrypt(aliceKeyPriv, encrypt(aliceKeyPub, data)).toString() | |
console.log(final) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment