Skip to content

Commit

Permalink
feat(DataIntegrityProof): convert proof format to data integrity proof
Browse files Browse the repository at this point in the history
  • Loading branch information
lemoustachiste committed Feb 13, 2024
1 parent 889440b commit 5f9215e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
7 changes: 5 additions & 2 deletions cert_issuer/proof_suites/merkle_proof_2019.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
from datetime import datetime

MERKLE_PROOF_2019_TYPE = 'MerkleProof2019'
DATA_INTEGRITY_PROOF_TYPE = 'DataIntegrityProof'
MERKLE_PROOF_2019_TYPE = 'merkle-proof-2019'
class MerkleProof2019Suite:
type = ''
cryptosuite = ''
verificationMethod = ''
created = ''
proofPurpose = ''
previousProof = ''
proofValue = ''

def __init__(self, proof_value, verificationMethod):
self.type = MERKLE_PROOF_2019_TYPE
self.type = DATA_INTEGRITY_PROOF_TYPE
self.cryptosuite = MERKLE_PROOF_2019_TYPE
self.proofPurpose = 'assertionMethod'
self.created = self.get_creation_time()
self.proofValue = proof_value.decode('utf-8')
Expand Down
10 changes: 5 additions & 5 deletions tests/test_certificate_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
from mock import ANY

class TestCertificateHandler(unittest.TestCase):
def _proof_helper(self, chain):
def _proof_helper(self):
proof = {
'type': 'MerkleProof2019',
'type': 'DataIntegrityProof',
'cryptosuite': 'merkle-proof-2019',
'created': ANY,
'proofValue': ANY,
'proofPurpose': 'assertionMethod',
Expand Down Expand Up @@ -93,7 +94,7 @@ def test_batch_web_handler_finish_batch(self):
result = certificate_batch_handler.prepare_batch()

chain = Chain.bitcoin_mainnet
proof = self._proof_helper(chain)
proof = self._proof_helper()

with patch.object(DummyCertificateHandler, 'add_proof', return_value= {"cert": "cert"} ) as mock_method:
result = certificate_batch_handler.finish_batch(
Expand All @@ -109,7 +110,7 @@ def test_batch_handler_finish_batch(self):
result = certificate_batch_handler.prepare_batch()

chain = Chain.bitcoin_mainnet
proof = self._proof_helper(chain)
proof = self._proof_helper()

config = mock.Mock()
config.issuing_address = "http://example.com"
Expand Down Expand Up @@ -191,7 +192,6 @@ def xtest_add_proof(self, mock_open):
def test_web_add_proof(self):
handler = CertificateWebV3Handler(None)
proof = {'a': 'merkel'}
chain = mock.Mock()
certificate_json = {
'@context': [
'https://www.w3.org/2018/credentials/v1'
Expand Down
6 changes: 4 additions & 2 deletions tests/test_merkle_tree_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ def do_test_signature(self, chain, display_chain, type):
proof_value = mp2019.encode(p1_json_proof)

p1_expected = {
"type": "MerkleProof2019",
"type": "DataIntegrityProof",
"cryptosuite": "merkle-proof-2019",
"created": p1['created'],
"proofValue": proof_value.decode('utf8'),
"proofPurpose": "assertionMethod",
Expand All @@ -82,7 +83,8 @@ def do_test_signature(self, chain, display_chain, type):
proof_value = mp2019.encode(p3_json_proof)

p3_expected = {
"type": "MerkleProof2019",
"type": "DataIntegrityProof",
"cryptosuite": "merkle-proof-2019",
"created": p3['created'],
"proofValue": proof_value.decode('utf8'),
"proofPurpose": "assertionMethod",
Expand Down

0 comments on commit 5f9215e

Please sign in to comment.