diff options
author | Florian Dold <florian@dold.me> | 2022-02-02 23:44:36 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2022-02-03 01:35:21 +0100 |
commit | f5ff4afae6a0a1a6cc006a97b529429c539e7a17 (patch) | |
tree | 3af81cc5fa1da96621d97714a6fd0a48289f532b /packages/taler-util/src/talerTypes.ts | |
parent | 003ba5e91bb016caa1d068805723edc3e15f4d30 (diff) | |
download | wallet-core-f5ff4afae6a0a1a6cc006a97b529429c539e7a17.tar.xz |
clause schnorr
Diffstat (limited to 'packages/taler-util/src/talerTypes.ts')
-rw-r--r-- | packages/taler-util/src/talerTypes.ts | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/packages/taler-util/src/talerTypes.ts b/packages/taler-util/src/talerTypes.ts index 37350c661..7305122bd 100644 --- a/packages/taler-util/src/talerTypes.ts +++ b/packages/taler-util/src/talerTypes.ts @@ -1123,7 +1123,8 @@ export interface RsaDenominationPubKey { export interface CsDenominationPubKey { cipher: DenomKeyType.ClauseSchnorr; - // FIXME: finish definition + age_mask: number; + cs_public_key: string; } export namespace DenominationPubKey { @@ -1151,6 +1152,16 @@ export namespace DenominationPubKey { return 1; } return strcmp(p1.rsa_public_key, p2.rsa_public_key); + } else if ( + p1.cipher === DenomKeyType.ClauseSchnorr && + p2.cipher === DenomKeyType.ClauseSchnorr + ) { + if ((p1.age_mask ?? 0) < (p2.age_mask ?? 0)) { + return -1; + } else if ((p1.age_mask ?? 0) > (p2.age_mask ?? 0)) { + return 1; + } + return strcmp(p1.cs_public_key, p2.cs_public_key); } else { throw Error("unsupported cipher"); } @@ -1171,6 +1182,7 @@ export const codecForDenominationPubKey = () => buildCodecForUnion<DenominationPubKey>() .discriminateOn("cipher") .alternative(1, codecForRsaDenominationPubKey()) + .alternative(2, codecForCsDenominationPubKey()) .alternative(3, codecForLegacyRsaDenominationPubKey()) .build("DenominationPubKey"); @@ -1186,6 +1198,12 @@ export const codecForLegacyRsaDenominationPubKey = () => .property("rsa_public_key", codecForString()) .build("LegacyRsaDenominationPubKey"); +export const codecForCsDenominationPubKey = () => + buildCodecForObject<CsDenominationPubKey>() + .property("cipher", codecForConstNumber(2)) + .property("cs_public_key", codecForString()) + .build("CsDenominationPubKey"); + export const codecForBankWithdrawalOperationPostResponse = (): Codec<BankWithdrawalOperationPostResponse> => buildCodecForObject<BankWithdrawalOperationPostResponse>() |