Beispiel #1
0
 def test_fail_to_sign_with_no_claim_address(self):
     cert = ClaimDict.generate_certificate(secp256k1_private_key,
                                           curve=SECP256k1)
     self.assertDictEqual(cert.claim_dict, secp256k1_cert)
     self.assertRaises(Exception,
                       ClaimDict.load_dict(example_010).sign,
                       secp256k1_private_key,
                       None,
                       claim_id_1,
                       curve=SECP256k1)
Beispiel #2
0
 def test_fail_to_validate_fake_ecdsa_signature(self):
     signed = ClaimDict.load_dict(example_010).sign(secp256k1_private_key,
                                                    claim_address_1,
                                                    claim_id_1,
                                                    curve=SECP256k1)
     signed_copy = ClaimDict.load_protobuf(signed.protobuf)
     fake_key = get_signer(SECP256k1).generate().private_key.to_pem()
     fake_cert = ClaimDict.generate_certificate(fake_key, curve=SECP256k1)
     self.assertRaises(ecdsa.keys.BadSignatureError,
                       signed_copy.validate_signature, claim_address_2,
                       fake_cert)
Beispiel #3
0
 def test_validate_ecdsa_signature(self):
     cert = ClaimDict.generate_certificate(nist384p_private_key,
                                           curve=NIST384p)
     signed = ClaimDict.load_dict(example_010).sign(nist384p_private_key,
                                                    claim_address_2,
                                                    claim_id_1,
                                                    curve=NIST384p)
     self.assertDictEqual(signed.claim_dict, claim_010_signed_nist384p)
     signed_copy = ClaimDict.load_protobuf(signed.protobuf)
     self.assertEquals(
         signed_copy.validate_signature(claim_address_2, cert), True)
Beispiel #4
0
 def test_fail_to_validate_with_no_claim_address(self):
     cert = ClaimDict.generate_certificate(secp256k1_private_key,
                                           curve=SECP256k1)
     self.assertDictEqual(cert.claim_dict, secp256k1_cert)
     signed = ClaimDict.load_dict(example_010).sign(secp256k1_private_key,
                                                    claim_address_2,
                                                    claim_id_1,
                                                    curve=SECP256k1)
     self.assertDictEqual(signed.claim_dict, claim_010_signed_secp256k1)
     signed_copy = ClaimDict.load_protobuf(signed.protobuf)
     self.assertRaises(Exception, signed_copy.validate_signature, None,
                       cert)
Beispiel #5
0
 def test_fail_to_validate_ecdsa_sig_for_altered_claim(self):
     cert = ClaimDict.generate_certificate(secp256k1_private_key,
                                           curve=SECP256k1)
     altered = ClaimDict.load_dict(example_010).sign(secp256k1_private_key,
                                                     claim_address_1,
                                                     claim_id_1,
                                                     curve=SECP256k1)
     sd_hash = altered['stream']['source']['source']
     altered['stream']['source']['source'] = sd_hash[::-1]
     altered_copy = ClaimDict.load_dict(altered.claim_dict)
     self.assertRaises(ecdsa.keys.BadSignatureError,
                       altered_copy.validate_signature, claim_address_1,
                       cert)
Beispiel #6
0
 def test_make_ecdsa_cert(self):
     cert = ClaimDict.generate_certificate(secp256k1_private_key,
                                           curve=SECP256k1)
     self.assertEquals(cert.is_certificate, True)
     self.assertDictEqual(cert.claim_dict, secp256k1_cert)
Beispiel #7
0
 def test_make_ecdsa_cert(self):
     cert = ClaimDict.generate_certificate(nist384p_private_key,
                                           curve=NIST384p)
     self.assertEquals(cert.is_certificate, True)
     self.assertDictEqual(cert.claim_dict, nist384p_cert)
Beispiel #8
0
}

cert_claim_id = "63f2da17b0d90042c559cc73b6b17f853945c43e"
stream_claim_address = "bDtL6qriyimxz71DSYjojTBsm6cpM1bqmj"
stream_claim_address_2 = "bUG7VaMzLEqqyZQAyg9srxQzvf1wwnJ48w"

claim_010_unsigned = migrate.migrate(unmigrated_003)

# NIST256p test data
nist256p_private_key = get_signer(NIST256p).generate().private_key.to_pem()
claim_010_signed_nist256p = claim_010_unsigned.sign(nist256p_private_key,
                                                    stream_claim_address,
                                                    cert_claim_id,
                                                    curve=NIST256p)

nist256p_cert = ClaimDict.generate_certificate(nist256p_private_key,
                                               curve=NIST256p)

# NIST384p test data
nist384p_private_key = get_signer(NIST384p).generate().private_key.to_pem()
claim_010_signed_nist384p = claim_010_unsigned.sign(nist384p_private_key,
                                                    stream_claim_address,
                                                    cert_claim_id,
                                                    curve=NIST384p)
nist384p_cert = ClaimDict.generate_certificate(nist384p_private_key,
                                               curve=NIST384p)

# SECP256k1 test data
secp256k1_private_key = get_signer(SECP256k1).generate().private_key.to_pem()
claim_010_signed_secp256k1 = claim_010_unsigned.sign(secp256k1_private_key,
                                                     stream_claim_address,
                                                     cert_claim_id,