Currently, the multisig descriptor constructions are limited to 16 keys only possibly because of template parsing reasons. Under p2sh context, such scripts would be invalid anyway because of 520-byte rule, but we can support up to 20 keys for CHECKMULTISIG in witness script context. 


unsigned int lenR = sig[3];
    
    if (5 + lenR >= sig.size()) return false;
    
    unsigned int lenS = sig[5 + lenR];
    
    
    if ((size_t)(lenR + lenS + 7) != sig.size()) return false;
    
    if (sig[2] != 0x02) return false;
    
    if (lenR == 0) return false;
    
    if (sig[4] & 0x80) return false;
    
    
    if (lenR > 1 && (sig[4] == 0x00) && !(sig[5] & 0x80)) return false;
    
    if (sig[lenR + 4] != 0x02) return false;
    
    if (lenS == 0) return false;
    
    if (sig[lenR + 6] & 0x80) return false;
    
    
    if (lenS > 1 && (sig[lenR + 6] == 0x00) && !(sig[lenR + 7] & 0x80)) return false;
    return true;
}
bool static IsLowDERSignature(const valtype &vchSig, ScriptError* serror) {