diff options
author | Florian Dold <florian@dold.me> | 2020-12-02 21:56:20 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2020-12-02 21:56:20 +0100 |
commit | 1ad064a2a5194dba3c512f244bf4e809c8ce5518 (patch) | |
tree | 1f842a23e26f9a9af29e6089b74048e5029dd105 /packages/taler-wallet-core/src/crypto/talerCrypto-test.ts | |
parent | 92885fa155a1c840be9ea897257ca9cbaee8d38f (diff) | |
download | wallet-core-1ad064a2a5194dba3c512f244bf4e809c8ce5518.tar.xz |
regression tests
Diffstat (limited to 'packages/taler-wallet-core/src/crypto/talerCrypto-test.ts')
-rw-r--r-- | packages/taler-wallet-core/src/crypto/talerCrypto-test.ts | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/packages/taler-wallet-core/src/crypto/talerCrypto-test.ts b/packages/taler-wallet-core/src/crypto/talerCrypto-test.ts index b273b0188..a8db6c44e 100644 --- a/packages/taler-wallet-core/src/crypto/talerCrypto-test.ts +++ b/packages/taler-wallet-core/src/crypto/talerCrypto-test.ts @@ -195,3 +195,94 @@ test("incremental hashing #2", (t) => { t.deepEqual(encodeCrock(h1), encodeCrock(h3)); t.deepEqual(encodeCrock(h1), encodeCrock(h2)); }); + +test("taler-exchange-tvg eddsa_ecdh #2", (t) => { + const priv_ecdhe = "W5FH9CFS3YPGSCV200GE8TH6MAACPKKGEG2A5JTFSD1HZ5RYT7Q0"; + const pub_ecdhe = "FER9CRS2T8783TAANPZ134R704773XT0ZT1XPFXZJ9D4QX67ZN00"; + const priv_eddsa = "MSZ1TBKC6YQ19ZFP3NTJVKWNVGFP35BBRW8FTAQJ9Z2B96VC9P4G"; + const pub_eddsa = "Y7MKG85PBT8ZEGHF08JBVZXEV70TS0PY5Y2CMEN1WXEDN63KP1A0"; + const key_material = + "G6RA58N61K7MT3WA13Q7VRTE1FQS6H43RX9HK8Z5TGAB61601GEGX51JRHHQMNKNM2R9AVC1STSGQDRHGKWVYP584YGBCTVMMJYQF30"; + + const myEcdhePub = ecdheGetPublic(decodeCrock(priv_ecdhe)); + t.deepEqual(encodeCrock(myEcdhePub), pub_ecdhe); + + const myEddsaPub = eddsaGetPublic(decodeCrock(priv_eddsa)); + t.deepEqual(encodeCrock(myEddsaPub), pub_eddsa); + + const myKm1 = keyExchangeEddsaEcdhe( + decodeCrock(priv_eddsa), + decodeCrock(pub_ecdhe), + ); + t.deepEqual(encodeCrock(myKm1), key_material); + + const myKm2 = keyExchangeEcdheEddsa( + decodeCrock(priv_ecdhe), + decodeCrock(pub_eddsa), + ); + t.deepEqual(encodeCrock(myKm2), key_material); +}); + +test("eddsa_ecdh regression #1 (wallet)", (t) => { + const myKm2 = keyExchangeEcdheEddsa( + decodeCrock("95P1ZRBAFZNXJ1DVZ3EANBM5KZ99AB5DNNY28CCVNWM902E9B7H0"), + decodeCrock("MWE4WM4D3FXRQ66X785CHX44XCN0ZDT2X3ND9CTFSVFW2GPKK2VG"), + ); + t.deepEqual( + encodeCrock(myKm2), + "5R9JBB5HBHC05XHXXFQVVN9ZKSXY955QZ2TP191793PCJ2SBAES3ZS3S4ZP2711XH81YN07WHCADX8B65V2DWEP1YS48SSXXRE03JKR", + ); +}); + +test("blinding regression (exchange log)", (t) => { + const messageHash = + "7T0M81R8NVB13SYYBDPY0XTP1ZMG091WM6YWFZE8E12DCDD41J242K75EH0KYQRMQJE278BCH8AYE7B89QZYGG9WBN8RHY8TVVDX9MR"; + const rsaPublicKey = + "020000XXM4C51WSNR83AYQG2D0HH5Y8D94R7WRZ7T6JG1TSMHF449TR0W4E2V68TZDWHWKW05T6Z132DEQ8K38EPHVSD77PJF8C9GSQ482JK2CAQ2PRYX1BQTY4Z1EYZ0Y6VXBY6D27RGCREM3G2X7FXMZJ1ADMVPPFYCSNJYWW2WP4NSVRJ5787K06AGD9F90RT7MKMPPQK0Q69PQHG2001"; + const bks = "VAXMY73TB736XCAM3PJR51E52KH2H3D20RGBWR59X25RRNBKV0N0"; + const bm = + "1BQH71QPF60K9TPE5TNNHDSEQ0N6AK9SEGXXXTW4HHWMR58PF8CEYN8C6NHZ8H19A3A7GRTJCGHHYJJPKX3RQ1SG2MDHWZFP98CDC8TTGZ3TN4FZG7J5MYEJ8239TV1BPQZSFEBYXE7ZJQEBEGW0SWJ6QHX2WM5JFS2ZDW1NXZ720JJVKD0MHE2Y0M3BGQE0SHVV5YMPZ6EME"; + + const myBm = rsaBlind( + decodeCrock(messageHash), + decodeCrock(bks), + decodeCrock(rsaPublicKey), + ); + t.deepEqual(encodeCrock(myBm), bm); +}); + + +test("taler-exchange-tvg blind signing (post-regression)", (t) => { + const messageHash = + "H9RYMXXSRMF2PH8ANYJ0FPW0NYV51120QNJ8HBVTFQ0EN6MVMYMZ5M3KQFDAVTN1S3YFZT42JJ4YS77DAWXHSEC72Q763E7QY0VT8TR"; + const rsaPublicKey = + "040000YFQZJJMK4EJKC9KHQWNMX4E9HHJQKXNFRGFTTW9AN72EJGY55EKCQJ34D8X1Y65DEE5N0D50E1NKFG51V2JJH3DKBZTRG4MJQP1647QDR5FRAM2848013FAW813CNT40EEN9JJM205XSMY525E2NZ9P9RQS1N7D1T05ZNEPXCKG2YPNF0SCNFSRJVJG0WS36BJJN9WH62H8MPBVHJQXXH5HN1FKDZ11GN0KCY9ZX1BRM3HTN66529MMB1MVCDFQKTBH18NZM430XHZFRHR3RQ5A82HNG8649VH686YHA1FNJJAHEZ1P1RCFY93GCJ31W2BJ56N2NYZJJ4CFNAP503D3VYE5HFWFB2XVMW7Q3XXM9KX0PGZMZBN2BRDKNCEYPXPQTYFSPFB1N36KJ7EHA40R8YQ04002"; + const bks = "D76VVVQ678V75M07K07MGN11Z3DPNFRTEEGPSSN3XMEJKQ6WM0F0"; + const bm = + "G9HCGGFNAPAQDCA41FA80VEQME90HDSQ4FZ7BV3A3RNYJS3C9BTM843E07FMH1V5M4Z8DHJQ8Q0BFH8RNBE08QQX1MB67D02ZRNVTJKGSKYMTPSQ4P5G4JJ36EVCQGSJ0GHG20XC93XJQC4JHJ1S0HN5X14VRMMTFXPHM5ZMNZZB2T21QY21CKHVBV907NH9P5XDYJXZQTV2XK8XNMQXT1Q3NCGEBVPQB2WF85SFSWZ0PS1ENHY5CGTKXE8K5NCAEAADQKGZCWJH2E2M7HW901CP863RV4PRA7HPHC29FWZ5EE8M3SKNY9V79K8CGK83WY6A97EAK98597FS10PTHFJD7NSCDM6EF9WAV70611GAQGDEDVAGZ7V48KWZ8FNC0WWRACBKZT0WPA3GPYMRZ9X8K8"; + const bs = + "PMTZ3MWWS4XKFV308HX4PR3NKTJF7TTGDXMR7V4VB42JZV58GT18SB1A1WXKJ7VTK9E92F4FWCEMMA9NTR9EQPJX7G91CBS3N7J9746BF301G8XSQ0M459RGKD5ZX95S5CAG56E61Y29X0HJWB9NC3MT19946NGVZ3027H0MMS5YPZ5HBBD6BJV7BW273YEBD6Q0BSY0WSE8YKG6B4F9KG295ZNTV0GV6TSDQPT4W32F4A1Z1KDVT83XHT68M0HWGSJ9J3MWR2205H2WKRRCAKX87HSWK1HSEZ1EQB5NE998P16MRX8KJWGZFM2ZHNEV20YREP1W4BKETD84JPT050QDS6VJRMNMK4MBF5BCCPCYC12H8F9WD4Z05F0WMMTH7P4Y5FG8QW3N0K732G9K2MS00R"; + const sig = + "SH9V61328M82B0VSSS760922R2Z79WYD6AZRVX0QYS6XYMBB9T8A228G41SK3VZCT826SC489TKMX7G4J6XP3P9VKYDPERP0QYZ0ZH1W4PGS9FARF3A8QHHHRAEQPJYWZM6NW1T7HXAWNK2R256YRJVF703XB0VJT0CJT8PT3ZBM73E584BH8PXNBJ14DZ8K4JGGNQN7WQC2HANX9G452GPVEC898KY6K1Y8D2P6KCHTBHFHVT35QM9NKNERR068QMSMT0FF546SGVFKBCA3SKHWYP94Y845RSR08KFV62DHXXM7EBD664Z7S7RCSD97DB7MHKZ3EXPYHHSF2FZW6NG14GJ25B1ZH51KAB9DKHWYR3S1XTCMXWGJT572EFCE9T90F5R54Z6RDXPJS7FDBWQ6TR"; + + 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); +});
\ No newline at end of file |