import struct

import cbor2


def get_credential_id(attestation_object_cbor: bytes) -> bytes:
	attestation_object = cbor2.loads(attestation_object_cbor)
	auth_data = attestation_object["authData"]
	rp_id_hash, flags, sign_count, aaguid, credential_id_length = struct.unpack('! 32s B L 16s H', auth_data[:55])
	credential_id = auth_data[55:(55 + credential_id_length)]
	return credential_id
