sigp / ecies-parity

JavaScript Elliptic Curve Integrated Encryption Scheme (ECIES) Library - Based off Parity's implementation
MIT License
16 stars 8 forks source link

Incorrect MAC #12

Open profcav opened 3 years ago

profcav commented 3 years ago

I have generated 10000 crypted messages in python, about 40 of them causing incorrect MAC error in ecies-parity verify The problem seems to be in this (javascript) part Tracing one of the "bad" messages, I see in browser.js derive function:

privateKeyA Uint8Array(32) [142, 11, 200, 145, 112, 236, 88, 70, 72, 85, 45, 54, 60, 137, 39, 164, 64, 173, 143, 227, 189, 30, 126, 130, 132, 209, 164, 192, 178, 231, 245, 7]

publicKeyB Uint8Array(65) [4, 9, 46, 45, 197, 50, 92, 238, 205, 224, 221, 138, 77, 86, 171, 14, 220, 179, 211, 45, 205, 57, 75, 119, 58, 219, 229, 188, 167, 23, 149, 56, 79, 7, 212, 39, 1, 248, 247, 14, 82, 168, 124, 69, 223, 93, 179, 232, 4, 175, 3, 12, 34, 75, 145, 14, 44, 106, 177, 11, 60, 170, 170, 154, 41]

and the Buffer returned by the function is 31 bytes long instead of 32 bytes

px Uint8Array(31) [22, 236, 220, 122, 152, 53, 54, 68, 24, 50, 246, 189, 98, 159, 167, 221, 207, 33, 34, 8, 193, 221, 163, 79, 231, 48, 111, 130, 45, 4, 41]