-
Notifications
You must be signed in to change notification settings - Fork 15
feat: add true randomness #119
base: main
Are you sure you want to change the base?
Conversation
Previously |
We decided to display a upper bound instead of a number of bits in the Solidity API, so nothing change from a developer perspective. cc @mortendahl |
randBigInt.SetUint64(randUint) | ||
randCt.TrivialEncrypt(*randBigInt, resultType) | ||
insertCiphertextToMemory(environment, randCt) | ||
randCt, err := tfhe.GenerateObliviousPseudoRandom(resultType, *(*uint64)(unsafe.Pointer(&seed.Bytes()[0])), numberOfBits) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIU, the seed can just be a counter. Right now, we hash a fixed global seed and the caller address, leading to the same seed every time. We should double check with tfhe-rs and, if that's the case, change the seed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK you mean we could use directly globalRngSeed
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is globalRngSeed
incremented after each use?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe nextRngNonce
is a better choice. I don't see where we use it right now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am getting it right, that globalRngSeed
/nextRngNonce
is local state? For the coprocessor we might want to avoid this, and instead use a counter from Solidity. This would make the coprocessor computation stateless and reproducible. To generate the symbolic values for random encryptions, we need a Solidity counter (plaintext integer) anyways. This counter could be used here as well.
Simple PR to review.
upperBound
to a number of bits.