예제 #1
0
    def get_address(self, pubkey):
        """ compute the nem-py address from the public one """
        s = sha3_256()
        s.update(unhexlify(pubkey))
        sha3_pubkey = s.digest()

        h = hashlib.new('ripemd160')
        h.update(sha3_pubkey)
        ripe = h.digest()

        if self.network == 'testnet':
            version = b"\x98" + ripe
        else:
            version = b"\x68" + ripe

        s2 = sha3_256()
        s2.update(version)
        checksum = s2.digest()[0:4]
        return base64.b32encode(version + checksum)
예제 #2
0
def decrypt(password, encrypted_seed, iv, seed_hash):
    key = kdf(password)
    cipher = AES.new(key, AES.MODE_CBC, iv)
    seed = unpad(cipher.decrypt(encrypted_seed))
    if seed is None:
        return None
    bkp = gen_bkp(seed)
    if sha3_256(seed + b'\x02').hexdigest() == seed_hash:
        return seed
    else:
        return None
예제 #3
0
def sha3(x):
    return python_sha3.sha3_256(x).digest()
예제 #4
0
def keccak_256(s):
    #return Keccak().Keccak((len(s)*4, s), 1088, 512, 0x01, 32*8, False).lower()
    k = python_sha3.sha3_256()
    k.update(s)
    return k.hexdigest()
예제 #5
0
def sha3(x):
    return python_sha3.sha3_256(x).digest()
예제 #6
0
파일: pyethtool.py 프로젝트: tagawa/website
def sha3(x): return python_sha3.sha3_256(x).digest()

def pbkdf2(x): return PBKDF2._pbkdf2(x,'',1000)[:16]
예제 #7
0
 def to_hash_sha3_256(m):
     return sha3_256(m).digest()
예제 #8
0
def gen_bkp(seed):
    return sha3_256(b'' + seed + b'\0x02').hexdigest()