[Framework] Random Number on-chain solution
- [x] Simple on-chain Random Number #771
- [ ] VRF on-chain
How about generating random seed in Rust and stored in TxContext, and then read it in contract?
How about generating random seed in Rust and stored in TxContext, and then read it in contract?
It is unverifiable
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.
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
ZK-VRF please refer:
https://github.com/zkvrf/zkvrf https://github.com/jae-cuz/zk-draw
A simple solution:
- Let the sequencer generate a random seed and add it to
TransactionSequenceInfo. - Include the
seedin the data of the sequencer signature. - 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?
Is the second issue VRF on-chain needing to be resolved?
Is the second issue
VRF on-chainneeding to be resolved?
Make this TBD