Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const erc20Token = await deployed( 'TestERC20', { deployID: `deploy${tradeSymbol}` } )
console.log('ERC20 Token Address ', erc20Token.address)
const token = await deployed( 'ZkAssetTradeable', { deployID: `deploy${tradeSymbol}` } )
LOGGER.info('Trade Symbol ' , tradeSymbol)
LOGGER.info('ZkMintableAsset Address ', token.address)
LOGGER.info('Deployer Address ' , deployerAddress)
LOGGER.info('Mintee address' , minteeAddress)
LOGGER.info('Mintee public key' , minteePublicKey)
LOGGER.info('Mintee amount' , minteeAmount)
LOGGER.info('mintFromZero' , mintFromZero)
assert( minteeAmount.gte(0), 'Mintee amount must be greater than or equal to zero.' )
assert( minteePublicKey.startsWith('0x04'), 'AZTEC public keys must start with 0x04' )
const derivedAddress =
util.toChecksumAddress(
util.publicToAddress('0x' + minteePublicKey.slice(4)).toString('hex'))
assert.equal(derivedAddress, minteeAddress,
`Mintee address from pubKey was ${derivedAddress} instead of ${minteeAddress}`)
const baseKey =`zkNotes/${chainId}/${minteeAddress}/${token.address}`
const mintKey =`zkMintedTotals/${chainId}/${deployerAddress}/${token.address}`
LOGGER.info(`Mint Key ${mintKey}`)
const minteeNote = await aztec.note.create(minteePublicKey, minteeAmount)
LOGGER.info(`Created new mintee note ${minteeNote.noteHash}`)
let oldTotalNote, oldTotalNoteHash, mintedFromZero
try {
if (mintFromZero) { throw new Error('Minting from zero.') }
const oldTotalNoteRaw = await bm.inputter(mintKey)
LOGGER.info('oldTotalNoteRaw', oldTotalNoteRaw)
oldTotalNoteHash = oldTotalNoteRaw.get('zkNoteHash')
_getAddressForWallet(wallet) {
if (typeof wallet.pubKey === 'undefined') {
return '0x' + ethUtil.privateToAddress(wallet.privKey).toString('hex');
}
return '0x' + ethUtil.publicToAddress(wallet.pubKey, true).toString('hex');
}
const publicKeyToAddress = (pubKey) => {
const addr = ethUtil.publicToAddress(Buffer.from(pubKey, 'hex')).toString('hex');
const address = ethUtil.toChecksumAddress(addr);
return address;
};
_addressFromId (pathBase, i) {
const dkey = this.hdk.derive(`${pathBase}/${i}`)
const address = ethUtil
.publicToAddress(dkey.publicKey, true)
.toString('hex')
return ethUtil.toChecksumAddress(address)
}
const r = data.slice(64, 96)
const s = data.slice(96, 128)
let publicKey
try {
publicKey = ecrecover(msgHash, new BN(v).toNumber(), r, s)
} catch (e) {
return {
gasUsed,
returnValue: Buffer.alloc(0),
}
}
return {
gasUsed,
returnValue: setLengthLeft(publicToAddress(publicKey), 32),
}
}
_getAddress (wallet) {
if (typeof wallet.pubKey === 'undefined') {
return '0x' + ethUtil.privateToAddress(wallet.privKey).toString('hex')
} else {
return '0x' + ethUtil.publicToAddress(wallet.pubKey, true).toString('hex')
}
}
function verifyAttribute(attribute, RPCsig) {
var hash = ethUtils.sha3(attribute);
var sig = ethUtils.fromRpcSig(RPCsig);
var pubkey = ethUtils.ecrecover(hash, sig.v, sig.r, sig.s);
return '0x' + ethUtils.publicToAddress(pubkey).toString('hex');
}
getAddress() {
if (this.isAddress) return this.publicKey;
return publicToAddress(this.publicKey, true);
}
Wallet.prototype.getAddress = function () {
if (typeof this.pubKey === 'undefined') {
return util.privateToAddress(this.privKey)
} else {
return util.publicToAddress(this.pubKey, true)
}
}