solidity-BN256G2 icon indicating copy to clipboard operation
solidity-BN256G2 copied to clipboard

submod method

Open dragan2234 opened this issue 2 years ago • 0 comments

Note that if b>n this method: https://github.com/musalbas/solidity-BN256G2/blob/master/BN256G2.sol#L151

doesn't give the correct representation of (n-b). It gives 2^256+(n-b).

Example: submod(3,11,10) would give you addmod(3,(10-11),10).

10-11 in solidity is 2^256-1 which is 115792089237316195423570985008687907853269984665640564039457584007913129639935

so 3 + 115792089237316195423570985008687907853269984665640564039457584007913129639935 modulo 10 is 8, not 3-11 mod 10 which is 2.

I don't know if that's the issue for the project, I just wanted to note this.

dragan2234 avatar Jan 06 '23 19:01 dragan2234