lib/auth/request-dh-params.js
function deserializeDHInnerData(context) {
    var decryptedDHParamsWithHash = context.decryptedDHParams;
    if (logger.isDebugEnabled()) {
        logger.debug('decryptedDHParamsWithHash(%s) = %s', decryptedDHParamsWithHash.length, decryptedDHParamsWithHash.toString('hex'));
    }
    var decryptedDHParams = decryptedDHParamsWithHash.slice(20, 564 + 20);
    if (logger.isDebugEnabled()) {
        logger.debug('decryptedDHParams(%s) = %s', decryptedDHParams.length, decryptedDHParams.toString('hex'));
    }
    var serverDHInnerData = new mtproto.type.Server_DH_inner_data({
        buffer: decryptedDHParams
    }).deserialize();
    if (logger.isDebugEnabled()) {
        logger.debug('serverDHInnerData = %s obtained in %sms', serverDHInnerData.toPrintable(), context.reqDHDuration);
    }
    // Check if the nonces are consistent
    if (serverDHInnerData.nonce !== context.serverDHParams.nonce) {
        throw createError('Nonce mismatch %s != %s', context.serverDHParams.nonce, serverDHInnerData.nonce);
    }
    if (serverDHInnerData.server_nonce !== context.serverDHParams.server_nonce) {
        throw createError('ServerNonce mismatch %s != %s', context.serverDHParams.server_nonce, serverDHInnerData.server_nonce);
    }
    // Synch the local time with the server time
    mtproto.time.timeSynchronization(serverDHInnerData.server_time, context.reqDHDuration);
    context.serverDHInnerData = serverDHInnerData;
    return context;
}
function deserializeDHInnerData(context) {
    var decryptedDHParamsWithHash = context.decryptedDHParams;
    if (logger.isDebugEnabled()) {
        logger.debug('decryptedDHParamsWithHash(%s) = %s', decryptedDHParamsWithHash.length, decryptedDHParamsWithHash.toString('hex'));
    }
    var decryptedDHParams = decryptedDHParamsWithHash.slice(20, 564 + 20);
    if (logger.isDebugEnabled()) {
        logger.debug('decryptedDHParams(%s) = %s', decryptedDHParams.length, decryptedDHParams.toString('hex'));
    }
    var serverDHInnerData = new mtproto.type.Server_DH_inner_data({
        buffer: decryptedDHParams
    }).deserialize();
    if (logger.isDebugEnabled()) {
        logger.debug('serverDHInnerData = %s obtained in %sms', serverDHInnerData.toPrintable(), context.reqDHDuration);
    }
    // Check if the nonces are consistent
    if (serverDHInnerData.nonce !== context.serverDHParams.nonce) {
        throw createError('Nonce mismatch %s != %s', context.serverDHParams.nonce, serverDHInnerData.nonce);
    }
    if (serverDHInnerData.server_nonce !== context.serverDHParams.server_nonce) {
        throw createError('ServerNonce mismatch %s != %s', context.serverDHParams.server_nonce, serverDHInnerData.server_nonce);
    }
    // Synch the local time with the server time
    mtproto.time.timeSynchronization(serverDHInnerData.server_time, context.reqDHDuration);
    context.serverDHInnerData = serverDHInnerData;
    return context;
}
function deserializeDHInnerData ( context ) { var decryptedDHParamsWithHash = context . decryptedDHParams ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( 'decryptedDHParamsWithHash(%s) = %s' , decryptedDHParamsWithHash . length , decryptedDHParamsWithHash . toString ( 'hex' ) ) ; } var decryptedDHParams = decryptedDHParamsWithHash . slice ( 20 , 564 + 20 ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( 'decryptedDHParams(%s) = %s' , decryptedDHParams . length , decryptedDHParams . toString ( 'hex' ) ) ; } var serverDHInnerData = new mtproto . type . Server_DH_inner_data ( { buffer : decryptedDHParams } ) . deserialize ( ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( 'serverDHInnerData = %s obtained in %sms' , serverDHInnerData . toPrintable ( ) , context . reqDHDuration ) ; } // Check if the nonces are consistent if ( serverDHInnerData . nonce !== context . serverDHParams . nonce ) { throw createError ( 'Nonce mismatch %s != %s' , context . serverDHParams . nonce , serverDHInnerData . nonce ) ; } if ( serverDHInnerData . server_nonce !== context . serverDHParams . server_nonce ) { throw createError ( 'ServerNonce mismatch %s != %s' , context . serverDHParams . server_nonce , serverDHInnerData . server_nonce ) ; } // Synch the local time with the server time mtproto . time . timeSynchronization ( serverDHInnerData . server_time , context . reqDHDuration ) ; context . serverDHInnerData = serverDHInnerData ; return context ; }
De-serialize the server DH inner data
De - serialize the server DH inner data