Skip to content
This repository was archived by the owner on Jul 15, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions app/codes/contractmanager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os
import codecs
import ecdsa
from Crypto.Hash import keccak


def create_contract_address():
private_key_bytes = os.urandom(32)
key = ecdsa.SigningKey.from_string(private_key_bytes, curve=ecdsa.SECP256k1).verifying_key
key_bytes = key.to_string()
public_key = codecs.encode(key_bytes, 'hex')
public_key_bytes = codecs.decode(public_key, 'hex')
hash = keccak.new(digest_bits=256)
hash.update(public_key_bytes)
keccak_digest = hash.hexdigest()
address = 'ct' + keccak_digest[-40:] # this overwrites the None value in the init call, whenever on-chain contract is setup
return address
Empty file added app/codes/contracts/__init__.py
Empty file.
Loading