Parse a bip32 public key from a text string ("xpub" type).
        Return a :class:`BIP32 <pycoin.key.BIP32Node.BIP32Node>` or None.
483202
def bip32_pub(self, s):
        
        data = self.parse_b58_hashed(s)
        if data is None or not data.startswith(self._bip32_pub_prefix):
            return None
        return self._network.keys.bip32_deserialize(data)
848754
def get(value: str) -> 'Protocol':
        

        for pktype in PublicKeyType:
            if value in (pktype.ver_type, pktype.authn_type):
                return pktype
        return None
331441
def decode_jwt(input_text, secure_key):
    
    if input_text is None:
        return None

    encoded = (input_text.split(":")[1]).encode('utf-8')
    decoded = jwt.decode(encoded, secure_key)
    return decoded['sub']
392294
function certBlob() {
	var self = {
		cbCert : new type.UInt32Le(function() {
			return self.abCert.size();
		}),
        abCert : new type.BinaryString(null, { readLength : new type.CallableValue(function() {
        	return self.cbCert.value;
        }) })
	};
	
	return new type.Component(self);
}
1041967
def ed25519_public_key_from_string(string):
    
    try:
        return Ed25519PublicKey.from_public_bytes(
            base64.b64decode(string)
        )
    except (UnsupportedAlgorithm, Base64Error) as exc:
        raise ScriptWorkerEd25519Error("Can't create Ed25519PublicKey: {}!".format(str(exc)))
159521
def account_xdr_object(self):
        
        return Xdr.types.PublicKey(Xdr.const.KEY_TYPE_ED25519,
                                   self.verifying_key.to_bytes())
805765
def read_serialized_rsa_pub_key(serialized):
        
        n = None
        e = None
        rsa = from_hex(serialized)

        pos = 0
        ln = len(rsa)
        while pos < ln:
            tag = bytes_to_byte(rsa, pos)
            pos += 1
            length = bytes_to_short(rsa, pos)
            pos += 2

            if tag == 0x81:
                e = bytes_to_long(rsa[pos:pos+length])
            elif tag == 0x82:
                n = bytes_to_long(rsa[pos:pos+length])

            pos += length

        if e is None or n is None:
            logger.warning("Could not process import key")
            raise ValueError('Public key deserialization failed')

        return n, e
1134366
def create_public_key_from_json(values):
        """"""
        # currently we only support RSA public keys
        _id = values.get('id')
        if not _id:
            # Make it more forgiving for now.
            _id = ''
            # raise ValueError('publicKey definition is missing the "id" value.')

        if values.get('type') == PUBLIC_KEY_TYPE_RSA:
            public_key = PublicKeyRSA(_id, owner=values.get('owner'))
        else:
            public_key = PublicKeyBase(_id, owner=values.get('owner'), type='EthereumECDSAKey')

        public_key.set_key_value(values)
        return public_key
903673
def _parse_ocsp_response_from_openssl_text(
            cls,
            response_text: str,
            response_status: OcspResponseStatusEnum
    ) -> Dict[str, Any]:
        
        response_dict = {
            'responseStatus': cls._get_value_from_text_output_no_p('OCSP Response Status:', response_text),
            'version': cls._get_value_from_text_output_no_p('Version:', response_text),
            'responseType': cls._get_value_from_text_output('Response Type:', response_text),
            'responderID': cls._get_value_from_text_output('Responder Id:', response_text),
            'producedAt': cls._get_value_from_text_output('Produced At:', response_text),
            }  # type: Dict[str, Any]

        if response_status != OcspResponseStatusEnum.SUCCESSFUL:
            return response_dict

        # A successful OCSP response will contain more data - let's parse it
        # TODO(ad): This will not work correctly if there are multiple responses as it assumes just one
        response_dict['responses'] = [
            {
                'certID': {
                    'hashAlgorithm': cls._get_value_from_text_output('Hash Algorithm:', response_text),
                    'issuerNameHash': cls._get_value_from_text_output('Issuer Name Hash:', response_text),
                    'issuerKeyHash': cls._get_value_from_text_output('Issuer Key Hash:', response_text),
                    'serialNumber': cls._get_value_from_text_output('Serial Number:', response_text)
                },
                'certStatus': cls._get_value_from_text_output('Cert Status:', response_text),
                'thisUpdate': cls._get_value_from_text_output('This Update:', response_text),
                'nextUpdate': cls._get_value_from_text_output('Next Update:', response_text),
            }
        ]
        if cls._get_scts_from_text_output(response_text):
            # SCT extension present
            response_dict['responses'][0]['singleExtensions'] = {
                'ctCertificateScts': cls._get_scts_from_text_output(response_text)
            }
        return response_dict
1002265
def parse(self) -> typing.Union[list, dict, None]:
        """"""
        root_node_offset = self._read_u32(12)
        if root_node_offset == 0:
            return None

        node_type = self._data[root_node_offset]
        if not _is_container_type(node_type):
            raise ValueError("Invalid root node: expected array or dict, got type 0x%x" % node_type)
        return self._parse_node(node_type, 12)
354876
def electrum_pub(self, s):
        
        blob = self._electrum_to_blob(s)
        if blob and len(blob) == 64:
            return self._network.keys.electrum_public(master_public_key=blob)
792547
def parse_private_key(data, password):
    
    # PEM
    if is_pem(data):
        if b'ENCRYPTED' in data:
            if password is None:
                raise TypeError('No password provided for encrypted key.')
        try:
            return serialization.load_pem_private_key(
                data, password, backend=default_backend())
        except ValueError:
            # Cryptography raises ValueError if decryption fails.
            raise
        except Exception:
            pass

    # PKCS12
    if is_pkcs12(data):
        try:
            p12 = crypto.load_pkcs12(data, password)
            data = crypto.dump_privatekey(
                crypto.FILETYPE_PEM, p12.get_privatekey())
            return serialization.load_pem_private_key(
                data, password=None, backend=default_backend())
        except crypto.Error as e:
            raise ValueError(e)

    # DER
    try:
        return serialization.load_der_private_key(
            data, password, backend=default_backend())
    except Exception:
        pass

    # All parsing failed
    raise ValueError('Could not parse private key.')
272781
def parse_message(
        self, body, timestamp=None, nonce=None, msg_signature=None
    ):
        
        message_dict = parse_xml(body)
        if "Encrypt" in message_dict:
            xml = self.crypto.decrypt_message(
                timestamp=timestamp,
                nonce=nonce,
                msg_signature=msg_signature,
                encrypt_msg=message_dict["Encrypt"]
            )
            message_dict = parse_xml(xml)
        return process_message(message_dict)
717646
def decode_pubkey_hex(pubkey_hex):
    
    if not isinstance(pubkey_hex, (str, unicode)):
        raise ValueError("public key is not a string")

    pubk = keylib.key_formatting.decompress(str(pubkey_hex))
    assert len(pubk) == 130

    pubk_raw = pubk[2:]
    pubk_i = (int(pubk_raw[:64], 16), int(pubk_raw[64:], 16))
    return pubk_i
1323537
def ecdsa_public_key(pubkey_str, compressed=None):
    
    if compressed == True:
        pubkey_str = keylib.key_formatting.compress(pubkey_str)
    elif compressed == False:
        pubkey_str = keylib.key_formatting.decompress(pubkey_str)

    return _ECPublicKey(pubkey_str)
859333
def bip32_seed(self, s):
        
        pair = parse_colon_prefix(s)
        if pair is None or pair[0] not in "HP":
            return None
        if pair[0] == "H":
            try:
                master_secret = h2b(pair[1])
            except ValueError:
                return None
        else:
            master_secret = pair[1].encode("utf8")
        return self._network.keys.bip32_seed(master_secret)
1033780
def to_point
      p = pubkey
      p ||= generate_pubkey(priv_key, compressed: compressed)
      ECDSA::Format::PointOctetString.decode(p.htb, Bitcoin::Secp256k1::GROUP)
    end