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. ...

Get Blockchain for Enterprise now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.