From 0b198e08888830890622e983445c75f947186b4c Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 13 Oct 2016 20:02:42 +0200 Subject: refactor work queue --- lib/wallet/cryptoLib.ts | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'lib/wallet/cryptoLib.ts') diff --git a/lib/wallet/cryptoLib.ts b/lib/wallet/cryptoLib.ts index 7969682b4..d471b577d 100644 --- a/lib/wallet/cryptoLib.ts +++ b/lib/wallet/cryptoLib.ts @@ -79,9 +79,13 @@ namespace RpcFunctions { let coinPub = coinPriv.getPublicKey(); let blindingFactor = native.RsaBlindingKeySecret.create(); let pubHash: native.HashCode = coinPub.hash(); - let ev: native.ByteArray = native.rsaBlind(pubHash, - blindingFactor, - denomPub); + let ev = native.rsaBlind(pubHash, + blindingFactor, + denomPub); + + if (!ev) { + throw Error("couldn't blind (malicious exchange key?)"); + } if (!denom.fee_withdraw) { throw Error("Field fee_withdraw missing"); @@ -234,10 +238,10 @@ namespace RpcFunctions { } - function createWithdrawSession(kappa: number, meltCoin: Coin, - newCoinDenoms: Denomination[], - meltAmount: AmountJson, - meltFee: AmountJson): RefreshSession { + export function createWithdrawSession(kappa: number, meltCoin: Coin, + newCoinDenoms: Denomination[], + meltAmount: AmountJson, + meltFee: AmountJson): RefreshSession { let sessionHc = new HashContext(); @@ -268,9 +272,12 @@ namespace RpcFunctions { let blindingFactor = native.RsaBlindingKeySecret.create(); let pubHash: native.HashCode = coinPub.hash(); let denomPub = native.RsaPublicKey.fromCrock(newCoinDenoms[i].denom_pub); - let ev: native.ByteArray = native.rsaBlind(pubHash, - blindingFactor, - denomPub); + let ev = native.rsaBlind(pubHash, + blindingFactor, + denomPub); + if (!ev) { + throw Error("couldn't blind (malicious exchange key?)"); + } let preCoin: RefreshPreCoin = { blindingKey: blindingFactor.toCrock(), coinEv: ev.toCrock(), -- cgit v1.2.3