private void generateSharedECDHSecret(final byte[] xy) {
        if(node.getProvisioneePublicKeyXY() == null) {
            node.setProvisioneePublicKeyXY(xy);
        } else {
            // Mark the node as secure if the provisionee public key is not null.
            // This would assume that the key was obtained via an OOB method and is provided by the
            // user before starting provisioning.
            node.markAsSecure();
        }

        final byte[] xComponent = new byte[32];
        System.arraycopy(xy, 0, xComponent, 0, xComponent.length);

        final byte[] yComponent = new byte[32];
        System.arraycopy(xy, 32, yComponent, 0, xComponent.length);

        MeshLogger.verbose(TAG, "Provisionee X: " + MeshParserUtils.bytesToHex(yComponent, false));
        MeshLogger.verbose(TAG, "Provisionee Y: " + MeshParserUtils.bytesToHex(xComponent, false));

        final BigInteger x = BigIntegers.fromUnsignedByteArray(xy, 0, 32);
        final BigInteger y = BigIntegers.fromUnsignedByteArray(xy, 32, 32);

        final ECParameterSpec ecParameters = ECNamedCurveTable.getParameterSpec("secp256r1");
        ECCurve curve = ecParameters.getCurve();
        ECPoint ecPoint = curve.validatePoint(x, y);

        ECPublicKeySpec keySpec = new ECPublicKeySpec(ecPoint, ecParameters);
        KeyFactory keyFactory;
        try {
            keyFactory = KeyFactory.getInstance("ECDH", "SC");
            ECPublicKey publicKey = (ECPublicKey) keyFactory.generatePublic(keySpec);

            KeyAgreement a = KeyAgreement.getInstance("ECDH", "SC");
            a.init(mProvisionerPrivateKey);
            a.doPhase(publicKey, true);

            final byte[] sharedECDHSecret = a.generateSecret();
            node.setSharedECDHSecret(sharedECDHSecret);
            MeshLogger.verbose(TAG, "ECDH Secret: " + MeshParserUtils.bytesToHex(sharedECDHSecret, false));

        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        } catch (NoSuchProviderException e) {
            e.printStackTrace();
        } catch (InvalidKeySpecException e) {
            e.printStackTrace();
        } catch (InvalidKeyException e) {
            e.printStackTrace();
        }
    }
Constructs the provisioning publick key state.

@param node                        {@link UnprovisionedMeshNode} node.
@param internalTransportCallbacks  {@link InternalTransportCallbacks} callbacks.
@param provisioningStatusCallbacks {@link MeshProvisioningStatusCallbacks} callbacks.
mesh/src/main/java/no/nordicsemi/android/mesh/provisionerstates/ProvisioningPublicKeyState.java