This guest post was written by: Pyrite - ruby.exchange core team
One of Ruby.Exchange's key features is the use of gemstones: NFT artworks that vary in both their appearance and the practical functionality they provide to users.
Gemstones displayed as user profile identifiers will have randomly-generated parameters. Meanwhile, gems that confer permissioned rewards to users will be distributed using a simple raffle system. For each case, a random number generator (RNG) is required.
However, it's hard to generate reliably random numbers within the deterministic environment of a computer system. At the same time, it's vital that the allocation of gemstones—which will embody real economic value—cannot be gamed by either users or network validators.
As it turns out, SKALE's BLS signatures offer the ideal solution to this problem.
The Problem Of On-Chain Randomness
Randomness is important for many applications, both online and offline, most obviously in gaming but also in areas as diverse as medical trials, cryptographic key generation, statistical sampling, computer simulation, and even generative art.
In the offline world, randomness of sufficient "quality" can be gained through a simple coin toss or the roll of a dice. In the digital realm, true randomness is much harder to find. Private key generation for crypto wallets often involves a human-provided source of randomness, such as moving the mouse around for a few seconds. Of course, this is impractical when random numbers are required in real time.
Video games typically use pseudorandom number generators (PRNG), which are good enough for most purposes but cannot be considered truly random. When dealing with applications where value is involved, we can't afford to take any chances.
Ruby.Exchange requires a RNG for generating and distributing gemstone NFTs. This must use a source of randomness that cannot be influenced by an attacker, that everyone can trust, and that is integrated with the blockchain for full transparency.
Ethereum does have a source of randomness in the form of the hash of data included with every block. This would be good enough for almost any application, if it were not for the fact that each block is produced by a single miner, who is able to structure the data and change the resulting hash, as well as know the result before anyone else. In other words, a miner can front-run randomness: It's impossible to do so much as flip a virtual coin on Ethereum without the miner knowing the result before it lands.
Many Ethereum-based projects use Chainlink's VRF (Verifiable Random Function), a provably fair RNG, but this is not yet available on SKALE.
Fortunately, SKALE itself has the ideal solution, built right into the way the network is secured.
BLS Signatures For The Win
As Stan comments in the video above, there is just one known mathematical algorithm capable of generating a random number from a large number of nodes in a cooperative way, thereby providing a decentralized and trustworthy source of randomness.
BLS (Boneh-Lynn-Shacham) signatures enable a group to sign a message (whether a document, blockchain transaction, or anything else), with each signatory providing a fragment of the final signature.
Any subset of a larger set of potential signatories can sign a transaction and produce the same result. SKALE already uses such threshold signatures, with a supermajority of nodes (e.g. 11 out of 16) being required to validate a block, rather than a single validator being solely responsible for producing each block.
Any subset of a larger group of nodes can create the same signature.
This means the BLS block signature can be considered a reliable source of randomness. The random number generated changes with every block (every few seconds), and cannot be influenced or anticipated in advance by a rogue miner.
In practice, this source of randomness can be accessed using a simple Solidity call, and can easily be used by Ruby or any other application.
Random number generation can be incorporated into dApps with just a few lines of code.
Reliably Random NFTs
SKALE's use of threshold encryption means that there is a source of randomness built into the way SKALE establishes consensus and adds blocks to the blockchain.
BLS signatures are also the technology that prevents MEV attacks on SKALE chains, thus avoiding the problem of front-running on Ruby that plagues DeFi applications on Ethereum mainnet—another feature we appreciate.
This unique property of the SKALE network means Ruby has the ideal way to incorporate provably random numbers into the way NFTs are generated, and to hide them from potential attackers until they are revealed to everyone else too.
Securely, easily, and free of charge.