O'Reilly logo

Blockchain for Enterprise by Narayan Prusty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Writing Python and JS scripts for testing

Let's now write some test scripts to test the smart contract and the data and user flow. We will write Python scripts to encrypt data, decrypt data, generate a re-encryption key, and re-encrypt data. And we will use Node.js to invoke the Python scripts and smart contract functions.

Create a directory named test. In this, create a file named encrypt.py and place the following code into it:

from npre import bbs98pre = bbs98.PRE()import base64import syspublicKey = base64.b64decode(sys.argv[1])encrypted_message = pre.encrypt(publicKey, sys.argv[2])print(base64.b64encode(encrypted_message))

This script takes two arguments, publicKey and a raw message. publicKey is passed as a base64 encoded public key. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required