There is a lot of advantages of blockchain technology but its transparency, combined with the deterministic nature of computers is a stumbling block in creating true on-chain randomness. Yet, random number generators (RNGs) are essential tools for solving various algorithmic problems. Here we will discuss the approach Oasis has adopted to ensure smart contract developers can integrate randomness into their applications in a hassle-free manner. What is RNG As deterministic machines, computers function by following predictable instructions. So, randomness is never truly possible. However, almost random numbers can be generated with external inputs or complex algorithms. But how feasible is this? Not very. For example, a deterministic RNG can only mimic randomness and produce pseudo-random outputs using algorithms transforming a starting “seed” value into sequences. If the “seed” is known, it all becomes predictable. On the other hand, non-deterministic RNG can generate completely random numbers by using erratic physical phenomena, like dice rolls or photon scattering, as a workaround for the computer reading predictable patterns. Why blockchains need RNG? When you try to replicate RNG in the smart contract framework, it gets interesting. Whether you are developing dApps for the web3 at large or the cryptoAI space, you will need provable fairness or unbiased and tamperproof outcomes based on unpredictable inputs. Even from a core blockchain point of view, RNG plays a crucial role in cryptographic operations. It produces the unique keys or values needed for securing transactions, encrypting data, or authenticating users, ensuring that outputs cannot be guessed or replicated. Without secure on-chain RNG, reverse engineering of keys, outcome manipulation and all kinds of exploits become possible. Now, blockchain technology also use deterministic rules, and all nodes reaching a consensus is a non-negotiable criteria. This makes on-chain randomness tricky but it is still doable. For example, verifiable random functions, commit-reveal schemes, or the method Oasis has adopted — using Verifiable Random Function (VRF) and some other cryptographic primitives. Let’s now take a closer look into Oasis. How Oasis RNG works? With its default focus on smart privacy and scalability, Oasis uses its confidential EVM runtime, Sapphire to streamline RNG through its randomBytes precompile. By abstracting a simple Solidity function, any smart contract developer can integrate randomness into their applications without dealing with the complexities of blockchain RNG. It basically works like this. Generating the Per-Block Root RNG Sapphire communicates with a key manager runtime to generate secret keys. The key manager supports multiple kinds of keys, some of which are long-term and some of which are ephemeral. The ephemeral keys are used for encrypting transactions and also the RNG. To improve security, these keys are never persisted anywhere and are rotated each epoch. This means fresh keys are generated, and after a while, old keys get securely erased and cannot be recovered even if any component is later compromised. The RNG exposed to Sapphire contracts is initialized on every block. Each block uses private ephemeral entropy obtained from the key manager runtime. Only remotely attested Sapphire instances can obtain this private entropy inside the TEE, which ensures that no external observers can learn anything about the RNG state. Next, this entropy is processed and used as a root VRF key. To turn this entropy into a usable key, Sapphire employs SHA-3-derived algorithms like TupleHash, KMAC256, and cSHAKE. These functions process the epoch-specific entropy from the key manager runtime, producing a unique per-block root RNG that anchors all subsequent randomness in the block with consistency and security. Domain Separation for Per-Transaction RNGs The per-block root RNG alone isn’t enough. Each transaction needs its own private RNG, which is where domain separation comes in. Sapphire builds on the key manager’s output by using Merlin transcripts to initialize per-transaction RNGs from the root RNG, customizing randomness for individual interactions using transaction-specific data. This customization is implemented in the Rust Runtime SDK used to build Sapphire, which handles the VRF and domain separation schemes. Together with the key manager’s private entropy, it ensures private, unbiased, and unpredictable outputs are exposed to developers via the randomBytes precompile. Code examples Basic Random Number Generation This snippet shows how to generate a 32-byte random value, ideal for straightforward RNG needs in a dApp like a poker game. bytes memory randomPad = Sapphire.randomBytes(32, ""); Random Number for Signing Key Pair This snippet uses randomBytes to seed a signing key pair generation, which you can use as a part of a more complex RNG-driven mechanism while ensuring cryptographic security. Sapphire.SigningAlg alg = Sapphire.SigningAlg.Ed25519Pure;bytes memory pk;bytes memory sk;(pk, sk) = Sapphire.generateSigningKeyPair(alg, Sapphire.randomBytes(32, "")); Key Resources: Sapphire docsSapphire repositoryrandomBytesOasis ROFLOasis playground for demo dApps Have a question or need help? Join our Discord and head over to the #dev-central channel. Originally published at https://dev.to on September 22, 2025. Secure On-chain Randomness By Oasis Is A Great Way To Answer The Blockchain Need For RNG was originally published in Coinmonks on Medium, where people are continuing the conversation by highlighting and responding to this storyThere is a lot of advantages of blockchain technology but its transparency, combined with the deterministic nature of computers is a stumbling block in creating true on-chain randomness. Yet, random number generators (RNGs) are essential tools for solving various algorithmic problems. Here we will discuss the approach Oasis has adopted to ensure smart contract developers can integrate randomness into their applications in a hassle-free manner. What is RNG As deterministic machines, computers function by following predictable instructions. So, randomness is never truly possible. However, almost random numbers can be generated with external inputs or complex algorithms. But how feasible is this? Not very. For example, a deterministic RNG can only mimic randomness and produce pseudo-random outputs using algorithms transforming a starting “seed” value into sequences. If the “seed” is known, it all becomes predictable. On the other hand, non-deterministic RNG can generate completely random numbers by using erratic physical phenomena, like dice rolls or photon scattering, as a workaround for the computer reading predictable patterns. Why blockchains need RNG? When you try to replicate RNG in the smart contract framework, it gets interesting. Whether you are developing dApps for the web3 at large or the cryptoAI space, you will need provable fairness or unbiased and tamperproof outcomes based on unpredictable inputs. Even from a core blockchain point of view, RNG plays a crucial role in cryptographic operations. It produces the unique keys or values needed for securing transactions, encrypting data, or authenticating users, ensuring that outputs cannot be guessed or replicated. Without secure on-chain RNG, reverse engineering of keys, outcome manipulation and all kinds of exploits become possible. Now, blockchain technology also use deterministic rules, and all nodes reaching a consensus is a non-negotiable criteria. This makes on-chain randomness tricky but it is still doable. For example, verifiable random functions, commit-reveal schemes, or the method Oasis has adopted — using Verifiable Random Function (VRF) and some other cryptographic primitives. Let’s now take a closer look into Oasis. How Oasis RNG works? With its default focus on smart privacy and scalability, Oasis uses its confidential EVM runtime, Sapphire to streamline RNG through its randomBytes precompile. By abstracting a simple Solidity function, any smart contract developer can integrate randomness into their applications without dealing with the complexities of blockchain RNG. It basically works like this. Generating the Per-Block Root RNG Sapphire communicates with a key manager runtime to generate secret keys. The key manager supports multiple kinds of keys, some of which are long-term and some of which are ephemeral. The ephemeral keys are used for encrypting transactions and also the RNG. To improve security, these keys are never persisted anywhere and are rotated each epoch. This means fresh keys are generated, and after a while, old keys get securely erased and cannot be recovered even if any component is later compromised. The RNG exposed to Sapphire contracts is initialized on every block. Each block uses private ephemeral entropy obtained from the key manager runtime. Only remotely attested Sapphire instances can obtain this private entropy inside the TEE, which ensures that no external observers can learn anything about the RNG state. Next, this entropy is processed and used as a root VRF key. To turn this entropy into a usable key, Sapphire employs SHA-3-derived algorithms like TupleHash, KMAC256, and cSHAKE. These functions process the epoch-specific entropy from the key manager runtime, producing a unique per-block root RNG that anchors all subsequent randomness in the block with consistency and security. Domain Separation for Per-Transaction RNGs The per-block root RNG alone isn’t enough. Each transaction needs its own private RNG, which is where domain separation comes in. Sapphire builds on the key manager’s output by using Merlin transcripts to initialize per-transaction RNGs from the root RNG, customizing randomness for individual interactions using transaction-specific data. This customization is implemented in the Rust Runtime SDK used to build Sapphire, which handles the VRF and domain separation schemes. Together with the key manager’s private entropy, it ensures private, unbiased, and unpredictable outputs are exposed to developers via the randomBytes precompile. Code examples Basic Random Number Generation This snippet shows how to generate a 32-byte random value, ideal for straightforward RNG needs in a dApp like a poker game. bytes memory randomPad = Sapphire.randomBytes(32, ""); Random Number for Signing Key Pair This snippet uses randomBytes to seed a signing key pair generation, which you can use as a part of a more complex RNG-driven mechanism while ensuring cryptographic security. Sapphire.SigningAlg alg = Sapphire.SigningAlg.Ed25519Pure;bytes memory pk;bytes memory sk;(pk, sk) = Sapphire.generateSigningKeyPair(alg, Sapphire.randomBytes(32, "")); Key Resources: Sapphire docsSapphire repositoryrandomBytesOasis ROFLOasis playground for demo dApps Have a question or need help? Join our Discord and head over to the #dev-central channel. Originally published at https://dev.to on September 22, 2025. Secure On-chain Randomness By Oasis Is A Great Way To Answer The Blockchain Need For RNG was originally published in Coinmonks on Medium, where people are continuing the conversation by highlighting and responding to this story

Secure On-chain Randomness By Oasis Is A Great Way To Answer The Blockchain Need For RNG

2025/09/23 16:40
5 min read

There is a lot of advantages of blockchain technology but its transparency, combined with the deterministic nature of computers is a stumbling block in creating true on-chain randomness. Yet, random number generators (RNGs) are essential tools for solving various algorithmic problems. Here we will discuss the approach Oasis has adopted to ensure smart contract developers can integrate randomness into their applications in a hassle-free manner.

What is RNG

As deterministic machines, computers function by following predictable instructions. So, randomness is never truly possible. However, almost random numbers can be generated with external inputs or complex algorithms. But how feasible is this?

Not very. For example, a deterministic RNG can only mimic randomness and produce pseudo-random outputs using algorithms transforming a starting “seed” value into sequences. If the “seed” is known, it all becomes predictable.

On the other hand, non-deterministic RNG can generate completely random numbers by using erratic physical phenomena, like dice rolls or photon scattering, as a workaround for the computer reading predictable patterns.

Why blockchains need RNG?

When you try to replicate RNG in the smart contract framework, it gets interesting. Whether you are developing dApps for the web3 at large or the cryptoAI space, you will need provable fairness or unbiased and tamperproof outcomes based on unpredictable inputs.

Even from a core blockchain point of view, RNG plays a crucial role in cryptographic operations. It produces the unique keys or values needed for securing transactions, encrypting data, or authenticating users, ensuring that outputs cannot be guessed or replicated. Without secure on-chain RNG, reverse engineering of keys, outcome manipulation and all kinds of exploits become possible.

Now, blockchain technology also use deterministic rules, and all nodes reaching a consensus is a non-negotiable criteria. This makes on-chain randomness tricky but it is still doable. For example, verifiable random functions, commit-reveal schemes, or the method Oasis has adopted — using Verifiable Random Function (VRF) and some other cryptographic primitives. Let’s now take a closer look into Oasis.

How Oasis RNG works?

With its default focus on smart privacy and scalability, Oasis uses its confidential EVM runtime, Sapphire to streamline RNG through its randomBytes precompile. By abstracting a simple Solidity function, any smart contract developer can integrate randomness into their applications without dealing with the complexities of blockchain RNG.

It basically works like this.

Generating the Per-Block Root RNG

  • Sapphire communicates with a key manager runtime to generate secret keys. The key manager supports multiple kinds of keys, some of which are long-term and some of which are ephemeral.
  • The ephemeral keys are used for encrypting transactions and also the RNG. To improve security, these keys are never persisted anywhere and are rotated each epoch. This means fresh keys are generated, and after a while, old keys get securely erased and cannot be recovered even if any component is later compromised.
  • The RNG exposed to Sapphire contracts is initialized on every block. Each block uses private ephemeral entropy obtained from the key manager runtime. Only remotely attested Sapphire instances can obtain this private entropy inside the TEE, which ensures that no external observers can learn anything about the RNG state.
  • Next, this entropy is processed and used as a root VRF key. To turn this entropy into a usable key, Sapphire employs SHA-3-derived algorithms like TupleHash, KMAC256, and cSHAKE. These functions process the epoch-specific entropy from the key manager runtime, producing a unique per-block root RNG that anchors all subsequent randomness in the block with consistency and security.

Domain Separation for Per-Transaction RNGs

  • The per-block root RNG alone isn’t enough. Each transaction needs its own private RNG, which is where domain separation comes in. Sapphire builds on the key manager’s output by using Merlin transcripts to initialize per-transaction RNGs from the root RNG, customizing randomness for individual interactions using transaction-specific data.
  • This customization is implemented in the Rust Runtime SDK used to build Sapphire, which handles the VRF and domain separation schemes. Together with the key manager’s private entropy, it ensures private, unbiased, and unpredictable outputs are exposed to developers via the randomBytes precompile.

Code examples

Basic Random Number Generation
This snippet shows how to generate a 32-byte random value, ideal for straightforward RNG needs in a dApp like a poker game.

bytes memory randomPad = Sapphire.randomBytes(32, "");

Random Number for Signing Key Pair
This snippet uses randomBytes to seed a signing key pair generation, which you can use as a part of a more complex RNG-driven mechanism while ensuring cryptographic security.

Sapphire.SigningAlg alg = Sapphire.SigningAlg.Ed25519Pure;
bytes memory pk;
bytes memory sk;
(pk, sk) = Sapphire.generateSigningKeyPair(alg, Sapphire.randomBytes(32, ""));

Key Resources:

Sapphire docs
Sapphire repository
randomBytes
Oasis ROFL
Oasis playground for demo dApps

Have a question or need help? Join our Discord and head over to the #dev-central channel.

Originally published at https://dev.to on September 22, 2025.


Secure On-chain Randomness By Oasis Is A Great Way To Answer The Blockchain Need For RNG was originally published in Coinmonks on Medium, where people are continuing the conversation by highlighting and responding to this story.

Disclaimer: The articles reposted on this site are sourced from public platforms and are provided for informational purposes only. They do not necessarily reflect the views of MEXC. All rights remain with the original authors. If you believe any content infringes on third-party rights, please contact service@support.mexc.com for removal. MEXC makes no guarantees regarding the accuracy, completeness, or timeliness of the content and is not responsible for any actions taken based on the information provided. The content does not constitute financial, legal, or other professional advice, nor should it be considered a recommendation or endorsement by MEXC.

You May Also Like

Solana Price Plummets: SOL Crashes Below $90 in Stunning Market Reversal

Solana Price Plummets: SOL Crashes Below $90 in Stunning Market Reversal

BitcoinWorld Solana Price Plummets: SOL Crashes Below $90 in Stunning Market Reversal In a dramatic shift for one of cryptocurrency’s leading networks, Solana (
Share
bitcoinworld2026/02/05 06:45
New Developments Could Push Price Toward $0.40

New Developments Could Push Price Toward $0.40

The post New Developments Could Push Price Toward $0.40 appeared on BitcoinEthereumNews.com. Pi Network has been one of the most anticipated projects in the crypto space, with millions of users mining its tokens via mobile devices long before a tradable price was established. Over the past few years, the project has carefully balanced its testnet development with community engagement, creating one of the largest ecosystems by user count despite not being fully listed on major exchanges. As 2025 advances, new updates are pushing Pi Network closer to mainstream adoption. Analysts suggest these developments could serve as the catalyst that finally drives Pi’s price toward the $0.40 level, a milestone that would validate years of community patience. In this context, investors are watching closely to see if Pi Network can turn its massive user base into sustainable value. Alongside this story, presale projects like MAGACOIN FINANCE are also drawing attention as speculative plays offering high asymmetry before exchange listings. Pi Network’s unique approach Unlike most cryptocurrencies, Pi Network built its community first, launching a mobile mining app that allowed millions of users to accumulate tokens without high-end hardware. This grassroots approach created unprecedented scale, with more than 50 million pioneers participating globally. The challenge, however, has always been translating this scale into economic value. By focusing on KYC verification, ecosystem apps, and gradual migration toward mainnet, the team has aimed to avoid the pitfalls of rushed launches. Analysts argue that this deliberate approach is what could allow Pi Network to sustain value once it achieves full exchange listings. Recent developments In 2025, Pi Network rolled out several updates that have sparked renewed optimism. Expanded KYC processes have accelerated, allowing more users to validate their holdings and prepare for migration. At the same time, Pi App Platform has gained traction, with developers launching decentralized apps directly into the Pi ecosystem. These apps range from…
Share
BitcoinEthereumNews2025/09/18 14:15
The $1.7 Billion Masterstroke Reshaping Tech’s Foundation

The $1.7 Billion Masterstroke Reshaping Tech’s Foundation

The post The $1.7 Billion Masterstroke Reshaping Tech’s Foundation appeared on BitcoinEthereumNews.com. A16z AI Infrastructure Fund: The $1.7 Billion Masterstroke
Share
BitcoinEthereumNews2026/02/05 06:36