src/crypto/cryptoHelpers.js
function(priv, network, _expectedAddress) {
    // Errors
    if (!priv || !network || !_expectedAddress) throw new Error('Missing argument !');
    if (!Helpers.isPrivateKeyValid(priv)) throw new Error('Private key is not valid !');
    //Processing
    let expectedAddress = _expectedAddress.toUpperCase().replace(/-/g, '');
    let kp = KeyPair.create(priv);
    let address = Address.toAddress(kp.publicKey.toString(), network);
    // Result
    return address === expectedAddress;
}
function(priv, network, _expectedAddress) {
    // Errors
    if (!priv || !network || !_expectedAddress) throw new Error('Missing argument !');
    if (!Helpers.isPrivateKeyValid(priv)) throw new Error('Private key is not valid !');
    //Processing
    let expectedAddress = _expectedAddress.toUpperCase().replace(/-/g, '');
    let kp = KeyPair.create(priv);
    let address = Address.toAddress(kp.publicKey.toString(), network);
    // Result
    return address === expectedAddress;
}
function ( priv , network , _expectedAddress ) { // Errors if ( ! priv || ! network || ! _expectedAddress ) throw new Error ( 'Missing argument !' ) ; if ( ! Helpers . isPrivateKeyValid ( priv ) ) throw new Error ( 'Private key is not valid !' ) ; //Processing let expectedAddress = _expectedAddress . toUpperCase ( ) . replace ( / - / g , '' ) ; let kp = KeyPair . create ( priv ) ; let address = Address . toAddress ( kp . publicKey . toString ( ) , network ) ; // Result return address === expectedAddress ; }
Check if a private key correspond to an account address

@param {string} priv - An account private key
@param {number} network - A network id
@param {string} _expectedAddress - The expected NEM address

@return {boolean} - True if valid, false otherwise
Check if a private key correspond to an account address