def test_serialize_signup_info(self): signup_info = \ EnclaveSignupInfo( poet_public_key='My Fake Key', proof_data='I am Victoria Antoinette Scharleau, and I ' 'approve of this message.', anti_sybil_id='Sally Field', sealed_signup_data="Signed, Sealed, Delivered, I'm Yours") self.assertIsNotNone(signup_info.serialize())
def create_signup_info(cls, originator_public_key_hash, most_recent_wait_certificate_id): with cls._lock: # First we need to create a public/private key pair for the PoET # enclave to use. cls._poet_private_key = pybitcointools.random_key() cls._poet_public_key = \ pybitcointools.privtopub(cls._poet_private_key) cls._active_wait_timer = None # We are going to fake out the sealing the signup data. signup_data = { 'poet_public_key': pybitcointools.encode_pubkey(cls._poet_public_key, 'hex'), 'poet_private_key': pybitcointools.encode_privkey(cls._poet_private_key, 'hex') } sealed_signup_data = \ pybitcointools.base64.b64encode(dict2json(signup_data)) # Create a fake report report_data = { 'originator_public_key_hash': originator_public_key_hash.upper(), 'poet_public_key': pybitcointools.encode_pubkey(cls._poet_public_key, 'hex').upper() } report = { 'report_data': pybitcointools.sha256(dict2json(report_data)) } # Fake our "proof" data. verification_report = { 'enclave_quote': pybitcointools.base64.b64encode(dict2json(report)), 'pse_manifest_hash': pybitcointools.base64.b64encode( pybitcointools.sha256('manifest destiny')), 'nonce': most_recent_wait_certificate_id } proof_data = { 'verification_report': dict2json(verification_report), 'signature': pybitcointools.ecdsa_sign(dict2json(verification_report), cls._report_private_key) } proof_data_dict = dict2json(proof_data) return \ EnclaveSignupInfo( poet_public_key=signup_data['poet_public_key'], proof_data=proof_data_dict, anti_sybil_id=originator_public_key_hash, sealed_signup_data=sealed_signup_data)
def test_deserialized_signup_info(self): signup_info = \ EnclaveSignupInfo( poet_public_key='My Fake Key', proof_data='I am Victoria Antoinette Scharleau, and I ' 'approve of this message.', anti_sybil_id='Sally Field', sealed_signup_data="Signed, Sealed, Delivered, I'm Yours") serialized = signup_info.serialize() copy_signup_info = \ EnclaveSignupInfo.signup_info_from_serialized(serialized) self.assertEqual( signup_info.poet_public_key, copy_signup_info.poet_public_key) self.assertEqual(signup_info.proof_data, copy_signup_info.proof_data) self.assertEqual( signup_info.anti_sybil_id, copy_signup_info.anti_sybil_id) self.assertIsNone(copy_signup_info.sealed_signup_data) self.assertEqual(serialized, copy_signup_info.serialize())
def test_create_signup_info(self): signup_info = \ EnclaveSignupInfo( poet_public_key='My Fake Key', proof_data='I am Victoria Antoinette Scharleau, and I ' 'approve of this message.', anti_sybil_id='Sally Field', sealed_signup_data="Signed, Sealed, Delivered, I'm Yours") self.assertEqual(signup_info.poet_public_key, 'My Fake Key') self.assertEqual( signup_info.proof_data, 'I am Victoria Antoinette Scharleau, and I approve of this ' 'message.') self.assertEqual(signup_info.anti_sybil_id, 'Sally Field') self.assertEqual( signup_info.sealed_signup_data, "Signed, Sealed, Delivered, I'm Yours")
def create_signup_info(cls, originator_public_key_hash, most_recent_wait_certificate_id): with cls._lock: # First we need to create a public/private key pair for the PoET # enclave to use. cls._poet_private_key = signing.generate_privkey() cls._poet_public_key = \ signing.generate_pubkey(cls._poet_private_key) cls._active_wait_timer = None # We are going to fake out the sealing the signup data. signup_data = { 'poet_public_key': signing.encode_pubkey(cls._poet_public_key, 'hex'), 'poet_private_key': signing.encode_privkey(cls._poet_private_key, 'hex') } sealed_signup_data = \ base64.b64encode(dict2json(signup_data)) # Create a fake report report_data = '{0}{1}'.format( originator_public_key_hash.upper(), signing.encode_pubkey(cls._poet_public_key, 'hex').upper()) quote = { 'report_body': hashlib.sha256(dict2json(report_data)).hexdigest() } # Fake our "proof" data. verification_report = { 'id': base64.b64encode( hashlib.sha256( datetime.datetime.now().isoformat()).hexdigest()), 'isvEnclaveQuoteStatus': 'OK', 'isvEnclaveQuoteBody': base64.b64encode(dict2json(quote)), 'pseManifestStatus': 'OK', 'pseManifestHash': base64.b64encode( hashlib.sha256(b'Do you believe in ' 'manifest destiny?').hexdigest()), 'nonce': most_recent_wait_certificate_id } proof_data_dict = { 'verification_report': dict2json(verification_report), 'signature': signing.sign(dict2json(verification_report), cls._report_private_key) } proof_data = dict2json(proof_data_dict) return \ EnclaveSignupInfo( poet_public_key=signup_data['poet_public_key'], proof_data=proof_data, anti_sybil_id=originator_public_key_hash, sealed_signup_data=sealed_signup_data)
def deserialize_signup_info(cls, serialized_signup_info): return \ EnclaveSignupInfo.signup_info_from_serialized( serialized_signup_info=serialized_signup_info)
def deserialize_signup_info(cls, serialized_signup_info): return \ EnclaveSignupInfo.signup_info_from_serialized( serialized_signup_info=serialized_signup_info)