// Select selects n witnesses out of provided list of witnesses.
Select selects n witnesses out of provided list of witnesses.
// Select selects n witnesses out of provided list of witnesses .
func (s *Selector) Select(witnesses []*proof.Witness, n int) ([]*proof.Witness, error) {
	l := len(witnesses)
	if n > l {
		return nil, fmt.Errorf("unable to select %d witnesses from witness array of length %d", n, len(witnesses))
	}
	if n == l {
		return witnesses, nil
	}
	max := len(witnesses)
	var selected []*proof.Witness
	uniqueIndexes := make(map[int]bool)
	for i := 0; i < n; i++ {
		for {
			i := rand.Intn(max) 
			if _, ok := uniqueIndexes[i]; !ok {
				uniqueIndexes[i] = true
				selected = append(selected, witnesses[i])
				break
			}
		}
	}
	return selected, nil
}
func ( s * Selector ) Select ( witnesses [ ] * proof . Witness , n int ) ( [ ] * proof . Witness , error ) { l := len ( witnesses ) if n > l { return nil , fmt . Errorf ( " " , n , len ( witnesses ) ) } if n == l { return witnesses , nil } max := len ( witnesses ) var selected [ ] * proof . Witness uniqueIndexes := make ( map [ int ] bool ) for i := 0 ; i < n ; i ++ { for { i := rand . Intn ( max ) if _ , ok := uniqueIndexes [ i ] ; ! ok { uniqueIndexes [ i ] = true selected = append ( selected , witnesses [ i ] ) break } } } return selected , nil }
Select selects n witnesses out of provided list of witnesses.
Select selects n witnesses out of provided list of witnesses .
//nolint:gosec