// pair establishes a new pairing over this channel, using the provided secret.
505520
func (s *Session) pair(secret []byte) (smartcardPairing, error) {
	err := s.Channel.Pair(secret)
	if err != nil {
		return smartcardPairing{}, err
	}

	return smartcardPairing{
		PublicKey:    s.Wallet.PublicKey,
		PairingIndex: s.Channel.PairingIndex,
		PairingKey:   s.Channel.PairingKey,
		Accounts:     make(map[common.Address]accounts.DerivationPath),
	}, nil
}
988141
func (pl *PairList) Keys() []string {
	keys := make([]string, 0, len(pl.Pairs))
	for k := range pl.Pairs {
		keys = append(keys, k)
	}
	sort.Strings(keys)
	return keys
}
887449
func (s *State) Channel(channelID string) (*Channel, error) {
	if s == nil {
		return nil, ErrNilState
	}

	s.RLock()
	defer s.RUnlock()

	if c, ok := s.channelMap[channelID]; ok {
		return c, nil
	}

	return nil, ErrStateNotFound
}
1118997
func (p *Pair) String() string {
	return fmt.Sprintf("(%v, %v)", p.X, p.Y)
}
635813
func (client *Client) PairWithFacade(str string) (tok Token, err error) {
	paylo := make(map[string]string)
	paylo["facade"] = str
	tok, err = client.PairClient(paylo)
	return tok, err
}
1187485
func (pl *PairList) Set(s string) error {
	entries := strings.Split(s, ",")

	for _, e := range entries {
		p := strings.SplitN(e, "=", 2)
		if len(p) != 2 {
			return fmt.Errorf("could not parse key=value pair %v", s)
		}
		key := p[0]
		val := p[1]
		err := pl.SetOne(key, val)
		if err != nil {
			return err
		}

	}
	return nil
}
842828
func (t *PairTree) Do(f PairIterateFunc) {
	t.ObjectTree.Do(func(v interface{}) bool { return f(v.(Pair)) })
}
656245
func (conn *Conn) Join(channel string, key ...string) {
	k := ""
	if len(key) > 0 {
		k = " " + key[0]
	}
	conn.Raw(JOIN + " " + channel + k)
}
727229
func New(password, body string) *Secret {
	return &Secret{
		password: password,
		body:     body,
	}
}
722768
func Seal(version Version, plaintext []byte, sender BoxSecretKey, receivers []BoxPublicKey) (out []byte, err error) {
	ephemeralKeyCreator, err := receiversToEphemeralKeyCreator(receivers)
	if err != nil {
		return nil, err
	}
	return seal(version, plaintext, sender, receivers, ephemeralKeyCreator, defaultEncryptRNG{})
}
618889
func (in *Secret) DeepCopy() *Secret {
	if in == nil {
		return nil
	}
	out := new(Secret)
	in.DeepCopyInto(out)
	return out
}
375281
func (c *ReactionsGetCall) Channel(channel string) *ReactionsGetCall {
	c.channel = channel
	return c
}
353291
func parse(str string, index int) *Pair {
	var key, value string
	if index > 0 {
		key, value = str[:index], str[index+1:]
	} else if index == 0 {
		key, value = "", str[1:]
	} else if index < 0 {
		key, value = str, ""
	}

	return &Pair{Key: key, Value: value}
}
1370224
func (s *SecureChannelSession) Open() error {
	if s.iv != nil {
		return fmt.Errorf("Session already opened")
	}

	response, err := s.open()
	if err != nil {
		return err
	}

	// Generate the encryption/mac key by hashing our shared secret,
	// pairing key, and the first bytes returned from the Open APDU.
	md := sha512.New()
	md.Write(s.secret)
	md.Write(s.PairingKey)
	md.Write(response.Data[:scSecretLength])
	keyData := md.Sum(nil)
	s.sessionEncKey = keyData[:scSecretLength]
	s.sessionMacKey = keyData[scSecretLength : scSecretLength*2]

	// The IV is the last bytes returned from the Open APDU.
	s.iv = response.Data[scSecretLength:]

	return s.mutuallyAuthenticate()
}
1280833
func (s Secret) Clone() Secret {
	out := Secret{Current: s.Current.Clone()}
	if s.Previous != nil {
		out.Previous = make([]NamedBlob, len(s.Previous))
		for i := range out.Previous {
			out.Previous[i] = s.Previous[i].Clone()
		}
	}
	return out
}
1297376
func (c *Channel) Link(channel ...*Channel) {
	packet := MumbleProto.ChannelState{
		ChannelId: &c.ID,
		LinksAdd:  make([]uint32, len(channel)),
	}
	for i, ch := range channel {
		packet.LinksAdd[i] = ch.ID
	}
	c.client.Conn.WriteProto(&packet)
}
1017037
func (k *Kontrol) KeyPair() (pair *KeyPair, err error) {
	if k.selfKeyPair != nil {
		return k.selfKeyPair, nil
	}

	kiteKey := k.Kite.KiteKey()

	if kiteKey == "" || len(k.lastPublic) == 0 {
		return nil, errNoSelfKeyPair
	}

	keyIndex := -1

	me := new(multiError)

	for i := range k.lastPublic {
		ri := len(k.lastPublic) - i - 1

		keyFn := func(token *jwt.Token) (interface{}, error) {
			if _, ok := token.Method.(*jwt.SigningMethodRSA); !ok {
				return nil, errors.New("invalid signing method")
			}

			return jwt.ParseRSAPublicKeyFromPEM([]byte(k.lastPublic[ri]))
		}

		if _, err := jwt.ParseWithClaims(kiteKey, &kitekey.KiteClaims{}, keyFn); err != nil {
			me.err = append(me.err, err)
			continue
		}

		keyIndex = ri
		break
	}

	if keyIndex == -1 {
		return nil, fmt.Errorf("no matching self key pair found: %s", me)
	}

	k.selfKeyPair = &KeyPair{
		ID:      k.lastIDs[keyIndex],
		Public:  k.lastPublic[keyIndex],
		Private: k.lastPrivate[keyIndex],
	}

	return k.selfKeyPair, nil
}