function getSharedSecret(public_key) {
        public_key = PublicKey(public_key);
        let KB = public_key.toUncompressed().toBuffer();
        let KBP = Point.fromAffine(
            secp256k1,
            BigInteger.fromBuffer( KB.slice( 1,33 )), // x
            BigInteger.fromBuffer( KB.slice( 33,65 )) // y
        );
        let r = toBuffer();
        let P = KBP.multiply(BigInteger.fromBuffer(r));
        let S = P.affineX.toBuffer({size: 32});
        // SHA512 used in ECIES
        return hash.sha512(S);
    }