diff options
Diffstat (limited to 'packages/taler-wallet-core/src/crypto')
-rw-r--r-- | packages/taler-wallet-core/src/crypto/workers/cryptoApi.ts | 5 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts | 18 |
2 files changed, 23 insertions, 0 deletions
diff --git a/packages/taler-wallet-core/src/crypto/workers/cryptoApi.ts b/packages/taler-wallet-core/src/crypto/workers/cryptoApi.ts index 286de5a17..29f3b02b2 100644 --- a/packages/taler-wallet-core/src/crypto/workers/cryptoApi.ts +++ b/packages/taler-wallet-core/src/crypto/workers/cryptoApi.ts @@ -42,6 +42,7 @@ import { PlanchetCreationResult, PlanchetCreationRequest, DepositInfo, + MakeSyncSignatureRequest, } from "../../types/walletTypes"; import * as timer from "../../util/timer"; @@ -455,4 +456,8 @@ export class CryptoApi { benchmark(repetitions: number): Promise<BenchmarkResult> { return this.doRpc<BenchmarkResult>("benchmark", 1, repetitions); } + + makeSyncSignature(req: MakeSyncSignatureRequest): Promise<string> { + return this.doRpc<string>("makeSyncSignature", 3, req); + } } diff --git a/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts b/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts index 46ac7c8a6..41836fdfa 100644 --- a/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts +++ b/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts @@ -43,6 +43,7 @@ import { PlanchetCreationResult, PlanchetCreationRequest, DepositInfo, + MakeSyncSignatureRequest, } from "../../types/walletTypes"; import { AmountJson, Amounts } from "../../util/amounts"; import * as timer from "../../util/timer"; @@ -85,6 +86,7 @@ enum SignaturePurpose { WALLET_COIN_LINK = 1204, EXCHANGE_CONFIRM_RECOUP = 1039, EXCHANGE_CONFIRM_RECOUP_REFRESH = 1041, + SYNC_BACKUP_UPLOAD = 1450, } function amountToBuffer(amount: AmountJson): Uint8Array { @@ -589,4 +591,20 @@ export class CryptoImplementation { }, }; } + + makeSyncSignature(req: MakeSyncSignatureRequest): string { + const hNew = decodeCrock(req.newHash); + let hOld: Uint8Array; + if (req.oldHash) { + hOld = decodeCrock(req.oldHash); + } else { + hOld = new Uint8Array(64); + } + const sigBlob = new SignaturePurposeBuilder(SignaturePurpose.SYNC_BACKUP_UPLOAD) + .put(hOld) + .put(hNew) + .build(); + const uploadSig = eddsaSign(sigBlob, decodeCrock(req.accountPriv)); + return encodeCrock(uploadSig); + } } |