async encrypt(message){

        if(! this.isSecure){
            throw new Error(`Engine is not secure to use, 
                please make sure you call checkSecurity() method before using engine.`);
        }

        if(! this.isReady()){
            throw new Error(`Engine is not initialized correctly!`);
        }

        const tempPrivateKey = await bigIntManager.getInRange(this.p.prev(), 1);

        /**
         * @property {bigInteger.BigInteger} lastEncryptionKey keeps the last used encryption key.
         */
        this.lastEncryptionKey = tempPrivateKey;

        let msgBI;
        if(typeof message === 'string'){
            throw new Error('Not implemented yet! the message should of type number');
        }else if(typeof message === 'number')
            msgBI = bigInteger(message);
        else if(message instanceof bigInteger)
            msgBI = message;
        else
            throw new Error('Not supported message type');
        
        log(this.y.modPow(tempPrivateKey, this.p).toString());
        return {
            c1 : this.g.modPow(tempPrivateKey, this.p),
            c2 : this.y.modPow(tempPrivateKey, this.p).multiply(msgBI).remainder(this.p)
        };
    }
/**
     * Encrypt the given message under ElGamal cryptosystem schema. By default this use your own 
     * public key unless you change it by setting publicKey.
     * @param {number|bigInteger.BigInteger} message - The message which you want to encrypt it. please note due to the ElGamal schema
     * it's must be a member of underlying group.
     * @returns {Promise<cipherText>} - The resulted cipher text which you can decrypt it by using decrypt() method. 
     * @throws Will throw an Error if the message is not a number
     */
Encrypt the given message under ElGamal cryptosystem schema. By default this use your own
public key unless you change it by setting publicKey.
@param {number|bigInteger.BigInteger} message - The message which you want to encrypt it. please note due to the ElGamal schema
it's must be a member of underlying group.
@returns {Promise} - The resulted cipher text which you can decrypt it by using decrypt() method.
@throws Will throw an Error if the message is not a number
Encrypt the given message under ElGamal cryptosystem schema . By default this use your own public key unless you change it by setting publicKey . @param { number|bigInteger . BigInteger } message - The message which you want to encrypt it . please note due to the ElGamal schema it ' s must be a member of underlying group . @returns { Promise } - The resulted cipher text which you can decrypt it by using decrypt () method . @throws Will throw an Error if the message is not a number
async encrypt(message){
        if(! this.isSecure){
            throw new Error(`Engine is not secure to use, 
                please make sure you call checkSecurity() method before using engine.`);
        }
        if(! this.isReady()){
            throw new Error(`Engine is not initialized correctly!`);
        }
        const tempPrivateKey = await bigIntManager.getInRange(this.p.prev(), 1);
        this.lastEncryptionKey = tempPrivateKey;
        let msgBI;
        if(typeof message === 'string'){
            throw new Error('Not implemented yet! the message should of type number');
        }else if(typeof message === 'number')
            msgBI = bigInteger(message);
        else if(message instanceof bigInteger)
            msgBI = message;
        else
            throw new Error('Not supported message type');
        log(this.y.modPow(tempPrivateKey, this.p).toString());
        return {
            c1 : this.g.modPow(tempPrivateKey, this.p),
            c2 : this.y.modPow(tempPrivateKey, this.p).multiply(msgBI).remainder(this.p)
        };
    }
async encrypt ( message ) { if ( ! this . isSecure ) { throw new Error ( ` ` ) ; } if ( ! this . isReady ( ) ) { throw new Error ( ` ` ) ; } const tempPrivateKey = await bigIntManager . getInRange ( this . p . prev ( ) , 1 ) ; this . lastEncryptionKey = tempPrivateKey ; let msgBI ; if ( typeof message === 'string' ) { throw new Error ( 'Not implemented yet! the message should of type number' ) ; } else if ( typeof message === 'number' ) msgBI = bigInteger ( message ) ; else if ( message instanceof bigInteger ) msgBI = message ; else throw new Error ( 'Not supported message type' ) ; log ( this . y . modPow ( tempPrivateKey , this . p ) . toString ( ) ) ; return { c1 : this . g . modPow ( tempPrivateKey , this . p ) , c2 : this . y . modPow ( tempPrivateKey , this . p ) . multiply ( msgBI ) . remainder ( this . p ) } ; }
Encrypt the given message under ElGamal cryptosystem schema.
Encrypt the given message under ElGamal cryptosystem schema .
/**
         * @property {bigInteger.BigInteger} lastEncryptionKey keeps the last used encryption key.
         */