aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-cli
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2020-12-03 14:15:40 +0100
committerFlorian Dold <florian@dold.me>2020-12-03 14:15:40 +0100
commit2c536d140f0e6a0797dd480971c4a5b3fc7254c8 (patch)
tree0638639f974ba1e75e1319def79c26e57a809e8a /packages/taler-wallet-cli
parentca140d99054364191d7209ae0d1de92cf185356e (diff)
tvgcheck
Diffstat (limited to 'packages/taler-wallet-cli')
-rw-r--r--packages/taler-wallet-cli/src/index.ts63
1 files changed, 63 insertions, 0 deletions
diff --git a/packages/taler-wallet-cli/src/index.ts b/packages/taler-wallet-cli/src/index.ts
index 5a662d807..936ce4851 100644
--- a/packages/taler-wallet-cli/src/index.ts
+++ b/packages/taler-wallet-cli/src/index.ts
@@ -35,8 +35,13 @@ import {
printTestVectors,
NodeThreadCryptoWorkerFactory,
CryptoApi,
+ rsaBlind,
+ encodeCrock,
+ rsaUnblind,
+ rsaVerify,
} from "taler-wallet-core";
import * as clk from "./clk";
+import { deepStrictEqual } from "assert";
// This module also serves as the entry point for the crypto
// thread worker, and thus must expose these two handlers.
@@ -647,6 +652,64 @@ testCli.subcommand("vectors", "vectors").action(async (args) => {
printTestVectors();
});
+async function read(stream: NodeJS.ReadStream) {
+ const chunks = [];
+ for await (const chunk of stream) chunks.push(chunk);
+ return Buffer.concat(chunks).toString('utf8');
+}
+
+testCli.subcommand("tvgcheck", "tvgcheck").action(async (args) => {
+ const data = await read(process.stdin);
+
+ const lines = data.match(/[^\r\n]+/g);
+
+ if (!lines) {
+ throw Error("can't split lines");
+ }
+
+ const vals: Record<string, string> = {}
+
+ let inBlindSigningSection = false;
+
+ for (const line of lines) {
+ if (line === "blind signing:") {
+ inBlindSigningSection = true;
+ continue;
+ }
+ if (line[0] !== " ") {
+ inBlindSigningSection = false;
+ continue;
+ }
+ if (inBlindSigningSection) {
+ const m = line.match(/ (\w+) (\w+)/);
+ if (!m) {
+ console.log("bad format");
+ process.exit(2)
+ }
+ vals[m[1]] = m[2];
+ }
+ }
+
+ console.log(vals);
+
+ const req = (k: string) => {
+ if (!vals[k]) {
+ throw Error(`no value for ${k}`);
+ }
+ return decodeCrock(vals[k]);
+ }
+
+ const myBm = rsaBlind(
+ req("message_hash"),
+ req("blinding_key_secret"),
+ req("rsa_public_key"),
+ );
+
+ deepStrictEqual(req("blinded_message"), myBm);
+
+ console.log("check passed!");
+});
+
testCli.subcommand("cryptoworker", "cryptoworker").action(async (args) => {
const workerFactory = new NodeThreadCryptoWorkerFactory();
const cryptoApi = new CryptoApi(workerFactory);