forked from Tribler/tribler
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DoubleEntry: added numerical example experiment for Tribler#10.
- Loading branch information
1 parent
39be24a
commit 334e324
Showing
3 changed files
with
54 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from Tribler.dispersy.crypto import ECCrypto | ||
|
||
__author__ = 'norberhuis' | ||
""" | ||
File containing experiments | ||
""" | ||
|
||
|
||
class NumericalExample: | ||
|
||
def __init__(self, double_entry_community): | ||
self._community = double_entry_community | ||
|
||
def perform_experiment(self): | ||
self.save_key_to_file(self._community.get_key()) | ||
|
||
message = self._community.create_signature_request_message() | ||
|
||
self.save_payload_to_file(message.payload.timestamp) | ||
self.save_signature_to_file(message.payload.signature_requester) | ||
|
||
@staticmethod | ||
def save_key_to_file(ec): | ||
pem = ECCrypto().key_to_pem(ec) | ||
f = open("key.pem", 'w') | ||
f.write(pem) | ||
f.close() | ||
|
||
@staticmethod | ||
def save_payload_to_file(payload): | ||
f = open("payload", 'w') | ||
f.write(payload) | ||
f.close() | ||
|
||
@staticmethod | ||
def save_signature_to_file(signature): | ||
f = open("signature", 'w') | ||
f.write(signature) | ||
f.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters