-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Secure random number generator at runtime for N3 #2456
Comments
|
No, we can not use any value from the existing Block to generate secure random number. More like |
|
#2296 In the new design, consensus nodes do not publish the nonce until it is used. And even the nonce generated by the primary node is not directly used to prevent misbehavior of the primary node on the random number. |
I don't think you can assume that the primary is honest. |
I agree, that is why the number generated by the last primary is not directly used. |
The principle here is, other consensus node should not able to know the random number until they start the consensus. The primary node is the first to know the random number but it can not decide or change it. If you stil think it is not secure for primary node to join the process of generating random number, maybe we can also use Oracle nodes to create random number cooperatively by sending a random number transaction for each Block. |
Please allow me to put it more clear by renaming those terms: The random number generated by the last primary node is denoted as
|
It is impossible. Because the consensus messages are relaying on the p2p network. |
My mistake. But encryption algorithms could achieve this. |
My old solution is to use Shamir's Secret Sharing Scheme. |
Now I unserstand where the biggest problem is. Will try to redesign it with threshold signature.(might also try VDF) |
I think BLS will be a better solution. |
|
Why should we modificy the consensus? In my understanding, this can be completely separated from the consensus node and completed by Oracle. And in the actual process, we only need a key-distribution step and confirmation step in the initialization stage. |
When committee selects new Oracle nodes, all Oracle nodes enter the initialization stage, and then use ECC to encrypt the shared private key and send it to the chain, so that it can only be decrypted by the corresponding Oracle node. When most Oracle nodes receive the shared key, it can be considered that the initialization process is over, and then the process of generating random numbers can be considered as just a multi-sign process, which is not complicated. |
Oracle in N3 uses |
I probably understand now, what you imagine is to generate a random number in each block. It sounds like VDF is also a good idea. But I want to know what is the application scenario of this random number, because if it is only a user's request (such as gambling, etc.), it seems that the real-time requirements of the block are not too high. |
can you please share your concern onVRF with me? |
This will be very useful for my project |
Implementation-wise my concerns are:
But there also is a protocol-level problem, the code we have in neo-project/neo-modules#596 implements #2481 is different in that it allows Primary to choose some particular generated nonce which theoretically makes it weaker than neo-project/neo-modules#596, but practically malicious Primary needs to benefit from this in some way and that actually can be harder than with neo-project/neo-modules#596. Because it can only benefit from it by altering transaction list (moving/removing transactions of others and adding transactions of its own), but that directly affects block hash and thus random number generated. So there is a conflict between choosing a number and benefiting from it with this scheme and I think it's a good property. Both solutions have some problems, but #2481 is much much simpler and can be implemented with minimal modifications to the core parts, so it'd be nice to consider it again. |
@roman-khimov, thank you for your discussion and suggestions. I do agree with all the things you mentioned. But please allow me to make some clarifications. First of all, the threat that you described above is called the Secondly, Thirdly, we have principles to follow while designing a Then, random number is essential for NEO on Lastly, as you can see in the discussion above, I tried to add 'nonce' in the |
If used in a commit-reveal fashion where all transactions are settled first and only then some subsequent block announces the winner based on current random number then yes, it is secure with #2477/neo-project/neo-modules#596 if PrevHash comes from different Primary (and #2481 allows for Primary to cheat with some computational effort if it has made some bet already). Do we have cases where we need to have some random number in the same block with transaction using this number? I'm not sure, but looks like the only way to do that really is some BLS scheme mentioned above (but it's even more invasive in terms of dBFT modifications and it also is very slow, might be noticeable).
Well, it comes down to release management then and here my top priority for now would be rolling out N3. For this to happen we must not change it. There are lots of things that could be improved, but we can roll them out in incremental updates (and it'd give these features more time to mature). |
@roman-khimov i don't think it worth any effort to worry about an issue no other Blockchain projects can currently solve. MEV attack, I think you know that better than me, is a fundamental design issue of Blockchain. But the random number is a thing we could address right now, think about that, it requires a hard fork to add it, but we are just right here, even Ethereum is also working actively on adding the random number in eth2.0, you should know how important it is for a public chain project. We can work on other improvements later, but not this one since it needs a hard fork. Once you release N3 officially without the random number, there is no chance for neo to have it anymore, whatever the method you prefer. Random number is important for Games and NFTs, i don't know what N3 is gonna do when tons of Game and NFT contracts need the random number to work. |
@Liaojinghui Since your current implementation changes a lot from the discussion here, could you give a brief overview of it? It seems that there are still some concerns and suggestions. N3 is coming soon and |
nonce
directly withRandom
system call, willupdate it with BLS
based on issue Design a on-chain random number #1657 .It has remained a big challenge for all Blockchain projects to generate secure random numbers at runtime. Existing solutions to get random numbers are basically using the data from the Blockchain, which has limited random space and sometimes predictable. The random number should be hidden from users until transactions are executed and grouped into blocks to design a secure random number generator. It is hard to achieve a secure random number generator for other Blockchain projects, but rather easy to do so in neo because of dBFT.
Do you have any solution you want to propose?
The primary generates a random number denoted as
nonce_0
and keeps it in the header. After the new Block is confirmed, each consensus node generates a local random number marked asnonce
, then calculates the random number with VDF.VDF is a type of function with a minimal execution time, making sure that everyone has to wait for a specific time to get the result.
In the figure above:
nonce_0
is the random number from the latest Block. This value prevents other consensus nodes from preparing random numbers in advance.nonce
is the random number that each consensus node generates locally. This value prevents the last primary from calculating the random number in advance.block
denotes the hash value of the latest Block. This value makes sure that dishonest nodes could prepare the random number in advance jointly.To prevent nodes from generating random number in large scall to pick one that benefit themselves the best, the delay of the VDF should be over half of the value
MillisecondsPerBlock
.Considering each consensus period might have multiple views, every consensus node has to prepare its own verifiable random number in case of view change.
To prevent consensus nodes from creating multiple
nonce
values locally and run multiple VDF in parallel, we can useVerifiable Random Function (VRF)
to make sure that each consensus node can only generate one verifiable random number with given input.Neo Version
Where in the software does this update applies to?
The text was updated successfully, but these errors were encountered: