func newSharedSecret(p *panda_proto.KeyExchange_SharedSecret) (*SharedSecret, bool) { ret := &SharedSecret{ Secret: p.GetSecret(), Day: int(p.Time.GetDay()), Month: int(p.Time.GetMonth()), Year: int(p.Time.GetYear()), Hours: int(p.Time.GetHours()), Minutes: int(p.Time.GetMinutes()), } ret.Cards.NumDecks = int(p.GetNumDecks()) if ret.Cards.NumDecks > 0 { if len(p.CardCount) != numCards { return nil, false } copy(ret.Cards.counts[:], p.CardCount) } else { if len(ret.Secret) == 0 { return nil, false } } return ret, true }