コード例 #1
0
 def create_cert(master_sk, signer_pk, cert_start, cert_stop):
     assert int(time.time()) < cert_start < cert_stop, 'wrong time setting of cert.'
     master_ecc = Encryption()
     master_ecc.sk = master_sk
     cert_raw = bjson.dumps((master_ecc.pk, signer_pk, cert_start, cert_stop), compress=False)
     cert = {
         'master': master_ecc.pk,
         'start': cert_start,
         'stop': cert_stop,
         'sign': master_ecc.sign(cert_raw, encode='hex')}
     return cert
コード例 #2
0
 def remove_file_by_master(self, signer_sk, cert, file_hash):
     file_hash = file_hash.lower()
     file_path = os.path.join(V.DATA_PATH, 'file.' + file_hash + '.dat')
     uuid = random.randint(10, 99999999)
     signer_ecc = Encryption()
     signer_ecc.sk = signer_sk
     try:
         os.remove(file_path)
         sign_raw = bjson.dumps((file_hash, uuid), compress=False)
         send_data = {
             'signer': signer_ecc.pk,
             'sign': signer_ecc.sign(msg=sign_raw, encode='hex'),
             'cert': cert}
         dummy, result = self.send_command(ClientCmd.FILE_DELETE, send_data, uuid=uuid)
         logging.debug("File delete success.")
     except:
         logging.debug("Failed delete file.")
         pass
コード例 #3
0
ファイル: allinone.py プロジェクト: massanchik/nem-ed25519
from nem_ed25519.base import Encryption

ecc = Encryption()

print("sk", ecc.secret_key())
print("pk", ecc.public_key())
print("ck", ecc.get_address())

msg = b'hello world nice day.'
signature = ecc.sign(msg, encode='base64')
print("sign", signature)
ecc.verify(msg, signature)

enc = ecc.encrypt(ecc.pk, msg, encode='base64')
print(enc)
print(ecc.decrypt(ecc.pk, enc))
コード例 #4
0
ファイル: allinone.py プロジェクト: namuyan/nem-ed25519
from nem_ed25519.base import Encryption
import base64

ecc = Encryption()

print("sk", ecc.secret_key())
print("pk", ecc.public_key())
print("ck", ecc.get_address())

msg = b'hello world nice day.'
signature = ecc.sign(msg, encode=base64)
print("sign", signature)
ecc.verify(msg, signature)

enc = ecc.encrypt(ecc.pk, msg, encode=base64)
print(enc)
print(ecc.decrypt(ecc.pk, enc))