aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-util/src/talerTypes.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2021-11-17 10:23:22 +0100
committerFlorian Dold <florian@dold.me>2021-11-17 10:23:30 +0100
commit9f0429cb2f8ad9cb2e98a787139602d913c1aefa (patch)
treecda55e2d07a291dd2ff6f243bb423121ecf220b3 /packages/taler-util/src/talerTypes.ts
parenta994009d2f094c4d9c12da68dac3abb28bdef4b3 (diff)
downloadwallet-core-9f0429cb2f8ad9cb2e98a787139602d913c1aefa.tar.xz
wallet: implement exchange protocol v9
Diffstat (limited to 'packages/taler-util/src/talerTypes.ts')
-rw-r--r--packages/taler-util/src/talerTypes.ts77
1 files changed, 68 insertions, 9 deletions
diff --git a/packages/taler-util/src/talerTypes.ts b/packages/taler-util/src/talerTypes.ts
index 56110ec1e..04d700483 100644
--- a/packages/taler-util/src/talerTypes.ts
+++ b/packages/taler-util/src/talerTypes.ts
@@ -59,7 +59,7 @@ export class Denomination {
/**
* Public signing key of the denomination.
*/
- denom_pub: string;
+ denom_pub: DenominationPubKey;
/**
* Fee for withdrawing.
@@ -158,7 +158,7 @@ export interface RecoupRequest {
/**
* Signature over the coin public key by the denomination.
*/
- denom_sig: string;
+ denom_sig: UnblindedSignature;
/**
* Coin public key of the coin we want to refund.
@@ -198,6 +198,11 @@ export interface RecoupConfirmation {
old_coin_pub?: string;
}
+export interface UnblindedSignature {
+ cipher: DenomKeyType.Rsa;
+ rsa_signature: string;
+}
+
/**
* Deposit permission for a single coin.
*/
@@ -213,7 +218,7 @@ export interface CoinDepositPermission {
/**
* Signature made by the denomination public key.
*/
- ub_sig: string;
+ ub_sig: UnblindedSignature;
/**
* The denomination public key associated with this coin.
*/
@@ -779,8 +784,38 @@ export class TipPickupGetResponse {
expiration: Timestamp;
}
+export enum DenomKeyType {
+ Rsa = 1,
+ ClauseSchnorr = 2,
+}
+
+export interface RsaBlindedDenominationSignature {
+ cipher: DenomKeyType.Rsa;
+ blinded_rsa_signature: string;
+}
+
+export interface CSBlindedDenominationSignature {
+ cipher: DenomKeyType.ClauseSchnorr;
+}
+
+export type BlindedDenominationSignature =
+ | RsaBlindedDenominationSignature
+ | CSBlindedDenominationSignature;
+
+export const codecForBlindedDenominationSignature = () =>
+ buildCodecForUnion<BlindedDenominationSignature>()
+ .discriminateOn("cipher")
+ .alternative(1, codecForRsaBlindedDenominationSignature())
+ .build("BlindedDenominationSignature");
+
+export const codecForRsaBlindedDenominationSignature = () =>
+ buildCodecForObject<RsaBlindedDenominationSignature>()
+ .property("cipher", codecForConstNumber(1))
+ .property("blinded_rsa_signature", codecForString())
+ .build("RsaBlindedDenominationSignature");
+
export class WithdrawResponse {
- ev_sig: string;
+ ev_sig: BlindedDenominationSignature;
}
/**
@@ -792,7 +827,7 @@ export interface CoinDumpJson {
/**
* The coin's denomination's public key.
*/
- denom_pub: string;
+ denom_pub: DenominationPubKey;
/**
* Hash of denom_pub.
*/
@@ -875,7 +910,7 @@ export interface ExchangeMeltResponse {
}
export interface ExchangeRevealItem {
- ev_sig: string;
+ ev_sig: BlindedDenominationSignature;
}
export interface ExchangeRevealResponse {
@@ -994,6 +1029,30 @@ export interface BankWithdrawalOperationPostResponse {
transfer_done: boolean;
}
+export type DenominationPubKey = RsaDenominationPubKey | CsDenominationPubKey;
+
+export interface RsaDenominationPubKey {
+ cipher: 1;
+ rsa_public_key: string;
+ age_mask?: number;
+}
+
+export interface CsDenominationPubKey {
+ cipher: 2;
+}
+
+export const codecForDenominationPubKey = () =>
+ buildCodecForUnion<DenominationPubKey>()
+ .discriminateOn("cipher")
+ .alternative(1, codecForRsaDenominationPubKey())
+ .build("DenominationPubKey");
+
+export const codecForRsaDenominationPubKey = () =>
+ buildCodecForObject<RsaDenominationPubKey>()
+ .property("cipher", codecForConstNumber(1))
+ .property("rsa_public_key", codecForString())
+ .build("DenominationPubKey");
+
export const codecForBankWithdrawalOperationPostResponse = (): Codec<BankWithdrawalOperationPostResponse> =>
buildCodecForObject<BankWithdrawalOperationPostResponse>()
.property("transfer_done", codecForBoolean())
@@ -1008,7 +1067,7 @@ export type CoinPublicKeyString = string;
export const codecForDenomination = (): Codec<Denomination> =>
buildCodecForObject<Denomination>()
.property("value", codecForString())
- .property("denom_pub", codecForString())
+ .property("denom_pub", codecForDenominationPubKey())
.property("fee_withdraw", codecForString())
.property("fee_deposit", codecForString())
.property("fee_refresh", codecForString())
@@ -1242,7 +1301,7 @@ export const codecForRecoupConfirmation = (): Codec<RecoupConfirmation> =>
export const codecForWithdrawResponse = (): Codec<WithdrawResponse> =>
buildCodecForObject<WithdrawResponse>()
- .property("ev_sig", codecForString())
+ .property("ev_sig", codecForBlindedDenominationSignature())
.build("WithdrawResponse");
export const codecForMerchantPayResponse = (): Codec<MerchantPayResponse> =>
@@ -1260,7 +1319,7 @@ export const codecForExchangeMeltResponse = (): Codec<ExchangeMeltResponse> =>
export const codecForExchangeRevealItem = (): Codec<ExchangeRevealItem> =>
buildCodecForObject<ExchangeRevealItem>()
- .property("ev_sig", codecForString())
+ .property("ev_sig", codecForBlindedDenominationSignature())
.build("ExchangeRevealItem");
export const codecForExchangeRevealResponse = (): Codec<ExchangeRevealResponse> =>