wallet-core: support new exchange wire account signature
This commit is contained in:
parent
da519af01f
commit
1b0bec0363
@ -45,4 +45,6 @@ test("version comparison", (t) => {
|
|||||||
compatible: true,
|
compatible: true,
|
||||||
currentCmp: 0,
|
currentCmp: 0,
|
||||||
});
|
});
|
||||||
|
t.true(LibtoolVersion.compare("42:0:1", "41:0:0")?.compatible);
|
||||||
|
t.true(LibtoolVersion.compare("41:0:0", "42:0:1")?.compatible);
|
||||||
});
|
});
|
||||||
|
@ -840,6 +840,10 @@ export class WireFeesJson {
|
|||||||
export interface AccountInfo {
|
export interface AccountInfo {
|
||||||
payto_uri: string;
|
payto_uri: string;
|
||||||
master_sig: string;
|
master_sig: string;
|
||||||
|
// Will become mandatory in later protocol versions
|
||||||
|
conversion_url?: string;
|
||||||
|
credit_restrictions?: any;
|
||||||
|
debit_restrictions?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ExchangeWireJson {
|
export interface ExchangeWireJson {
|
||||||
@ -1426,6 +1430,9 @@ export const codecForAccountInfo = (): Codec<AccountInfo> =>
|
|||||||
buildCodecForObject<AccountInfo>()
|
buildCodecForObject<AccountInfo>()
|
||||||
.property("payto_uri", codecForString())
|
.property("payto_uri", codecForString())
|
||||||
.property("master_sig", codecForString())
|
.property("master_sig", codecForString())
|
||||||
|
.property("conversion_url", codecOptional(codecForString()))
|
||||||
|
.property("credit_restrictions", codecForAny())
|
||||||
|
.property("debit_restrictions", codecForAny())
|
||||||
.build("AccountInfo");
|
.build("AccountInfo");
|
||||||
|
|
||||||
export const codecForExchangeWireJson = (): Codec<ExchangeWireJson> =>
|
export const codecForExchangeWireJson = (): Codec<ExchangeWireJson> =>
|
||||||
|
@ -35,6 +35,7 @@ import {
|
|||||||
bufferForUint32,
|
bufferForUint32,
|
||||||
bufferForUint64,
|
bufferForUint64,
|
||||||
buildSigPS,
|
buildSigPS,
|
||||||
|
canonicalJson,
|
||||||
CoinDepositPermission,
|
CoinDepositPermission,
|
||||||
CoinEnvelope,
|
CoinEnvelope,
|
||||||
createHashContext,
|
createHashContext,
|
||||||
@ -82,6 +83,7 @@ import {
|
|||||||
TalerProtocolTimestamp,
|
TalerProtocolTimestamp,
|
||||||
TalerSignaturePurpose,
|
TalerSignaturePurpose,
|
||||||
UnblindedSignature,
|
UnblindedSignature,
|
||||||
|
validateIban,
|
||||||
WireFee,
|
WireFee,
|
||||||
WithdrawalPlanchet,
|
WithdrawalPlanchet,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
@ -534,6 +536,9 @@ export interface WireAccountValidationRequest {
|
|||||||
paytoUri: string;
|
paytoUri: string;
|
||||||
sig: string;
|
sig: string;
|
||||||
masterPub: string;
|
masterPub: string;
|
||||||
|
conversionUrl?: string;
|
||||||
|
debitRestrictions?: any[];
|
||||||
|
creditRestrictions?: any[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EddsaKeypair {
|
export interface EddsaKeypair {
|
||||||
@ -975,9 +980,23 @@ export const nativeCryptoR: TalerCryptoInterfaceR = {
|
|||||||
): Promise<ValidationResult> {
|
): Promise<ValidationResult> {
|
||||||
const { sig, masterPub, paytoUri } = req;
|
const { sig, masterPub, paytoUri } = req;
|
||||||
const paytoHash = hashTruncate32(stringToBytes(paytoUri + "\0"));
|
const paytoHash = hashTruncate32(stringToBytes(paytoUri + "\0"));
|
||||||
const p = buildSigPS(TalerSignaturePurpose.MASTER_WIRE_DETAILS)
|
const pb = buildSigPS(TalerSignaturePurpose.MASTER_WIRE_DETAILS);
|
||||||
.put(paytoHash)
|
pb.put(paytoHash);
|
||||||
.build();
|
if (req.versionCurrent >= 15) {
|
||||||
|
let conversionUrlHash;
|
||||||
|
if (!req.conversionUrl) {
|
||||||
|
conversionUrlHash = new Uint8Array(64);
|
||||||
|
} else {
|
||||||
|
conversionUrlHash = hash(stringToBytes(req.conversionUrl + "\0"));
|
||||||
|
}
|
||||||
|
pb.put(conversionUrlHash);
|
||||||
|
pb.put(hash(stringToBytes(canonicalJson(req.debitRestrictions) + "\0")));
|
||||||
|
pb.put(hash(stringToBytes(canonicalJson(req.creditRestrictions) + "\0")));
|
||||||
|
}
|
||||||
|
const p = pb.build();
|
||||||
|
logger.info(`wire sig blob: ${encodeCrock(p)}`);
|
||||||
|
logger.info(`credit restrictions: ${j2s(req.creditRestrictions)}`);
|
||||||
|
logger.info(`debit restrictions: ${j2s(req.debitRestrictions)}`);
|
||||||
return { valid: eddsaVerify(p, decodeCrock(sig), decodeCrock(masterPub)) };
|
return { valid: eddsaVerify(p, decodeCrock(sig), decodeCrock(masterPub)) };
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -253,6 +253,9 @@ async function validateWireInfo(
|
|||||||
paytoUri: a.payto_uri,
|
paytoUri: a.payto_uri,
|
||||||
sig: a.master_sig,
|
sig: a.master_sig,
|
||||||
versionCurrent,
|
versionCurrent,
|
||||||
|
conversionUrl: a.conversion_url,
|
||||||
|
creditRestrictions: a.credit_restrictions,
|
||||||
|
debitRestrictions: a.debit_restrictions,
|
||||||
});
|
});
|
||||||
isValid = v;
|
isValid = v;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
This file is part of GNU Taler
|
This file is part of GNU Taler
|
||||||
(C) 2019 Taler Systems S.A.
|
(C) 2019-2023 Taler Systems S.A.
|
||||||
|
|
||||||
GNU Taler is free software; you can redistribute it and/or modify it under the
|
GNU Taler is free software; you can redistribute it and/or modify it under the
|
||||||
terms of the GNU General Public License as published by the Free Software
|
terms of the GNU General Public License as published by the Free Software
|
||||||
@ -19,7 +19,7 @@
|
|||||||
*
|
*
|
||||||
* Uses libtool's current:revision:age versioning.
|
* Uses libtool's current:revision:age versioning.
|
||||||
*/
|
*/
|
||||||
export const WALLET_EXCHANGE_PROTOCOL_VERSION = "12:0:0";
|
export const WALLET_EXCHANGE_PROTOCOL_VERSION = "15:0:2";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Protocol version spoken with the merchant.
|
* Protocol version spoken with the merchant.
|
||||||
|
Loading…
Reference in New Issue
Block a user