aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-util
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-03-07 12:09:38 +0100
committerFlorian Dold <florian@dold.me>2022-03-07 12:09:38 +0100
commit0290c5fd379a4b4262d8835d4131b7c4e8a2f2f2 (patch)
tree233cbe5e18925339daedfaffb2882d390b3479a5 /packages/taler-util
parent2cfefa93920eba7bc4bfa3ca788a7bcf74c149f5 (diff)
address protocol changes in the exchange
The exchange now has a wad fee and truncates the payto hash in signatures
Diffstat (limited to 'packages/taler-util')
-rw-r--r--packages/taler-util/src/backupTypes.ts2
-rw-r--r--packages/taler-util/src/talerCrypto.ts12
-rw-r--r--packages/taler-util/src/talerTypes.ts3
3 files changed, 15 insertions, 2 deletions
diff --git a/packages/taler-util/src/backupTypes.ts b/packages/taler-util/src/backupTypes.ts
index 8663850c9..41a9ce98e 100644
--- a/packages/taler-util/src/backupTypes.ts
+++ b/packages/taler-util/src/backupTypes.ts
@@ -1023,6 +1023,8 @@ export interface BackupExchangeWireFee {
*/
wire_fee: string;
+ wad_fee: string;
+
/**
* Fees to close and refund a reserve.
*/
diff --git a/packages/taler-util/src/talerCrypto.ts b/packages/taler-util/src/talerCrypto.ts
index 83e5dc6fe..358da9dac 100644
--- a/packages/taler-util/src/talerCrypto.ts
+++ b/packages/taler-util/src/talerCrypto.ts
@@ -25,6 +25,7 @@ import * as nacl from "./nacl-fast.js";
import { kdf, kdfKw } from "./kdf.js";
import bigint from "big-integer";
import {
+ Base32String,
CoinEnvelope,
DenominationPubKey,
DenomKeyType,
@@ -598,6 +599,15 @@ export function hash(d: Uint8Array): Uint8Array {
return nacl.hash(d);
}
+/**
+ * Hash the input with SHA-512 and truncate the result
+ * to 32 bytes.
+ */
+export function hashTruncate32(d: Uint8Array): Uint8Array {
+ const sha512HashCode = nacl.hash(d);
+ return sha512HashCode.subarray(0, 32);
+}
+
export function hashCoinEv(
coinEv: CoinEnvelope,
denomPubHash: HashCodeString,
@@ -608,7 +618,6 @@ export function hashCoinEv(
return hashContext.finish();
}
-
const logger = new Logger("talerCrypto.ts");
export function hashCoinEvInner(
@@ -683,7 +692,6 @@ export interface FreshCoin {
bks: Uint8Array;
}
-
function bufferForUint32(n: number): Uint8Array {
const arrBuf = new ArrayBuffer(4);
const buf = new Uint8Array(arrBuf);
diff --git a/packages/taler-util/src/talerTypes.ts b/packages/taler-util/src/talerTypes.ts
index 59d37dece..4581f0b6a 100644
--- a/packages/taler-util/src/talerTypes.ts
+++ b/packages/taler-util/src/talerTypes.ts
@@ -738,6 +738,8 @@ export class WireFeesJson {
*/
wire_fee: string;
+ wad_fee: string;
+
/**
* Cost of clising a reserve.
*/
@@ -1356,6 +1358,7 @@ export const codecForWireFeesJson = (): Codec<WireFeesJson> =>
buildCodecForObject<WireFeesJson>()
.property("wire_fee", codecForString())
.property("closing_fee", codecForString())
+ .property("wad_fee", codecForString())
.property("sig", codecForString())
.property("start_date", codecForTimestamp)
.property("end_date", codecForTimestamp)