function bigint2mpi(mpi_ptr,bi_num){
        if(!this.handle) this.handle = Module["_malloc"](4);//pointer to *gcry_mpi_t
        var bi_num_str = Module["BigInt"]["bigInt2str"](bi_num,16);
        //gcry_error_t gcry_mpi_scan (gcry_mpi_t *r_mpi, enum gcry_mpi_format format, const unsigned char *buffer, size_t buflen, size_t *nscanned)
        var err = Module["libgcrypt"]["mpi_scan"](this.handle,4,bi_num_str,0,0); //4 == HEX Format
        assert(err===0,"bigint2mpi:"+Module["libgcrypt"]["strerror"](err));
    
        var scanned_mpi_ptr = Module["getValue"](this.handle,"i32");
        assert(scanned_mpi_ptr !==0, "NULL scanned mpi in bigint2mpi()");
    
        Module["libgcrypt"]["mpi_set"](mpi_ptr,scanned_mpi_ptr);
        Module["libgcrypt"]["mpi_release"](scanned_mpi_ptr);
    }
/* convert bi_num (BigInt) to hex string then scan it into a new gcry_mpi_t, using gcry_mpi_scan
        copy the new mpi to mpi_ptr */
convert bi_num (BigInt) to hex string then scan it into a new gcry_mpi_t, using gcry_mpi_scan
copy the new mpi to mpi_ptr
convert bi_num ( BigInt ) to hex string then scan it into a new gcry_mpi_t using gcry_mpi_scan copy the new mpi to mpi_ptr
function bigint2mpi(mpi_ptr,bi_num){
        if(!this.handle) this.handle = Module["_malloc"](4);
        var bi_num_str = Module["BigInt"]["bigInt2str"](bi_num,16);
        var err = Module["libgcrypt"]["mpi_scan"](this.handle,4,bi_num_str,0,0); 
        assert(err===0,"bigint2mpi:"+Module["libgcrypt"]["strerror"](err));
        var scanned_mpi_ptr = Module["getValue"](this.handle,"i32");
        assert(scanned_mpi_ptr !==0, "NULL scanned mpi in bigint2mpi()");
        Module["libgcrypt"]["mpi_set"](mpi_ptr,scanned_mpi_ptr);
        Module["libgcrypt"]["mpi_release"](scanned_mpi_ptr);
    }
function bigint2mpi ( mpi_ptr , bi_num ) { if ( ! this . handle ) this . handle = Module [ "_malloc" ] ( 4 ) ; var bi_num_str = Module [ "BigInt" ] [ "bigInt2str" ] ( bi_num , 16 ) ; var err = Module [ "libgcrypt" ] [ "mpi_scan" ] ( this . handle , 4 , bi_num_str , 0 , 0 ) ; assert ( err === 0 , "bigint2mpi:" + Module [ "libgcrypt" ] [ "strerror" ] ( err ) ) ; var scanned_mpi_ptr = Module [ "getValue" ] ( this . handle , "i32" ) ; assert ( scanned_mpi_ptr !== 0 , "NULL scanned mpi in bigint2mpi()" ) ; Module [ "libgcrypt" ] [ "mpi_set" ] ( mpi_ptr , scanned_mpi_ptr ) ; Module [ "libgcrypt" ] [ "mpi_release" ] ( scanned_mpi_ptr ) ; }
convert bi_num (BigInt) to hex string then scan it into a new gcry_mpi_t, using gcry_mpi_scan
copy the new mpi to mpi_ptr
convert bi_num ( BigInt ) to hex string then scan it into a new gcry_mpi_t using gcry_mpi_scan copy the new mpi to mpi_ptr
//pointer to *gcry_mpi_t //gcry_error_t gcry_mpi_scan (gcry_mpi_t *r_mpi, enum gcry_mpi_format format, const unsigned char *buffer, size_t buflen, size_t *nscanned) //4 == HEX Format