Consensys / eth-lightwallet

Lightweight JS Wallet for Node and the browser
MIT License
1.47k stars 503 forks source link

signing.concatSig sometimes produces invalid signatures #170

Closed miladmostavi closed 6 years ago

miladmostavi commented 6 years ago

This happens when r or s start with zero. The resulting string ends up with less than 32 bytes.

To reproduce this try to sign 0xacdfc5f85167f748f4b10c34c27c03202918b7e89b61cb4dd5372f6274198f2b with this private key: 3297df1b48b8de12e40e8f51c2d99ac7042f77fa7b912f536f81c4e8378b6205.

The result should be: 0xef28df7e1d0667bc6b34f36b03fc9f7aed5902e77923dca5a519f738b082e70e0001e712c691b6653b783f21f199a10b91b9d93ee12984560053b8c507109af51c, but instead we get 0xef28df7e1d0667bc6b34f36b03fc9f7aed5902e77923dca5a519f738b082e70e0001e712c691b6653b783f21f199a10b91b9d93ee12984560053b8c507109af51c.

This is because s in this case is returned 01e712c691b6653b783f21f199a10b91b9d93ee12984560053b8c507109af5 instead of 0001e712c691b6653b783f21f199a10b91b9d93ee12984560053b8c507109af5.

coder5876 commented 6 years ago

Merged #171 which fixes this.