问题描述
我正在阅读一篇名为
如果我的理解是正确的,他们使用一个名为 G 的伪随机生成器,它将一个由零和长度为 k 的对象作为输入,并生成一个由零和长度为 m 的对象组成的对象.
我的问题是:如何在 Python 中实现它?
如何实现一个伪随机生成器,它采用大小为 k 的种子并产生大小为 m 的输出?
你可以随时生成 am
个字符串 :-) ...
开玩笑的一个简单的解决方案是将输入数字(将在 0
和 2**k-1
之间)提供给 random.seed
然后从 random.randrange(1< 得到结果.
I'm reading a paper called More Efficient Oblivious Transfer Extensions withSecurity for Malicious Adversaries by Gilad Asharov, Yehuda Lindell, Thomas Schneider and Michael Zohner.
On page 8 they present their protocol. When presenting the tools being used, they write:
If my understanding is correct they use a pseudorandom generator called G which takes as an input an object consisting of zeros and ones of length k and produce an object of zeros and ones of length m.
My questions is: How can I implement this in Python?
How can I implement a pseudorandom generator which takes a seed of size k and produces an output of size m?
解决方案
You could just always generate a string of
m
ones :-) ...
Kidding apart a simple solution is to feed the input number (that will be between
0
and 2**k-1
) to random.seed
and then get the result from random.randrange(1<<m)
.
这篇关于在 Python 中实现伪随机生成器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!