Skip to content
Snippets Groups Projects

Bloxberg proof of concept

Merged Daniel Hornung requested to merge f-bloxberg-poc into dev

Summary

This MR allow users to certify a single entity with the Bloxberg blockchain.

Tests are still missing.

Focus

  • Does the API look usable for other programmers?

Test Environment

  • Start your own CaosDB server and make sure that your pycaosdb.ini will connect to it.
  • Install this project with pip3 install .
  • Start Python shell and run:
import caosadvancedtools.bloxberg.bloxberg as blx
blx.demo_run()

Check List for the Author

  • All automated tests pass
  • Reference related Issue: #34 (closed)
  • Up-to-date CHANGELOG.md
  • Annotations in code (Gitlab comments)
    • Intent of new code
    • Problems with old code
    • Why this implementation?

Check List for the Reviewer

  • I understand the intent of this MR
  • All automated tests pass
  • Up-to-date CHANGELOG.md
  • The test environment setup works and the intended behavior is reproducible in the test environment
  • In-code documentation and comments are up-to-date.
  • Check: Are there spezifications? Are they satisfied?

For further good practices have a look at our review guidelines.

Edited by Alexander Schlemmer

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
118 def verify(self, certificate):
119 """Attempt to verify the certificate.
120
121 A certificate passes verification if the Bloxberg instance says it is good. Typical use cases may
122 also include the `validate` step to make sure that the certificate's original data exists and
123 contains what it claimed to contain when the certificate was created.
124
125 This method does nothing if the verification passes, else it raises an exception.
126
127 Parameters
128 ----------
129 certificate : caosdb.Record
130 The BloxbergCertificate Record which shall be verified.
131
132 """
133 raise NotImplementedError("Bloxberg first needs to implement a verification API method.")
  • 79 The entity to be certified
    80
    81 Returns
    82 -------
    83 out : caosdb.Record
    84 A BloxbergCertificate Record with all the necessary Properties.
    85 """
    86 # Calculate hash
    87 pepper = str(secrets.randbits(1024))
    88 entity.retrieve()
    89 hasher = hashlib.sha256()
    90 hasher.update(pepper.encode(encoding="utf8"))
    91 hasher.update(str(entity).encode(encoding="utf8"))
    92 entity_hash = "0x" + hasher.hexdigest()
    93 print(entity_hash)
    94 pubkey = "0x9858eC18a269EE69ebfD7C38eb297996827DDa98" # TODO The key of the API server?
  • 72
    73 def certify(self, entity):
    74 """Attempt to certify the given `entity` and return a certificate Record.
    75
    76 Parameters
    77 ----------
    78 entity : caosdb.Entity
    79 The entity to be certified
    80
    81 Returns
    82 -------
    83 out : caosdb.Record
    84 A BloxbergCertificate Record with all the necessary Properties.
    85 """
    86 # Calculate hash
    87 pepper = str(secrets.randbits(1024))
  • 171 if isinstance(entity, int):
    172 entity = db.Entity(id=entity)
    173
    174 blx = Bloxberg()
    175 print("Obtaining certificate...")
    176 certificate = blx.certify(entity)
    177 print("Certificate was successfully obtained.")
    178 certificate.insert()
    179 print("Certificate was stored in CaosDB.")
    180
    181 if json_filename:
    182 with open(json_filename, "w") as json_file:
    183 json_file.write(certificate.get_property("certificateJSON").value)
    184
    185
    186 def demo_run():
  • 1 """Submodule for working with data models.
    2 """
  • Daniel Hornung marked the checklist item Annotations in code (Gitlab comments) as completed

    marked the checklist item Annotations in code (Gitlab comments) as completed

  • Daniel Hornung marked the checklist item All automated tests pass as completed

    marked the checklist item All automated tests pass as completed

  • Daniel Hornung added 1 commit

    added 1 commit

    • 13f15963 - STY: Exclude autogenerated code from autopep8.

    Compare with previous version

  • 107 107 stage: style
    108 108 image: $CI_REGISTRY_IMAGE
    109 109 script:
    110 - autopep8 -ar --diff --exit-code .
    110 - autopep8 -ar --diff --exit-code --exclude swagger_client .
  • Alexander Schlemmer marked the checklist item I understand the intent of this MR as completed

    marked the checklist item I understand the intent of this MR as completed

  • Alexander Schlemmer marked the checklist item All automated tests pass as completed

    marked the checklist item All automated tests pass as completed

  • Alexander Schlemmer marked the checklist item Does the API look usable for other programmers? as completed

    marked the checklist item Does the API look usable for other programmers? as completed

  • Alexander Schlemmer marked the checklist item Start your own CaosDB server and make sure that your pycaosdb.ini will connect to it. as completed

    marked the checklist item Start your own CaosDB server and make sure that your pycaosdb.ini will connect to it. as completed

  • Alexander Schlemmer marked the checklist item Install this project with pip3 install . as completed

    marked the checklist item Install this project with pip3 install . as completed

  • Alexander Schlemmer marked the checklist item Start Python shell and run: as completed

    marked the checklist item Start Python shell and run: as completed

  • Alexander Schlemmer marked the checklist item Check in your CaosDB instance that the RecordTypes and Records look OK: https://localhost:10443/Entity/?query=FIND%20Bloxb* as completed

    marked the checklist item Check in your CaosDB instance that the RecordTypes and Records look OK: https://localhost:10443/Entity/?query=FIND%20Bloxb* as completed

  • Alexander Schlemmer marked the checklist item Verify the certificate (stored at /tmp/cert.json or saved from the certificate Record) at https://certify.bloxberg.org/verify as completed

    marked the checklist item Verify the certificate (stored at /tmp/cert.json or saved from the certificate Record) at https://certify.bloxberg.org/verify as completed

  • Alexander Schlemmer marked the checklist item Up-to-date CHANGELOG.md as completed

    marked the checklist item Up-to-date CHANGELOG.md as completed

  • Alexander Schlemmer marked the checklist item The test environment setup works and the intended behavior is as completed

    marked the checklist item The test environment setup works and the intended behavior is as completed

  • Alexander Schlemmer marked the checklist item In-code documentation and comments are up-to-date. as completed

    marked the checklist item In-code documentation and comments are up-to-date. as completed

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading