bnb-chain / tss-lib

Threshold Signature Scheme, for ECDSA and EDDSA
MIT License
790 stars 271 forks source link

[Audit] Inconsistent arguments validation in range proof #47

Closed jpopxfile closed 5 years ago

jpopxfile commented 5 years ago

The verification function checks that arguments are not nil:

func (pf *RangeProofAlice) Verify(pk *paillier.PublicKey, NTilde, h1, h2, c *big.Int) bool {
  if pf == nil || pk == nil || NTilde == nil || h1 == nil || h2 == nil || c == nil {
    return false
  }
...

However the proof creation does not perform any such checks (and might fail upon nil values when performing arithmetic operations):

func ProveRangeAlice(pk *paillier.PublicKey, c, NTilde, h1, h2, m, r *big.Int) *RangeProofAlice {
  q := tss.EC().Params().N
  q3 := new(big.Int).Mul(q, q)
  q3 = new(big.Int).Mul(q, q3)
  ...

We recommend to add nil checks for extra safety.