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

0 Members and 1 Guest are viewing this topic.

Offline TechnoL0g

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 »

Offline TechnoL0g

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 abit

  • Committee member
  • Hero Member
  • *
  • Posts: 4669
    • View Profile
    • Abit's Hive Blog
  • BitShares: abit
  • GitHub: abitmore
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");

BitShares committee member: abit
BitShares witness: in.abit

Offline TechnoL0g

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 »