Author Topic: Help: Decrypt / Decode Memo from tx - bitsharesjs (solved)  (Read 96 times)

0 Members and 1 Guest are viewing this topic.

Offline TechnoL0g

  • Newbie
  • *
  • Posts: 4
    • View Profile
Help: Decrypt / Decode Memo from tx - bitsharesjs (solved)
« on: June 04, 2018, 02:05:12 pm »
Need help with working examples of decode memo on bitsharesjs.
node -v 8.11.1

I get the transaction history:

Code: [Select]
{
       from: '<BTS Address>',
       to: '<BTS Address>',
       nonce: '<random>',
       message: '<encrypted message>'
}

What sequence of steps is needed to perform the decryption?

by doing:

Code: [Select]
Aes.decrypt_with_checksum(
          private_key,
          public_key,
          memo.nonce,
          memo.message
        ).toString("utf-8");


getting an error: transfer memo exception ...
~TypeError: private_key.get_shared_secret is not a function.
~node_modules\bitsharesjs\dist\ecc\src\aes.js:97


Has anyone encountered a similar problem?

« Last Edit: June 06, 2018, 11:45:55 am by TechnoL0g »

Offline abit

  • Committee member
  • Hero Member
  • *
  • Posts: 3140
    • View Profile
    • Steemit Blog
  • BitShares: abit
  • GitHub: abitmore
Re: Help: Decrypt / Decode Memo from tx - bitsharesjs
« Reply #1 on: June 05, 2018, 10:19:30 am »
Something like this.

If you have private key of `memo.to`:

 Aes.decrypt_with_checksum(
          PublicKey.fromPublicKeyString(memo.from),
          PrivateKey.fromWif(private_key),
          memo.nonce,
          memo.message
        ).toString("utf-8");

BTS account: abit
BTS committee member: abit
BTS witness: in.abit

Offline TechnoL0g

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Help: Decrypt / Decode Memo from tx - bitsharesjs
« Reply #2 on: June 05, 2018, 08:12:01 pm »
Something like this.

If you have private key of `memo.to`:

 Aes.decrypt_with_checksum(
          PublicKey.fromPublicKeyString(memo.from),
          PrivateKey.fromWif(private_key),
          memo.nonce,
          memo.message
        ).toString("utf-8");

Thanks a friend, it helped me with the above problem!

But now a new one has appeared: AssertionError [ERR_ASSERTION]: Expecting key to begin with GPH, instead got BTS

I need to specify the main blockchain type? but where, heh ..
I found the config in bitsharesjs-ws, probably do not look in the right direction.

It is only necessary to decrypt memo, this should not be a big problem.
Unfortunately in the documentation, I could not find any specifications for this particular issue, only python lib.
« Last Edit: June 05, 2018, 09:19:49 pm by TechnoL0g »

Offline TechnoL0g

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Help: Decrypt / Decode Memo from tx - bitsharesjs
« Reply #3 on: June 06, 2018, 12:06:50 am »
Problem Solved.

First it was necessary to connect to the Bitshares network and initialize:


Code: [Select]
import {Apis} from "bitsharesjs-ws";
import {PrivateKey, key, PublicKey, Aes} from "../lib";

Apis.instance("wss://bitshares.openledger.info/ws", true).init_promise.then((res) => {
    console.log("connected to:", res[0].network);
    code..
}

Thx you for helping the newcomer!
« Last Edit: June 06, 2018, 12:15:56 am by TechnoL0g »