ecies.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:py-evm 作者: ethereum 项目源码 文件源码
def kdf(key_material):
    """NIST SP 800-56a Concatenation Key Derivation Function (see section 5.8.1).

    Pretty much copied from geth's implementation:
    https://github.com/ethereum/go-ethereum/blob/673007d7aed1d2678ea3277eceb7b55dc29cf092/crypto/ecies/ecies.go#L167
    """
    key = b""
    hash_blocksize = hashes.SHA256().block_size
    reps = ((KEY_LEN + 7) * 8) / (hash_blocksize * 8)
    counter = 0
    while counter <= reps:
        counter += 1
        ctx = sha256()
        ctx.update(struct.pack('>I', counter))
        ctx.update(key_material)
        key += ctx.digest()
    return key[:KEY_LEN]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号