// check the entire proof set, failing if any one proof fails.
333927
func (p *proofSetT) check(ctx context.Context, world LoaderContext, parallel bool) (err error) {
	defer p.G().CTrace(ctx, "TeamLoader proofSet check", func() error { return err })()

	if parallel {
		return p.checkParallel(ctx, world)
	}

	var total int
	for _, v := range p.proofs {
		total += len(v)
	}

	var i int
	for _, v := range p.proofs {
		for _, proof := range v {
			p.G().Log.CDebugf(ctx, "TeamLoader proofSet check [%v / %v]", i, total)
			err = proof.check(ctx, p.G(), world, p)
			if err != nil {
				return err
			}
			i++
		}
	}
	return nil
}
1347082
func (m MultiError) any(pred func(Error) bool) bool {
	for _, e := range m {
		if ourErr, ok := e.(Error); ok && pred(ourErr) {
			return true
		}
	}
	return false
}
1275524
func (c *constraint) check(v *Version) bool {
	return c.function(v, c)
}
367595
func CheckProof(m libkb.MetaContext, pvlS string, service keybase1.ProofType, info ProofInfo) libkb.ProofError {
	m1 := newMetaContext(m, info.stubDNS)
	perr := checkProofInner(m1, pvlS, service, info)
	if perr != nil {
		debug(m1, "CheckProof failed: %v", perr)
	}
	if perr != nil && perr.GetProofStatus() == keybase1.ProofStatus_INVALID_PVL {
		return libkb.NewProofError(keybase1.ProofStatus_INVALID_PVL,
			"Invalid proof verification instructions! Let us know at https://github.com/keybase/keybase-issues/new")
	}
	return perr
}
448585
func (self *Collection) Check() error {
	var merr error

	for i, field := range self.Fields {
		if field.Name == `` {
			merr = log.AppendError(merr, fmt.Errorf("collection[%s] field #%d cannot have an empty name", self.Name, i))
		}

		if ParseFieldType(string(field.Type)) == `` {
			merr = log.AppendError(merr, fmt.Errorf("collection[%s] field[%s]: invalid type %q", self.Name, field.Name, field.Type))
		}
	}

	return merr
}
623937
func Check(d *certdata.Data) *errors.Errors {
	var e = errors.New(nil)

	// Check if we use SHA1 or less (MD5, MD2)
	if d.Cert.SignatureAlgorithm > x509.SHA1WithRSA &&
		d.Cert.SignatureAlgorithm != x509.DSAWithSHA1 &&
		d.Cert.SignatureAlgorithm != x509.ECDSAWithSHA1 {
		return e
	}

	if d.Cert.NotBefore.After(time.Date(2016, 1, 1, 0, 0, 0, 0, time.UTC)) {
		e.Err("Certificate is using SHA1, but is issued on/after 1 Jan 2016")
		return e
	}

	if d.Cert.NotBefore.After(time.Date(2015, 1, 16, 0, 0, 0, 0, time.UTC)) &&
		d.Cert.NotAfter.After(time.Date(2017, 1, 1, 0, 0, 0, 0, time.UTC)) {
		e.Err("Certificate is using SHA1, but is still valid on/after 1 Jan 2017")
		return e
	}

	return nil
}
449117
func (v *Validation) Check(obj interface{}, checks ...Validator) *ValidationResult {
	var result *ValidationResult
	for _, check := range checks {
		result = v.apply(check, obj)
		if !result.Ok {
			return result
		}
	}
	return result
}
137296
func checkExclusive(ctx *cli.Context, args ...interface{}) {
	set := make([]string, 0, 1)
	for i := 0; i < len(args); i++ {
		// Make sure the next argument is a flag and skip if not set
		flag, ok := args[i].(cli.Flag)
		if !ok {
			panic(fmt.Sprintf("invalid argument, not cli.Flag type: %T", args[i]))
		}
		// Check if next arg extends current and expand its name if so
		name := flag.GetName()

		if i+1 < len(args) {
			switch option := args[i+1].(type) {
			case string:
				// Extended flag check, make sure value set doesn't conflict with passed in option
				if ctx.GlobalString(flag.GetName()) == option {
					name += "=" + option
					set = append(set, "--"+name)
				}
				// shift arguments and continue
				i++
				continue

			case cli.Flag:
			default:
				panic(fmt.Sprintf("invalid argument, not cli.Flag or string extension: %T", args[i+1]))
			}
		}
		// Mark the flag if it's set
		if ctx.GlobalIsSet(flag.GetName()) {
			set = append(set, "--"+name)
		}
	}
	if len(set) > 1 {
		Fatalf("Flags %v can't be used at the same time", strings.Join(set, ", "))
	}
}
1201775
func (t proofTerm) equal(u proofTerm) bool {
	return t.seqno() == u.seqno()
}
1073445
func VerifyAll(t Failable, header string, collection interface{}, transform func(interface{}) string) error {
	if len(header) != 0 {
		header = fmt.Sprintf("%s\n\n\n", header)
	}

	outputText := header + strings.Join(utils.MapToString(collection, transform), "\n")
	return VerifyString(t, outputText)
}
57026
func (a ABCIResults) ProveResult(i int) merkle.SimpleProof {
	_, proofs := merkle.SimpleProofsFromByteSlices(a.toByteSlices())
	return *proofs[i]
}
1342998
func (a *Assertion) True(expr bool, msg ...interface{}) *Assertion {
	True(a.t, expr, msg...)
	return a
}
431430
func (a *Assertions) False(value bool, msgAndArgs ...interface{}) bool {
	return False(a.t, value, msgAndArgs...)
}
12623
func VerifyAllCombinationsFor9(
	t Failable,
	header string,
	transform func(a, b, c, d, e, f, g, h, i interface{}) string,
	collection1,
	collection2,
	collection3,
	collection4,
	collection5,
	collection6,
	collection7,
	collection8,
	collection9 interface{}) error {

	if len(header) != 0 {
		header = fmt.Sprintf("%s\n\n\n", header)
	}

	var mapped []string

	slice1 := reflect.ValueOf(collection1)
	slice2 := reflect.ValueOf(collection2)
	slice3 := reflect.ValueOf(collection3)
	slice4 := reflect.ValueOf(collection4)
	slice5 := reflect.ValueOf(collection5)
	slice6 := reflect.ValueOf(collection6)
	slice7 := reflect.ValueOf(collection7)
	slice8 := reflect.ValueOf(collection8)
	slice9 := reflect.ValueOf(collection9)

	for i1 := 0; i1 < slice1.Len(); i1++ {
		for i2 := 0; i2 < slice2.Len(); i2++ {
			for i3 := 0; i3 < slice3.Len(); i3++ {
				for i4 := 0; i4 < slice4.Len(); i4++ {
					for i5 := 0; i5 < slice5.Len(); i5++ {
						for i6 := 0; i6 < slice6.Len(); i6++ {
							for i7 := 0; i7 < slice7.Len(); i7++ {
								for i8 := 0; i8 < slice8.Len(); i8++ {
									for i9 := 0; i9 < slice9.Len(); i9++ {
										p1 := slice1.Index(i1).Interface()
										p2 := slice2.Index(i2).Interface()
										p3 := slice3.Index(i3).Interface()
										p4 := slice4.Index(i4).Interface()
										p5 := slice5.Index(i5).Interface()
										p6 := slice6.Index(i6).Interface()
										p7 := slice7.Index(i7).Interface()
										p8 := slice8.Index(i8).Interface()
										p9 := slice9.Index(i9).Interface()

										parameterText := getParameterText(p1, p2, p3, p4, p5, p6, p7, p8, p9)
										transformText := getTransformText(transform, p1, p2, p3, p4, p5, p6, p7, p8, p9)
										if transformText != SkipThisCombination {
											mapped = append(mapped, fmt.Sprintf("%s => %s", parameterText, transformText))
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}

	outputText := header + strings.Join(mapped, "\n")
	return VerifyString(t, outputText)
}
1116542
func (p *proofSetT) checkParallel(ctx context.Context, world LoaderContext) (err error) {

	var total int
	for _, v := range p.proofs {
		total += len(v)
	}
	p.G().Log.CDebugf(ctx, "TeamLoader proofSet check parallel [%v]", total)

	queue := make(chan proof)
	go func() {
		for _, v := range p.proofs {
			for _, proof := range v {
				queue <- proof
			}
		}
		close(queue)
	}()

	group, ctx := errgroup.WithContext(libkb.CopyTagsToBackground(ctx))
	const pipeline = 20
	for i := 0; i < pipeline; i++ {
		group.Go(func() error {
			for {
				select {
				case <-ctx.Done():
					return ctx.Err()
				case proof, ok := <-queue:
					if !ok {
						return nil
					}
					err = proof.check(ctx, p.G(), world, p)
					if err != nil {
						return err
					}
				}
			}
		})
	}

	return group.Wait()
}
220846
func checkConstraint(ctx Context, operand string, lVal, rVal interface{}, lFound, rFound bool) bool {
	// Check for constraints not handled by this checker.
	switch operand {
	case structs.ConstraintDistinctHosts, structs.ConstraintDistinctProperty:
		return true
	default:
		break
	}

	switch operand {
	case "=", "==", "is":
		return lFound && rFound && reflect.DeepEqual(lVal, rVal)
	case "!=", "not":
		return !reflect.DeepEqual(lVal, rVal)
	case "<", "<=", ">", ">=":
		return lFound && rFound && checkLexicalOrder(operand, lVal, rVal)
	case structs.ConstraintAttributeIsSet:
		return lFound
	case structs.ConstraintAttributeIsNotSet:
		return !lFound
	case structs.ConstraintVersion:
		return lFound && rFound && checkVersionMatch(ctx, lVal, rVal)
	case structs.ConstraintRegex:
		return lFound && rFound && checkRegexpMatch(ctx, lVal, rVal)
	case structs.ConstraintSetContains, structs.ConstraintSetContainsAll:
		return lFound && rFound && checkSetContainsAll(ctx, lVal, rVal)
	case structs.ConstraintSetContainsAny:
		return lFound && rFound && checkSetContainsAny(lVal, rVal)
	default:
		return false
	}
}
869450
func (p *SetupServerSession) ProofFromClientProof(clientProof []byte) ([]byte, error) {
	if !p.session.VerifyClientAuthenticator(clientProof) { // Validates M1 based on S and A
		return nil, errors.New("Client proof is not valid")
	}

	return p.session.ComputeAuthenticator(clientProof), nil
}