Skip to content

Instantly share code, notes, and snippets.

@loon3
Created August 26, 2022 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loon3/1df4bbc4aa6772404f78c94e99d9f950 to your computer and use it in GitHub Desktop.
Save loon3/1df4bbc4aa6772404f78c94e99d9f950 to your computer and use it in GitHub Desktop.
ECIES Bitcoin Example
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