diff options
author | Florian Dold <florian.dold@gmail.com> | 2016-10-13 20:02:42 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2016-10-13 20:02:42 +0200 |
commit | 0b198e08888830890622e983445c75f947186b4c (patch) | |
tree | 562eb58178c57f44c885adbf2bf52c578f1a32a8 /lib/wallet/cryptoLib.ts | |
parent | d3b49c0a2fb5d8a888e533fd63545103abd919c5 (diff) | |
download | wallet-core-0b198e08888830890622e983445c75f947186b4c.tar.xz |
refactor work queue
Diffstat (limited to 'lib/wallet/cryptoLib.ts')
-rw-r--r-- | lib/wallet/cryptoLib.ts | 27 |
1 files changed, 17 insertions, 10 deletions
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(), |