diff options
author | Florian Dold <florian@dold.me> | 2020-12-03 14:15:40 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2020-12-03 14:15:40 +0100 |
commit | 2c536d140f0e6a0797dd480971c4a5b3fc7254c8 (patch) | |
tree | 0638639f974ba1e75e1319def79c26e57a809e8a | |
parent | ca140d99054364191d7209ae0d1de92cf185356e (diff) |
tvgcheck
3 files changed, 487 insertions, 2 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); diff --git a/packages/taler-wallet-core/src/crypto/talerCrypto-test.ts b/packages/taler-wallet-core/src/crypto/talerCrypto-test.ts index a9fa61035..81dad2f8e 100644 --- a/packages/taler-wallet-core/src/crypto/talerCrypto-test.ts +++ b/packages/taler-wallet-core/src/crypto/talerCrypto-test.ts @@ -321,4 +321,398 @@ test("gnunet-exchange-tvg blind signing (GNUnet v0.13.0)", (t) => { decodeCrock(rsaPublicKey), ); t.true(v); -});
\ No newline at end of file +}); + +test("gnunet-exchange-tvg blind signing (GNUnet v0.13.0, attempt 2)", (t) => { + const messageHash = + "NRSAGHSY3HVPXD22R41QCK8NK4FVA0TX44565RG944YSXKZ4A2WS38QXQGYC7KCQP3S2CEBD0B353YEQMCQHQCJ33C4CJV43P5XSDPR"; + const rsaPublicKey = + "040000Y6TRSZEM8HRBKMCYC4RF0FSS6GXTZ4FEB6QDBGXG1EBVCT6CMY3A9VR01W2YZKG6KS8603ZGBGNPSEB9Y5PGDF33JBGVCG7GFABV1WNXCHTVVE4FSZQJD9TTE06NQEVFJDJ2CPD5383ECCM3CDF7EFCT6EY2SHQ4CB6NNZZ64CZSY6M12BY0DE65YC7DMD22VRMKFQ1QZE5HYRJRASPJH4NNG08CKCABPQXYB44DF4Y2TTBKP21PY0BC84XQMMKSBE9XR190H54YH641X0326851C0MZR00C4W05F88VFBF2N246WNK8RWBYHDWK74W9J65JZFYHY1DNBZKCCS4K3A23BKV0H8Q8FV2EQXHGQGWXDKSGBQHMD0275EGA4ZRKZ6NK4S6GM0457ATPY26MS23XCX04002"; + const bks = "M027BA4SJHDDS3F4Z5VKHW76CDZ60ENVHE8T6HP4Y3B15M84FHMG"; + const bm = + "FSM0GCTX159NFEVGBS5WKDWWG56XJMG1A9E7S8GGDDF7ZK4EBXAR58YBBHQ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H0VSFQ13Y34AMKNMD0YFP5T0T33V2CZ5RNCRRKHNAFG6SD1X0XZ73GWZK6XDAYJH3NE3CE6W1FFPWJYRJFQZ79WJA8Q1B15ECZ4QR"; + + const myBm = rsaBlind( + decodeCrock(messageHash), + decodeCrock(bks), + decodeCrock(rsaPublicKey), + ); + t.deepEqual(encodeCrock(myBm), bm); + + const mySig = rsaUnblind( + decodeCrock(bs), + decodeCrock(rsaPublicKey), + decodeCrock(bks), + ); + t.deepEqual(encodeCrock(mySig), sig); + + const v = rsaVerify( + decodeCrock(messageHash), + decodeCrock(sig), + decodeCrock(rsaPublicKey), + ); + t.true(v); +}); + + +test("gnunet-exchange-tvg blind signing (GNUnet v0.13.3)", (t) => { + const messageHash = + "KJ9NSRGA30Z7X59NM8XCFFRN6TW65V23QHPAT9VBNZ96CCDSTTZPJN3AJTTXXJABJ8088JQM1PRQYDXCEA26NPDGVT2VZHA69FT3VW0"; + const rsaPublicKey = + "040000ZCN8T8GYMN60SYZXP6DSAHJ2NXHPSA2PY0395WDFK37RGF0H8B73XT3G15JWSGCFF4ZT32YHPA84HQ298HNE544AJRGF7380G4VGGBFMTV6T1W4ZZA7M7QEGX3JZS648XJ6DYXR0Z5Z4Y3JHFF9CPJPJJSEE6SERVJVCBKPT9KVS3AY2T8VWBRN317GC1WQC35WA3QWP13VCDYCHPTZEW6DGM22HNRH63A1M34HBJJEPC69SK4SJCEAERS45DC72Q6TAR05F406AQWHJDQF47QC3SVHCP8EX2TW494A3ND0V8N25YDXKF7HWN3NNA43WE2S9GSE6DCX74XWTM7VKHP4508HASZZBG1Z4PBC0GTNQY7ZD8MW627GC1TRCCSNHNXQ4QR7K2QV4H8BCETVMCJGPJ904002"; + const bks = "B9W4W4DWVEVTZ8QZTW8RN2XQ92CVPGKS9GY2EN3FMR35Q67XEE80"; + const bm = + "V5N1AJGYYB6XWZDZSXANNNAA3HF2885FY8F9BQHC0R5ACR9JEZ6Y0F92FFQMXGNKG8RQAN731BA5WVDA0Y5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FT56SY59WJX9EKH6G0D8M6HTJ1TYTFNW7XWAZPN7082DT8R0X7Z4224X7Z5JN3DYBTNWK4"; + + const myBm = rsaBlind( + decodeCrock(messageHash), + decodeCrock(bks), + decodeCrock(rsaPublicKey), + ); + t.deepEqual(encodeCrock(myBm), bm); + + const mySig = rsaUnblind( + decodeCrock(bs), + decodeCrock(rsaPublicKey), + decodeCrock(bks), + ); + t.deepEqual(encodeCrock(mySig), sig); + + const v = rsaVerify( + decodeCrock(messageHash), + decodeCrock(sig), + decodeCrock(rsaPublicKey), + ); + t.true(v); +}); + + +test("gnunet-exchange-tvg blind signing (GNUnet v0.14.0)", (t) => { + const messageHash = + "Y2RGCYZJZ0GQW5VRHB8QMWBWAN1B7FTPCZMKXB9CEP9SDM4369E97W2G9JA2EFP002AQ2T4D33Z5MVQT3CJ3XC0FTSNZT53K864DS88"; + const rsaPublicKey = + "040000Y2TSH830TRWE2P3CFMGZ0GKD82C2KFDDAY9HV2PNSBH9VNQJ7RRVT67H77GVWCA01ATXJTQTB838BGEFTT0HDXH5SV0EYTKK4T3W7DZVHPMWBVK27BWJ5Z4N22J0GAG2QQB4T5QFNB29ZJGC65WDRTA287B7FSA1ZNS7DEKW640MTD1DSJ12T346YTGPXF5Q8FGP83GS1M4GVMMH782CNPZHNJ4SY0ANJ9PMA04K20CZNPM7PF8QYAYMBN43007F70SXQDRCM4MTH58BHPN49FW3K8XAB00K4GWFE0XDXFB0C3QZ6AJ26XHS1KHW1Z9XQKSZ83CN4E6T63PZNKN43YZBX7T9EKXEQK618SEJH7E692NQNY1BQHZ6V8SFXS8MPCWYHSPV5RA2RSVGAFM895JXCF04002"; + const bks = "YM36FHH7MZ7G41C2G9R3W7C853V7MX5FKJTX4W47Y76JZADVMEAG"; + const bm = + "M7D02AGB495HC2ZEKY81E3ABHCJ7S3C7AYZXFPCDWJW83FZVSCMNQNY4XWB71B3CXHZ8JTJXYNBBYXDK2RDA9XAR631VX4K92EWN2284QYCEZ70HWBEX09C062PS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0PJCKD9GJ03WCYPQKV94NRFBWFM2ACP7TK4"; + + const myBm = rsaBlind( + decodeCrock(messageHash), + decodeCrock(bks), + decodeCrock(rsaPublicKey), + ); + t.deepEqual(encodeCrock(myBm), bm); + + const mySig = rsaUnblind( + decodeCrock(bs), + decodeCrock(rsaPublicKey), + decodeCrock(bks), + ); + t.deepEqual(encodeCrock(mySig), sig); + + const v = rsaVerify( + decodeCrock(messageHash), + decodeCrock(sig), + decodeCrock(rsaPublicKey), + ); + t.true(v); +}); + + +test("gnunet-exchange-tvg blind signing (GNUnet git ddbb4c740614d)", (t) => { + const messageHash = + "1ATSVTM3T954VJDAT9BBHT7Q4FGP8NWVF4SPCGSH9B1MR4J3FP5MZ73F4JRJHV96AKZD3GREC6G5BM2C7GZCG5YCAKZTX4B9J8EGQ0R"; + const rsaPublicKey = + "040000XA4AHKR3XCRMRSN9ZK019FK9FTHFV796G59T8FT6DARHT9PEBGF444AZD1YDCH0C1V0SK6JKCGBW22KYMBRJTKPA7GDY6SPHEQ3YKX22E0AM6TVFG8AQ3CCPED0N7PNJ19WQ2ND35MVRW9GDAF0GG0K0K2NC9JBMRF7GXM6E7C0TPHYFR4PFDGFK4R8SA3QDPZCCH0NXS6FQHRN593DVA638PTY38Y2TX0FNC9TDH40PBBPD2YP0DF6BXECA41A8Z0FD644BS3ABW2H7EHS49MXNCZMEXSNV8GBXGH3HW3YM5TPTVSC1T3PJ9GENVZGG5GK68K3DKH0EANHHXSV39K58AEMZ0AS3GW4ZEVSD2919SS5GFX0QVJM2NB39F9236BTCCFPT8VH6XNPT2B30YZJ9SN04002"; + const bks = "XR39EEEDN0KEPPJTN4W1K1SVR7WV0FYY6M2Y12R76729EE3QHHJ0"; + const bm = + "0B3DX0NZNMT4DY6K7KV6P9Z67TVS24NAJESF8A2X82A0A4AND4H8A3H0891TXDWW9SJRS4MZSMPQKY1MXR2F3D3YFQK3AYX1NG7FG6SMAZFQ03QBY5Y6ATR71YBNRDV7760W867B1RRGXP7FH7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X7KR"; + + const myBm = rsaBlind( + decodeCrock(messageHash), + decodeCrock(bks), + decodeCrock(rsaPublicKey), + ); + t.deepEqual(encodeCrock(myBm), bm); + + const mySig = rsaUnblind( + decodeCrock(bs), + decodeCrock(rsaPublicKey), + decodeCrock(bks), + ); + t.deepEqual(encodeCrock(mySig), sig); + + const v = rsaVerify( + decodeCrock(messageHash), + decodeCrock(sig), + decodeCrock(rsaPublicKey), + ); + t.true(v); +}); + + +test("gnunet-exchange-tvg blind signing (GNUnet git 52968789d280)", (t) => { + const messageHash = + "9EDHM6NPM3J96NMDPGNRRJFQQ1DXQNN8HB3PGMMND9V7QYGW0SEZH2MBA36KX2BHDEPPN29BGP2N7X1CDEH6QFDRAFQP1HQ1JHHDGH8"; + const rsaPublicKey = + "040000X8SKF2D18C7702HAARRAB1QDF1YSKA8EKXHYJFYYN6BJJEPWW063FACXYTAQA7NANGRQRT9RC5SQ09K7D0TD3FM07CNY1NM0HGJ11AR5639NNC9AE6230Y5CJJSPPYKEAM6NNYQZF3NGY74XWVNX8JPA3F5S66YCE2FB1AFG026QWKRAHXSHG4Y4QPJ1S5X0AE5XM0312B9N9WDCFM87PAFD7BVMZ3F68VJFNQ9ERSEW9Q7XPVKP2FNV5DV5ZQADHR3BXW1H8DX1NXJC638TNT8797NB6H0YFHPHBN6J28ZZQW40MXSZY6PATP1W73NDJC60SNWRS3T2A802KTVQ7914RFVWD2FK5K5WSTJZN0XXV95EJPMK3YRX782NNEVV9H2WDY62KQS43KE1ASJ2JWZV7N04002"; + const bks = "HJA760YC8PCRF7GBJWER5J3SYRNJKF0527QM3JBE5J1BW61KBGK0"; + const bm = + "M7JXX0BQ2R4R8XRAAWFKW69VF7531QPQNMNSECRE0H63SVDBP1KG4W0CG33Q6DW654BHQVB535MG8GQEANV0JWKDHPZN03J1A32SW2CKVFTF7TVG9S0APC23WGD4NQ7NWYA9SNZVGNW0ZAKCZ26D3NGQ3HHPHNM0ZCS99W29QQTB1JW0QKGV399PX6FRJ1FAE920C2MMS0274NX2A2619FRBXZGME0FNT2SE0GF1CVS8F5CNPMR3WT2CA7PSCJX32F012SD837A9JJ2ADS1DAHY6D5WNE0QAPYG40PN0Z3ZS994AAPTB87AMDJHVYCKAGY51FA7PD5MP4V6NAD5TV1G61EB4DHFB8CYN1JEVFKG6PAVK28N0WDX6TTFQ8NS4Q8M36V6Z128VP94ASST3MPNAHG"; + const bs = + "6RPBZM7Z1ZZJ8PEP5ESPKNC5931B5N1J10FPXJ8VAEC44TKMRNACNXTSF9GPYPWG0556H0QYTNKEKXKTH63BY0B6F44QEHG37PTT8WFQ4Z9Y0W6RH86PS2E5PMQJGK8Q708WJEVNBMGZ8B63YZ4RQ0RPN1VWAVEK3JAMVC5E4HP39VJZQ58PDC403PYV0WARFD1V5A4HS2GRHQKP28E4FNQTVK657P8QDZ6ZT66TDV6VEDSS2H0PH0GKF6K9TB3982S2R78T1SDY3G2AB577PWZK22G9X8FJKACFARVV1PCGMECN4PXB6GGZDT7ZV20GHYZTF4V0PY8KSPF6H102WH6Y7P75V0RCV6SFHWTB2EV102K4SYPESNAVKB02NNS0BRMG1YPZHJXS0G1FKQ5W66HNEM"; + const sig = + "77NSZ9ACKJSN78MF5GP7ABBRVN00W0CVH9AMPT8RWE93SQ40JHVV93HRCCWAB65NKG8WC6DYN36DYTHX8FGA7ADQWAPS5EAYHSDHHFATQJ85RYNFFBGPGDTEPYNGA99JZPNHZYM51C3NKCGA9BCJP0MDCKNRPJ1560767MS7HVEKCKT3449T4STSPQ73HDA3QBEEQ8RNKYK23J759JCT116ZRZB9J3Y8BN3C35461M7FC3MJAS0ZF02AK34EM6Y7WQQSKMG423ENECKHAN4FVMKCZCAEG1RA45KHQ75A7W237MSCJFAJR05KZRKKDNK9BERHV9Q16NZ4FP9DFGMJTYDASG9XA6W4HHVAEG82MJGA81674YJ6NCGHY6JQ0YQ94E3X87K4B06W9CADS5H8DZN55M"; + + const myBm = rsaBlind( + decodeCrock(messageHash), + decodeCrock(bks), + decodeCrock(rsaPublicKey), + ); + t.deepEqual(encodeCrock(myBm), bm); + + const mySig = rsaUnblind( + decodeCrock(bs), + decodeCrock(rsaPublicKey), + decodeCrock(bks), + ); + t.deepEqual(encodeCrock(mySig), sig); + + const v = rsaVerify( + decodeCrock(messageHash), + decodeCrock(sig), + decodeCrock(rsaPublicKey), + ); + t.true(v); +}); + + +test("gnunet-exchange-tvg blind signing (GNUnet git 41000a00)", (t) => { + const messageHash = + "Y0X772RP6YA7TB7RP522Q4XXEEQW098NM0BYYCSC4T40RV9PQTFYV2WPZBX784VEEYV0NK1EWZTW31NB5WP3X47KQ8QNY2F7943K2C0"; + const rsaPublicKey = + "040000XT6GVM4B1SENCMNQHBDEX363Z2W6TSVDQ3JW28RSYQ6T6W2JR1EDKSBN490MG9WXKRMVV39JV0XRXQC9FDEYD7QJAFRFVY6TJCV5NN3016TX6YA6E6H63PK27CE2QEYFZPCEP8TTKA8SMNXD8KXTJB69XBXFZVBF2MCPJCN0PTRX97SX1CV94RFC0TDTCBAEPBXF7N2P025R8CDCYDFJWSKHCY7YRPP5N8B3GXSNS95TCEV47RS24TF2RZGKNRAB9MWG1TN30WRZ5WH8WEX3ERD5QQDXPCKFCPM08115X0R0H4NFB0KVQ126ERW6ZVR19DYTVBY1WNQ8D7B637FM5VWAKA4J4DTZVQEDEHB3PV405NB8Z6PCTW154P18G0FMGG3CE3GEM9FX644R6MZ54XPF7K04002"; + const bks = "RBNWGNW2KG4F1SHDVAG8DSPWKZT5X60A16B24JADG0J0T0ZE3SSG"; + const bm = + "256DXR8AXXZ3QEHKJ7YCD80WMKFMKT883K44T2ARGF2454NTN4YTG0V9K8RREY51ZQWNSQ4ZRY9Q1EBRSMJCEWQF18FCV02X29EERVMEVT2N27HGAK9TXSZVRTTC3G6W7YFAW3AXKGSY33S8DB9B23Y16V3J3W1JECVM186497Y1MT1X2S3K1MKE5PZYDAT37987C92HSTK0Q2EBBVJYKVEKXKCX2YWXNN8ATW9PE1NT3FHDYWKT88VMK2BNZA5D11BNFC4PZQBGJF8171Z2AR89NPPDAEYKHMHMN9NDJXV8XSKDB31ADPNV9EATWXRPK7GPPKP2QBHZYSHY95E0NW744V5Y2CY9T1772341EA36NS388VGQ2JJMENABCBW4J3JBNM4ABJ064J30BKRF28RPVG"; + const bs = + "21G2ZD0ES20ZMSS0SJAYE5N2YVAXDCASMA50E8QPXZ299GC8VP5AW6ZWQ9N4Q2TS333X6XFS0PWSB1BD434QYDDJ2J88AYDCF7GNY1YV0RQ5ZCCMX01SR523E82KP0YTAAMTY4PK1VBZJG6VTP4GD10G7AY0CHVZ5Y07Q11N5Z1KT7YMDX51ZPR5VK8DSNVRXDM9BNYWDE1RVABBG5NFV2QZ1XS2HY23VB260SAJCGS5DKQW73J973PBKAT0QRWSNTWB7RQJPJ41279FDSJW71B0R8XR87FMBWMYY0NB5FTQ5XMSY7Q6APCTNHT9QFM9J8XNJ6Y6GARQACQDB5BJG29KMQ3XNZMCYMAKQB6Z4K80NFJHV2YZ9G6PYP4XMSETQPWX8R26ZT2S49ZHWNRJ79D2YR"; + const sig = + "PFAKXZ50BFW6MFHYZ8A329FC9XA32RCYGW1JVG55DGZ840WTHQPGDSTBN0SQA0N939K0WM2X675NS7C7FPJ1K8AB48YTHGM06M07D6JPWEZQ07V0CD3BD6SHEJZYGABG6MFBZ5ZK7VJMX0G8SJRM2T0EYW852C1VCWJ1EW6W5VWVTMFJXN8PD4RSN2MN13NGQR0T31C8FG2XB17RDRM14F3X85B6RBT0M0A43192KS45JTKT25APMNEZG6SZXZKPE7KB0JAT4YESTG9KS7SJB0CW4A9KA45MC3HCJRPF094VZGNE7X4X6YJ4YA6FRH3VR2PX5R9YV6PZPNEHAHG8EEERBKWBX1DFCSHZ5QCJ41ZSVNZ1PY8DJWRY5ZBN62WG8NNGTX267WV39E8JVCDRP4GQAC"; + + const myBm = rsaBlind( + decodeCrock(messageHash), + decodeCrock(bks), + decodeCrock(rsaPublicKey), + ); + t.deepEqual(encodeCrock(myBm), bm); + + const mySig = rsaUnblind( + decodeCrock(bs), + decodeCrock(rsaPublicKey), + decodeCrock(bks), + ); + t.deepEqual(encodeCrock(mySig), sig); + + const v = rsaVerify( + decodeCrock(messageHash), + decodeCrock(sig), + decodeCrock(rsaPublicKey), + ); + t.true(v); +}); + + +test("gnunet-exchange-tvg blind signing (GNUnet git c0f407c9d)", (t) => { + const messageHash = + "CQXB3S7MJ2TH49NVPWY6KYJ0HT2DTNCPY6R3XCXA2KPBPYVYM9VTPX9K6KT35M361Q1228HNKEEV9TFQ5HC9HQBZTAMMX1RMM39KP5G"; + const rsaPublicKey = + "040000Y7S1X9TVB45Z26DDGDJQAS6T0R2SA5S636VESHSSKCMB953Z2KB036CK0V6D5WD2BKVVT9VAD5H0WT61QR54S33J9W1PPYFR88J4RK5K5TC0DRNV7R5KM8W2BFTPK60CS04AG9KBYB1T8SXEKXKKS7YVXPVGN46BHF2BC09647PJSTWBXZZ9WBH0RT8VVPE2KEYB3P9N50PPSFAD8NAG01NBMWQPZ84JWXKGZ20ZYCB6YA78ZNVSMPQS419084XTH2RCYP3GEMY47WNK1J4C53W9VKK92R6CPDD8GCDCPK0ZN3JK3M28XV40WGP43M3ZV3F8TZEX1Y3A4RFD5DHB452RXWDFPQVT94BWVNA38AHF1FABB6YK3NBT4P7ESBF06GCREDVDTN6NQ721JWAVRCZ3N704002"; + const bks = "D3QQXZT39B0ENYMESD8RF6AT4PSR5NREK2N56MQFDSZGMKAZYVN0"; + const bm = + "JAES15QSDZ137M788VM11TWP8CZMA1RBZ0SQM2EZBPJ65D76QEVAY632VMAY1K7MSWQ0ES9M77WSYWX7SRJJP2CGX5F3GSHF8VAJ46M5FY8KSHDYDKRK9080BAAEY24Z253YZ60Z70ESCS7A3C76NR184333ZF6JYD9AKW15D9C3TGYMKDXRSEA604S0WK4CXMVNBMBDBGYTAWDZ3SEAPNSG1390A1TH2D9QXACRR66BD2Q65BTPCHX6X0P1P283QYM0XPCC9GHWD80ZS7AK9EHDCQQZHQRC887DCQBK7CH646FKV3KZ51VAKMX547YCDGNAFXE3APED970K0SVWYDE84R0WC0MMTW4NKPDXDGHDD2D9D65YZQHMVRP3PDQ8Z3NQW07TJ785KARMB004DKF21C"; + const bs = + "9G624TT7V946QMMGC11D70CVWE79MKEE8HCW41BQN4V5VH75PM5DY4D17DW5H97VWHSAVKA49SS82T5DPFXNA1GQE3PZF8N4N3NQNV35C9GSPV4MFG50QNHEGY14K4F31FT74P6BH51JP9ZP02NFDEP1XW89S7RK1SHAZTDZ22AM67PF4KKXH1F70EN1A4PXJMMWJZSJY6S0HM34KE9DWWZYVSK0RDGFD2Q20K04VP3B5GT2M2VAR1KMJ6BFZSFE7Y9SM15S33H3M3ZDRJ2Q7S5QPMTB57J2S33GJJ80KDVHFYSJKYDPXC1M5HZBTQ43PVD3BTJE69D7CBQM47ZWY0HEMGSQJMJD6CSJN98A44B1HH09KKY9P2C56NR4AG78QBCCM23JKFZ0TZ8EQ671GFV27M"; + const sig = + "6XEFC32PJMJANZYDQXG82G6B41A3BT39RNBC9MYD8FR8Y6QWVCGD91ND62T9JESMP7F3QBNHYMCWQS7JRCSB0J3ZC0VPEYNCNPFYSC37H1C9BYTD4G1NG1RHXBF6PXGCTWM9K61GHWG2P9KA8TAZ9KNS0V3X6KVMV8BC85GMNGQQ5DYC6GA5732M7AENS6RHV1209PVRBVJ02VC4PE3K5MXJRRAMZG6HWXHRAREJ2NC8NCXMMJEXM4HBXPB6ETMSJT0CBVSMV12XN2STNFTM9PA2RP2N3Z5PCSK449SCZQ9ETJD9RFR00EA4TCB93513DB0C9F6KRCWVB9HJJHNWFWYKC5VMQRHA5GZRXC64FHDGFK4NTGQZJG9GH4GK08BPXH2Y3PR4R5YEWYDJRYNJX1EH5W"; + + const myBm = rsaBlind( + decodeCrock(messageHash), + decodeCrock(bks), + decodeCrock(rsaPublicKey), + ); + t.deepEqual(encodeCrock(myBm), bm); + + const mySig = rsaUnblind( + decodeCrock(bs), + decodeCrock(rsaPublicKey), + decodeCrock(bks), + ); + t.deepEqual(encodeCrock(mySig), sig); + + const v = rsaVerify( + decodeCrock(messageHash), + decodeCrock(sig), + decodeCrock(rsaPublicKey), + ); + t.true(v); +}); + + +test("gnunet-exchange-tvg blind signing (GNUnet git c90b5703c8)", (t) => { + const messageHash = + "GRYH1N6KBP6MP40QMBRJJBTJ1TH5X7CVZDDTB4B2MTY63FK42DFGVNVR41EKARK0S5REVWAZQX2C71KXFCEFBG853ETD53SHTK8NAT0"; + const rsaPublicKey = + "040000XW244EXHAN4QQS9QVVV67T3W7PFN619HDBGKMR37NVDYQ122BS5M2R8P1FEYJZ7N1AMR98K216JSASW3ZMN8FPWXTTABZPVBVSR1MQCE7AT6BG3NY5XFT9HNDN989VYH6389B0G31MR1G9BT38S8X5BQQVC5SCYRZN62WCYE7MFNTJDXBYVAZXK7XT60NS7554WSSAB0C2N53VK096FBNPJH50CD58B3D1VAGADESCSNPCGSQ4EBRNQBEJCC1XNNJWSE495S5FNTZV930H56G646HDADTDKZP797PQ7S59DY8TNDERA0M424YW4TPFQNMYSY639ARQ5H1YA4YRC0Y413DBTRMAXEM5GWAS848MJX306WPC917W11TS753T2GAP4Y1C474VTZTMSPT8CY2F55FS04002"; + const bks = "CFEEEMSBJN0EJJZVE1J81279Q28X39XHGFBCDT00C7C0PNQZWK3G"; + const bm = + "978AJ8MBGPJANHSPER978SYKGJ1A4ZXBY00DNXCP10SWGB5S5Z6HZH7TH3VA0HHC3F82XDB7TNWMNJ8GYM0T46SS6E7X8J05QT59FEQMGQERBG7ZCYXB85VZD5BN8QBWP49JB142P4PSNM6Q2M29AWEPK7AD5VV61C3KCQ14QQ25706B2G7NQ8EWAM8KXJ0Q8443H21VT48R63327G6P1Q3H4GVPVYMFXEPJ123KNFK6V2EDZVQM756TE0Y7E9M5ME7BEFZ2EXDJDRZXCQGFKWABCKCB9SED2BDRXJGT83MB8HYE1WS2F3JF67TQRFMKWCN0PYB44573FSP2EF0X06NM6P50KQZEDVFCNED29AY04K3X9RBN124TSCGM83ECZC701WZ00FF665FR6N7HZ788E8"; + const bs = + "E9AZ4D8HN5JB14BZCCR0MX9M27ZCDD7SXCWPZTSAXE6CKZX70900G8Y2YD9QJDVX4DM14YDSTVVN7KWVSMDC7W6MFHSQXZRT4G40WGRW8MD4J8NTTW0V21R9S1KNDPX9ANBKHWM4NPWZHEKT8T9G5VZRNPDDS2SWSM4A75VCY65ZRHKM6A31PTJGNDJYCSB3G0SPMV88WDM5X3MH6ZFW3YYBW6RJKZSYRDFYEESH2FH8S16SGAZRVN8MHCTC2ZAYN7XQ79NNK743PDSAZ7S2JMGHSTQMFV934FE341D9RSWXHZWK28JE383N9T003WPD8P0AQHGRVKQYVSDEYDVKMVR28F75KFBJGQZSFCZXK0WXM986CQMEEEH4R7E6NTGZ5BKCBYKBAMVWB03C60J73M1W24"; + const sig = + "0FK43KXRXAPQ4MKTVAJ6HMBFETRCFNBKPW27FV407VF2VNGPEMJ293T42GKZ99GQ3MEGMENKKCF9XVAT17ZMSK5HHFW27A97FBM1JZJ3YXAM7DN17QRTXVR4WDQ22NJKA13TA9VVWWDKZA846RXEEMT0QP34XKK7MCBMFC911QSY2DHJBRCQ6XGVDPD4FA06AFDCYCFJRDZCVW50DQKJD93FM546B9D2KF8YRR82NMH1CRTAY06XDRZ53W2KS2P9PBNPPWC2RD83KXETPQM0ZAS1YV7RPBK95EX9SGX2VVQEVHD2SR7RAA46GB6PYTB0MB93EE6XB2SNBCYNTC47SR74FGDN03ACQW1PSSF3VSMH4KN5QTJ4E1B9ZS1N6AVGWZ99V0HX82K9T4AR3CCJQPGXMC"; + + const myBm = rsaBlind( + decodeCrock(messageHash), + decodeCrock(bks), + decodeCrock(rsaPublicKey), + ); + t.deepEqual(encodeCrock(myBm), bm); + + const mySig = rsaUnblind( + decodeCrock(bs), + decodeCrock(rsaPublicKey), + decodeCrock(bks), + ); + t.deepEqual(encodeCrock(mySig), sig); + + const v = rsaVerify( + decodeCrock(messageHash), + decodeCrock(sig), + decodeCrock(rsaPublicKey), + ); + t.true(v); +}); + +test("gnunet-exchange-tvg blind signing (GNUnet git f62e24a8)", (t) => { + const messageHash = + "AJXZQM1V429T10Z0T8AK84NNANM29QZERDPSAHJEEGMC8JWG39RJP7RS0S6Z51JKGMDRKR3VFD058N126QRGFPKZZ4QRTQQ9GDRRH98"; + const rsaPublicKey = + "040000WYSS9AGSVH9771Q0CJ47K5WFTQTDFX14WSY2BR2S14N255EHEHS7QH1Y4V20NFD218EMBYJCNAN399RRFHFCMP29X0YY70DRZ1J7P07ZFHSSNAN5R2G8D50F7ZPN98RJTBB5N22FGNCVHAGRND3T5F1W08Z8S0RY5EWEFG9VQVDW2QNV720H6FWQ97S3FVWMFDKJ2QMJCED592VFHSZ8FD2JR74GZMZFB7HGTJNF82XH8ER034WK66MQ8D9CHXY0481BZCX717F4N5PBMNBVJ2S1TVYHVGZFRKNMTEKK7MJ2V2K6X1Z4XMCH83NRDP1X2CF8QP7XPGY09H1P5QBCAWK8YSMETSNJ5A46E6BBPP6XKMT80TGTJ6860VW9KPTJMKYQJ49PDXXAGVX8FF98T4XS2K04002"; + const bks = "SJ603F6Y4E35CD0BA2ZA1MZEP55JXZQN9BS4VA8G4QZEBRKZVCYG"; + const bm = + "JC6VZVQPWGD0NEK0GTH133CTK81AX41PVV788EE5EMGDESPM2A3N3DK5E7QKG49HN0NYARR4MMEWBEA1MXQKX1RFGGNKJZ4F5W2QNTN6WGP8FHA0SWGPAAY8E90JGJ45ZGW4MYBWBGERC6ENP2HQC8X41YR3ZW38FYM1PBRT474S9P70923GF5P7XY60YW9W9GTZ9E52Y6KJM03970ACG4CAMA8P81JZF3FA5VBD2JQ9MJKNH990Y38WB2ZEA3EF85ES5RVB7ZNTG5DAEW9AX026E1VKXAFWAMQ7WMZ3HNC5PKBSM4WMKX329A382R529PCZPMNVZ7V81SVARY2FXH6412FFMM33C3M6YSYA09V3XE271KBDVCQK8VAHGN180BKE9PAJ8YCDG36WB4MHG5YJD8"; + const bs = + "GEYKYF6TND76TB9M56C3C02HF5C0H2FV618959NDNA72J2YWFWNEXRYP2TQ09DD0WHRNCVFH7BMWN1EKV58XNBXKDVH26SB3KJV0WCHJ0753N5R6YA5SKW9Y8BZZVS1RM432HSM5VXAQCBZR7D39WR2EP5NR3BWRSPTQXEBTM55TEXQYK7QXK9WKBXQN87ZM9GBQRNGG90XW890W9ZSBD4W7MP27H5CA8YNN3MRQQ9TR24PY4PX4YCKSZZXSRT21S4VC2XQJR6N33Z760XJGKGQ83BMKC3797T2C04TY0C94G3CCWV4SFHDH4BTKE1RQN0ERPE1MQJAVH766ZGGW1CK2V3AXKT3KEJHWMAS8CG09B3E31THHZJGWYJ9M7BR8VSMFAP34HR1JYV4K3155H85FY0"; + const sig = + "2QC0HWZNBXPN81JRNJK3MPRT3B4591Q77MZC7SNF24CCM076DZ93HZ8Y10GMM5G675PSM2RGPRA19WQRKR8KFN6CRJ2TZKAMRD93C6VQ1PNQWKN6RCE6XC3RAHNHWKTTVJZ7V377WJAGBT64ASAVQRFX3GT7NXSZ16S6Q2HVD163TQXFZE6MFR6TPQ2ZG9CV2690PFX5VQJ742KDNM5Z7J21147N502CZ2EYW3ZEQ4Z70CXD8VT06TX718Q0GF7FKCDAGJFG9DKA6NZ4J2S6YCXJFGTGJAACZGBC3ABJBVG7CHTHRHSDETSCKEZASKKT0MXMK5BP31MX1NEMWEJWZDEDY5G9JG6TDG2N1ZDAXNHRV7MEZ9XBQA1TPQBT9ANXWVGCECHPC10DN5G11MFXB66Y7R"; + + const myBm = rsaBlind( + decodeCrock(messageHash), + decodeCrock(bks), + decodeCrock(rsaPublicKey), + ); + t.deepEqual(encodeCrock(myBm), bm); + + const mySig = rsaUnblind( + decodeCrock(bs), + decodeCrock(rsaPublicKey), + decodeCrock(bks), + ); + t.deepEqual(encodeCrock(mySig), sig); + + const v = rsaVerify( + decodeCrock(messageHash), + decodeCrock(sig), + decodeCrock(rsaPublicKey), + ); + t.true(v); +}); + + +test("gnunet-exchange-tvg blind signing (GNUnet git v0.14.0 again)", (t) => { + const messageHash = + "0KPXQ02JNKX2B7XKTEQX0JBNCJPRCWGJNF8RK5ECDWBQETX44HCAESXHTRJ67S6AVQ43ZTKSJPDT09ZD3VR1K9JTWNJ5JYQMT78FQE8"; + const rsaPublicKey = + "040000ZTZ0RFMX7K1EE2WK284EMNBMCPA0RMDVHVZCQ4P9ZW0V9BAEFMM34WKQN1VJTQEYCEP5F14SEMZR3E55FZ6GN1T77WST9BCW0BF6Y6G7W55DWX1D3HW8Y9EE1CE9Q77M2HKBC01XW7HCMY79021H353XGEX5E746ZAPNZ5B6RWX8VSD2X5HYSJCA4A1K8NRTMD85CV26N39NPF64F0QCNEMTT937TCS2KEJZWPQ3JBHFGTJ3TMXA283QMW06PR6FHX26ECEV08NRRCK2ARDS5XQDB0N19CS7C1R6E0WQ83JPBCM66Z4F9Y44WMMGXFHJWQD15Z4X4SBRASFM54DRX9P38Q51QT41SEMSG17AND2FGJ1FFB1MNTNRJ6M8KZJBWVG8JCJK4XT70X8SDS896YXFVD04002"; + const bks = "T2GASPN0MFC86A629SRSN3DQ8WEMQM9PPW1GY3EX6Z0R6CMQRYEG"; + const bm = + "TNRCH0YSEPQQ2TNK8P0KCC2148TAHJ9ZET8ABNYQXS77TXY83AETEAX100TNE5TG9QXB6HEE7356Y89Y1ATC12Z9RZHEM11R2Q6KK64WN0J36TRJHCYBJ3ZTRBFVFX8894R9XGX86RQ6Y96RSNNFETF455PTF9NC60SPN5T3TNX0N889BG2A5Z19KY5WCMWQ4YA9FCZ07VKD8XKYCHX3XDC256NTCFEENMRM9G8R0VSSMH2BKK2GJ09J1JYGMEQS71DPDP5GYZ6A47FRC1WT5GT209RB9XYV6DM54E54WZCET1Z9ZHE06B89KXE83CGXDPYTNJ1SCFRCQ5Y6443JBCYE937B7XN65YAVZ8JWY08JFK61CP94P2285FAKHTFY96TAA025BGXA9K8A0QT7Q4ZT18"; + const bs = + "H2KWYFRQTSD85HGGVF856FW45VZXWGT945J8389TJEXHKVE27T93DB0AMW49ZM4WGD3C4E6Q3G0B542MA2D3ASP16KY29BHXJHB599V4WWVJSNPQ2HMZX0DH1H4E8NA9WZX60BTMRBPREWMQVMZTVJ2WHA11R0B2963P38BSGN0AE2DVE53VH2NATQNY5BPKJZ42X1TWFM0XFJ8GJ14PEY40Q2435DHBAD6CA86262X4K93E5FGDFDGXQ4CMGP72EGKJ1J568FD28PXR3JZK1RRKQTW2QJCVY9808ZFKVRTWWY520V7M2FXF5QG8P4A1G1HVQPNE5WZBB2GT1Y07YGHV697F3CQ8M2QSSBFNG136QZSE98PHDSTXA8WRMHEVVWV8D3KHR90Z54TYKBCH8SXC7W"; + const sig = + "C3RJ3W7MCN9D6X7NZ7PG65H375PWKKE3ETMQ0JGCSKXCACQBJVZWP3KR2R9M24771N70HVZGAQ76XGCTG7AGTH2GWJ4SCVA2FRPCD3MJVCNKZVFGQDT1DNVZPDKBCJ46WSKKAB75J4VXF4DW1D4A39RSN3SDCW7QWKQ7QD3QJKSK8ANM817C4FJ7HWYZ3D78MYYHAQGB0JV149C4Y6XV92N263HJVPP8RB8832P98FVENA9SNC6PXNQ4QAGADREBJ0HMQYF477SGC5DXWTX1HGZM1VRF9YDHG6BNQDGRBJ1J965P6F3720JBRM9C923BH9666ZZE40XZQSWCTFPV7EA0A231BJCRC79JX3ADQK826DP6BG1AK69Z5RBDW4J1098GDJEENK15DX6GPX712NSJ34"; + + const myBm = rsaBlind( + decodeCrock(messageHash), + decodeCrock(bks), + decodeCrock(rsaPublicKey), + ); + t.deepEqual(encodeCrock(myBm), bm); + + const mySig = rsaUnblind( + decodeCrock(bs), + decodeCrock(rsaPublicKey), + decodeCrock(bks), + ); + t.deepEqual(encodeCrock(mySig), sig); + + const v = rsaVerify( + decodeCrock(messageHash), + decodeCrock(sig), + decodeCrock(rsaPublicKey), + ); + t.true(v); +}); + + +test("gnunet-exchange-tvg blind signing (GNUnet git 39456ab7)", (t) => { + const messageHash = + "QKV41ZYSNAHMYXJAS2HGNPRJNW9GTRZM42SGNT0K9436ESQWDZHFD3XGY08C611VQQB44ACKVDTSF7GQJ8D2ZKDT2Q5BR1N98G24AF8"; + const rsaPublicKey = + "040000XACG6M4386HT4RJST513ZE489QSJSBC4X1FEAYEF7A9MCPJ2VQ6R4WQYWYA03FCAH6XA5N99APKFFMGEM6ER7HHEH2HZ3MZZ622WG09QYEMNYBJ5SV8MKTNWR1HF3M7KSK3GG2WVSRRA40CFN0PMWHG56RFZF46WBWB8KE6YVYWD7NDCRGHZ24J9ZHAESHFNBRGXG47459TRTR8X7D88NY5PRTJFJ3MKF0TET9975XVV6B2A05850YD1SQ7Z0VDM934VJ1N7DEBEDVE7MQSSNC8EW0RW3BNYC51R16DYP1CDHCY8T5ASRXA89R8AGZ1WQ4Y0HZTKHWK40Y0QEV6ASNT005M99TNS1DD9HDM15S98F9H1RF5B6QYCDPQ24F7WNJK5PNEQFDZJJBC6B5AQQQV9G104002"; + const bks = "SWB2XNW91AJSWVQGRBF04X803D4J2JXHZTH7EY6WZH7C4D2C0TA0"; + const bm = + "H54JFWTTAPW0BGD65N5VMW37P9CF7T296AAQ3K84EQ74CCJ1AP4TFRA8N8RJXX65T1ZNQ4TYSFVJ32VA1J5KPQ0FZ31D32B34B8KHPGMCMNRY79B2JEAN6P52JGA18SERYD9E8TEDNPM2V58PHBFJFBK4NQ2CBW0GVEG55VAYQM43F4M0HWABRC4S0KJ12WYK8GPC230QK8N1FGJCENTAAG5BY8FAZ2DBXWQ06XHQ93C0V04BG7QVKNGA33R5TC1XG82MJWH8RGX5V1HQTMFGA2BJ008C70T5XX47RY8P3YQ51NV0S77G3Y2AMFVYZRHV95AQACWZ7X6B9KWAB4ZCB98QC9XN1AKD7AEM37KCR87SB7HKHQA7PH4WMXKRT4N22C6Y3DZ9BRXYCYPSPX10T52TW"; + const bs = + "DZXJDQKZDG3VR0KGNE0AC9GRSG65QXKXXVXHVHVPZFYBDSYEPD8C4SD8QVFY7FRX1YRYZ5RKX1MXSYPSSPDY38Y2694CBBJXNSGYGJ1Z1XW6PJAZ8ATJZMMDHVMXBAY7C9YX44VFHDRXSS2DRXQ6XNNT7X344AFMD06QTFH9RD2XCKAA1DZN09V6VBWGP54E6QYC8QS9XY6ZRBRV631KVCQM39PN5YXSZPN9KH30KWJMD2D03KYPA2WJE5G89S24GBBP8SQ3F2XNPEACW4ACC1GSGRQCEGGTJFM1VVSNYZ44HMV7BMRDHT3W7AT49WS772AJEYBZFNDJMJAMQNZRW14MZHAANAEE2RDZ9BGYPHKXAWA7A8ZKEHZTFHFPTGQ9GW76H427C1S1X5GPJV498RTSAG"; + const sig = + "3NZN0YFM6C0A58WC3F3RAQVFBH6PZZQB1B7JY3V49378K38E2PH8EBJ8134VCCSP4T6R3YE1GX7HM3CMD4RQVWRVB646SFJDG4AWJA6JN2Q227RRB8BR852CCVBWQAG1MVVX20HJ5QB6FRS8DFKPE6YCSB4N5CGYTMHC3HW8DX9ARJGRBRJEWHK84PQCBWC6ZCGES3N1ESE8VTS0EXFB1CSY8XDPKRHA2EZTV01GQZDYKS8G4Z8852CJ809Y3WNSHECKTC8G3M2DFP3QABKZ7NTZTFPY4ZH93BJ9SEY2VFTCV5XWP9H5556ZQWQH06833D2WX26BH02Q7BCAJ72MPS1Q85EFEBVRDXCVYGK9PXP1Y0SYRGJAHBJ4F0NPV0Z8G7FMJHQPF5B48YF7AQMZ3BDPA0"; + + const myBm = rsaBlind( + decodeCrock(messageHash), + decodeCrock(bks), + decodeCrock(rsaPublicKey), + ); + t.deepEqual(encodeCrock(myBm), bm); + + const mySig = rsaUnblind( + decodeCrock(bs), + decodeCrock(rsaPublicKey), + decodeCrock(bks), + ); + t.deepEqual(encodeCrock(mySig), sig); + + const v = rsaVerify( + decodeCrock(messageHash), + decodeCrock(sig), + decodeCrock(rsaPublicKey), + ); + t.true(v); +}); diff --git a/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts b/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts index 41836fdfa..e55fa3d7b 100644 --- a/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts +++ b/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts @@ -72,6 +72,10 @@ import { timestampTruncateToSecond, } from "../../util/time"; +import { Logger } from "../../util/logging"; + +const logger = new Logger("cryptoImplementation.ts"); + enum SignaturePurpose { WALLET_RESERVE_WITHDRAW = 1200, WALLET_COIN_DEPOSIT = 1201, @@ -402,9 +406,14 @@ export class CryptoImplementation { const planchetsForGammas: RefreshPlanchet[][] = []; + logger.trace("starting RC computation"); + for (let i = 0; i < kappa; i++) { const transferKeyPair = createEcdheKeyPair(); sessionHc.update(transferKeyPair.ecdhePub); + logger.trace( + `HASH transfer_pub ${encodeCrock(transferKeyPair.ecdhePub)}`, + ); transferPrivs.push(encodeCrock(transferKeyPair.ecdhePriv)); transferPubs.push(encodeCrock(transferKeyPair.ecdhePub)); } @@ -413,11 +422,16 @@ export class CryptoImplementation { for (let i = 0; i < denomSel.count; i++) { const r = decodeCrock(denomSel.denom.denomPub); sessionHc.update(r); + logger.trace(`HASH new_coins ${encodeCrock(r)}`); } } sessionHc.update(decodeCrock(meltCoin.coinPub)); + logger.trace(`HASH coin_pub ${meltCoin.coinPub}`); sessionHc.update(amountToBuffer(valueWithFee)); + logger.trace( + `HASH melt_amount ${encodeCrock(amountToBuffer(valueWithFee))}`, + ); for (let i = 0; i < kappa; i++) { const planchets: RefreshPlanchet[] = []; @@ -445,7 +459,17 @@ export class CryptoImplementation { publicKey: encodeCrock(coinPub), }; planchets.push(planchet); + + logger.trace( + `GENERATE i=${i} coin=${coinNumber} m=${encodeCrock( + pubHash, + )} bf=${encodeCrock(blindingFactor)} dp=${encodeCrock( + denomPub, + )} ev=${encodeCrock(ev)}`, + ); + sessionHc.update(ev); + logger.trace(`HASH ev ${encodeCrock(ev)}`); } } planchetsForGammas.push(planchets); @@ -453,6 +477,8 @@ export class CryptoImplementation { const sessionHash = sessionHc.finish(); + logger.trace(`RHASH ${encodeCrock(sessionHash)}`); + const confirmData = buildSigPS(SignaturePurpose.WALLET_COIN_MELT) .put(sessionHash) .put(decodeCrock(meltCoin.denomPubHash)) @@ -600,7 +626,9 @@ export class CryptoImplementation { } else { hOld = new Uint8Array(64); } - const sigBlob = new SignaturePurposeBuilder(SignaturePurpose.SYNC_BACKUP_UPLOAD) + const sigBlob = new SignaturePurposeBuilder( + SignaturePurpose.SYNC_BACKUP_UPLOAD, + ) .put(hOld) .put(hNew) .build(); |