def register(device, data, facet):
if isinstance(data, string_types):<EOL><INDENT>data = json.loads(data)<EOL><DEDENT>if data['<STR_LIT:version>'] != VERSION:<EOL><INDENT>raise ValueError('<STR_LIT>' % data['<STR_LIT:version>'])<EOL><DEDENT>app_id = data.get('<STR_LIT>', facet)<EOL>verify_facet(app_id, facet)<EOL>app_param = sha256(app_id.encode('<STR_LIT:utf8>')).digest()<EOL>client_data = {<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': data['<STR_LIT>'],<EOL>'<STR_LIT>': facet<EOL>}<EOL>client_data = json.dumps(client_data)<EOL>client_param = sha256(client_data.encode('<STR_LIT:utf8>')).digest()<EOL>request = client_param + app_param<EOL>p1 = <NUM_LIT><EOL>p2 = <NUM_LIT:0><EOL>response = device.send_apdu(INS_ENROLL, p1, p2, request)<EOL>return {<EOL>'<STR_LIT>': websafe_encode(response),<EOL>'<STR_LIT>': websafe_encode(client_data)<EOL>}<EOL>
Register a U2F device

data = {
    "version": "U2F_V2",
    "challenge": string, //b64 encoded challenge
    "appId": string, //app_id
}