public static function getSharedSecret(
        EncryptionSecretKey $privateKey,
        EncryptionPublicKey $publicKey,
        bool $get_as_object = false
    ): object {
        if ($get_as_object) {
            return new EncryptionKey(
                new HiddenString(
                    \sodium_crypto_scalarmult(
                        $privateKey->getRawKeyMaterial(),
                        $publicKey->getRawKeyMaterial()
                    )
                )
            );
        }
        return new HiddenString(
            \sodium_crypto_scalarmult(
                $privateKey->getRawKeyMaterial(),
                $publicKey->getRawKeyMaterial()
            )
        );
    }
public static function getSharedSecret(
        EncryptionSecretKey $privateKey,
        EncryptionPublicKey $publicKey,
        bool $get_as_object = false
    ): object {
        if ($get_as_object) {
            return new EncryptionKey(
                new HiddenString(
                    \sodium_crypto_scalarmult(
                        $privateKey->getRawKeyMaterial(),
                        $publicKey->getRawKeyMaterial()
                    )
                )
            );
        }
        return new HiddenString(
            \sodium_crypto_scalarmult(
                $privateKey->getRawKeyMaterial(),
                $publicKey->getRawKeyMaterial()
            )
        );
    }
public static function getSharedSecret ( EncryptionSecretKey $ privateKey , EncryptionPublicKey $ publicKey , bool $ get_as_object = false ) : object { if ( $ get_as_object ) { return new EncryptionKey ( new HiddenString ( \ sodium_crypto_scalarmult ( $ privateKey -> getRawKeyMaterial ( ) , $ publicKey -> getRawKeyMaterial ( ) ) ) ) ; } return new HiddenString ( \ sodium_crypto_scalarmult ( $ privateKey -> getRawKeyMaterial ( ) , $ publicKey -> getRawKeyMaterial ( ) ) ) ; }
Diffie-Hellman, ECDHE, etc.

Get a shared secret from a private key you possess and a public key for
the intended message recipient

@param EncryptionSecretKey $privateKey Private key (yours)
@param EncryptionPublicKey $publicKey  Public key (theirs)
@param bool $get_as_object             Get as a Key object?
@return HiddenString|Key

@throws InvalidKey
@throws \TypeError
Diffie - Hellman ECDHE etc .