rooch icon indicating copy to clipboard operation
rooch copied to clipboard

[Framework] Random Number on-chain solution

Open jolestar opened this issue 2 years ago • 8 comments

  • [x] Simple on-chain Random Number #771
  • [ ] VRF on-chain

jolestar avatar Sep 06 '23 09:09 jolestar

How about generating random seed in Rust and stored in TxContext, and then read it in contract?

pause125 avatar Sep 06 '23 13:09 pause125

How about generating random seed in Rust and stored in TxContext, and then read it in contract?

It is unverifiable

jolestar avatar Sep 06 '23 15:09 jolestar

How about generating random seed in Rust and stored in TxContext, and then read it in contract?

It is unverifiable

May the verifiable feature is not required unless we have consensus mechanism? We can emit an event every query a random number.

pause125 avatar Sep 07 '23 06:09 pause125

May the verifiable feature is not required unless we have consensus mechanism?

The transaction needs to be synced to another executor or proposer node, so the execution result must be determinate. Maybe we can put the sequencer's transaction witness data in the TxContext, and sync the transaction and witness data together. #771

jolestar avatar Sep 08 '23 08:09 jolestar

ZK-VRF please refer:

https://github.com/zkvrf/zkvrf https://github.com/jae-cuz/zk-draw

MaggieNgWu avatar Oct 30 '23 18:10 MaggieNgWu

A simple solution:

  1. Let the sequencer generate a random seed and add it to TransactionSequenceInfo.
  2. Include the seed in the data of the sequencer signature.
  3. In the future, we can improve the random seed by zkVRF.
pub struct TransactionSequenceInfo {
    /// The tx order
    pub tx_order: u128,
    /// The tx order signature, it is the signature of the sequencer to commit the tx order.
    pub tx_order_signature: Authenticator,
    /// The tx accumulator root after the tx is append to the accumulator.
    pub tx_accumulator_root: H256,
}

Or can we directly use the tx_order_signature as the random seed?

jolestar avatar Oct 31 '23 16:10 jolestar

Is the second issue VRF on-chain needing to be resolved?

Is the second issue VRF on-chain needing to be resolved?

Make this TBD

jolestar avatar Aug 10 '24 11:08 jolestar