BLISS.py 文件源码

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

项目:Lattice-Based-Signatures 作者: krishnacharya 项目源码 文件源码
def hash_iterative(s, n, k):
    '''
    Uses Hashing technique mentioned in BLISS pg 19
    i/p: string s to be hashed to binary string of length n and weight k
    '''  
    i = 0 # seed which increases till we get Bk^n
    while(True):
        Bk = [0] * n
        I_val = int(hashlib.sha512(s + str(i)).hexdigest(), 16)
        count = 0
        while(I_val > 0):
            pos = I_val % n
            I_val /= n
            if(Bk[pos] == 0):
                Bk[pos] = 1
                count += 1
            if(count == k):
                return np.array(Bk)
        i += 1
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号