// GetRawPublicKey returns the raw public key that corresponds to this secret key.
778536
func (k SigningSecretKey) GetRawPublicKey() *[ed25519.PublicKeySize]byte {
	return (*[ed25519.PublicKeySize]byte)(&k.pub)
}
195411
func ParsePublicKeyDER(der []byte) (crypto.PublicKey, error) {
	generalKey, err := x509.ParsePKIXPublicKey(der)
	if err != nil {
		return nil, trace.Wrap(err)
	}
	return generalKey, nil
}
1197048
func (s *SQLKeyDBStore) GetKey(keyID string) data.PublicKey {
	privKey, _, err := s.getKey(keyID, false)
	if err != nil {
		return nil
	}
	return data.NewPublicKey(privKey.Algorithm, []byte(privKey.Public))
}
257763
func (s *Signatory) RealisePublicKey(getter acmstate.AccountGetter) error {
	const errPrefix = "could not realise public key for signatory"
	if s.PublicKey == nil {
		if s.Address == nil {
			return fmt.Errorf("%s: address not provided", errPrefix)
		}
		acc, err := getter.GetAccount(*s.Address)
		if err != nil {
			return fmt.Errorf("%s: could not get account %v: %v", errPrefix, *s.Address, err)
		}
		publicKey := acc.PublicKey
		s.PublicKey = &publicKey
	}
	if !s.PublicKey.IsValid() {
		return fmt.Errorf("%s: public key %v is invalid", errPrefix, *s.PublicKey)
	}
	address := s.PublicKey.GetAddress()
	if s.Address == nil {
		s.Address = &address
	} else if address != *s.Address {
		return fmt.Errorf("address %v provided with signatory does not match address generated from "+
			"public key %v", *s.Address, address)
	}
	return nil
}
1307328
func PEMFromRSAPublicKey(key crypto.PublicKey, headers map[string]string) ([]byte, error) {
	pkey, err := verifyRSAPublicKey(key)
	if err != nil {
		return nil, err
	}
	marshalled, err := x509.MarshalPKIXPublicKey(pkey)
	if err != nil {
		return []byte{}, err
	}
	block := pem.Block{
		Type:    "PUBLIC KEY",
		Headers: headers,
		Bytes:   marshalled,
	}
	bytes := pem.EncodeToMemory(&block)
	return bytes, nil
}
752703
func (s *Store) importPublicKey(ctx context.Context, r string) error {
	for _, kd := range []string{keyDir, oldKeyDir} {
		filename := filepath.Join(kd, r)
		if !s.storage.Exists(ctx, filename) {
			out.Debug(ctx, "Public Key %s not found at %s", r, filename)
			continue
		}
		pk, err := s.storage.Get(ctx, filename)
		if err != nil {
			return err
		}
		return s.crypto.ImportPublicKey(ctx, pk)
	}
	return fmt.Errorf("public key not found in store")
}
103883
func (s *GetParametersForImportOutput) SetPublicKey(v []byte) *GetParametersForImportOutput {
	s.PublicKey = v
	return s
}
1204276
func (ve *SignerValidatorEndpoint) GetPubKey() crypto.PubKey {
	ve.mtx.Lock()
	defer ve.mtx.Unlock()
	return ve.signer.GetPubKey()
}
844434
func MarshalPKIXPublicKey(pub interface{}) ([]byte, error) {
	var publicKeyBytes []byte
	var publicKeyAlgorithm pkix.AlgorithmIdentifier
	var err error

	if publicKeyBytes, publicKeyAlgorithm, err = marshalPublicKey(pub); err != nil {
		return nil, err
	}

	pkix := pkixPublicKey{
		Algo: publicKeyAlgorithm,
		BitString: asn1.BitString{
			Bytes:     publicKeyBytes,
			BitLength: 8 * len(publicKeyBytes),
		},
	}

	ret, _ := asn1.Marshal(pkix)
	return ret, nil
}
499879
func (rdb *RethinkDBKeyStore) GetKey(keyID string) data.PublicKey {
	dbPrivateKey, _, err := rdb.getKey(keyID)
	if err != nil {
		return nil
	}

	return data.NewPublicKey(dbPrivateKey.Algorithm, dbPrivateKey.Public)
}
1266377
func handlePublicKeys(w http.ResponseWriter, r *http.Request) {
	raw, err := json.MarshalIndent(publicKeys, "", "  ")
	if err != nil {
		log.Printf("failed to marshal data: %v", err)
		http.Error(w, "Internal server error", http.StatusInternalServerError)
		return
	}
	w.Header().Set("Content-Type", "application/json")
	w.Header().Set("Content-Length", strconv.Itoa(len(raw)))
	w.Write(raw)
}
199325
func GetMasterPublicKey() (crypto.PublicKey, error) {
	// check the master keys first
	if key, err := getMasterPublicKeyAsMaster(); err == nil {
		return key, err
	}

	dKeyCond.RLock()
	defer dKeyCond.RUnlock()
	if delegateKeys.masterPublic == nil {
		return nil, ErrNoPublicKey
	}
	return delegateKeys.masterPublic, nil
}
932881
func determinePublicKey(sig, pubkeyX []byte) ([]byte, error) {
	for v := 0; v < 2; v++ {
		sig[64] = byte(v)
		pubkey, err := crypto.Ecrecover(DerivationSignatureHash[:], sig)
		if err == nil {
			if bytes.Equal(pubkey, pubkeyX) {
				return pubkey, nil
			}
		} else if v == 1 || err != secp256k1.ErrRecoverFailed {
			return nil, err
		}
	}
	return nil, ErrPubkeyMismatch
}
876325
func (w *WIF) SerializePubKey() []byte {
	pk := (*btcec.PublicKey)(&w.PrivKey.PublicKey)
	if w.CompressPubKey {
		return pk.SerializeCompressed()
	}
	return pk.SerializeUncompressed()
}
1189288
func ParsePublicKey(in []byte) (out PublicKey, err error) {
	return gossh.ParsePublicKey(in)
}
735604
func ParseArmoredPublicKey(r io.Reader) (shortKeyId, armoredKey string, err error) {
	var buf bytes.Buffer
	pk, err := openArmoredPublicKeyFile(ioutil.NopCloser(io.TeeReader(r, &buf)))
	if err != nil {
		return
	}
	return publicKeyID(pk), buf.String(), nil
}
143657
func (trust *NotarySigner) GetKey(keyid string) data.PublicKey {
	pubKey, _, err := trust.getKeyInfo(keyid)
	if err != nil {
		return nil
	}
	return pubKey
}