<p>In most proof of stake systems, there isn't really some node that says "this node is the next staker". Rather what many do is, using data from the blockchain, calculate a set of public keys (the set can just be one public key) that can be the next staker. If a node that has the private key for one of those public keys is online, they can construct the next block.</p>

<p>The way that the set of public keys is determined varies by coin, but they all use data from the blockchain and a deterministic algorithm so that all nodes will come to the same set of public keys.</p>

<p>The randomness in these algorithms typically comes from hashing data which could not have been known beforehand (e.g. for block <code>n</code>, take the hash of block <code>n-1</code>). In this way, a random number is generated such that all nodes on the network will generate the same number.</p>

CC BY-SA 4.0
2018-05-15T08:24:05.117Z
Is this correct: all the nodes shares the same algorithm to generate the public keys from the blockchain. Then after block `n-1` is generated, all the nodes shares another algorithm so that they will agrees on a public key to determine the `miner` for block `n`.
Steven Luo
CC BY-SA 4.0
2018-05-15T14:37:01.320Z
They don't share anything, they use the same algorithm, so given the same blockchain, they will calculate the same thing and thus agree on the public keys. But yes, your idea is correct.
Ava Chow
CC BY-SA 4.0
2018-05-15T04:08:32.213Z
2018-05-15T04:08:32.213Z
Ava Chow
<p>I've researched on the internet, but am still confused about how Proof-of-stack works programmatically.</p>

<p>As mentioned <a href="https://bitcoin.stackexchange.com/questions/20007/how-does-proof-of-stake-mining-work">here</a>, in Proof-of-Stake system, <strong>A random Nextcoin is selected to be the next "miner".</strong> Which node is designated to randomly select a node as the next "miner"? Or in other words, how can a system agree on a random number in a way that can't be manipulated?</p>

<mining-theory><proof-of-stake>
How does Proof-of-Stake works programmatically
Steven Luo
# How does Proof-of-Stake works programmatically

(Asked by: username_0 on 2018-05-14)

I've researched on the internet, but am still confused about how Proof-of-stack works programmatically.

As mentioned [here](https://bitcoin.stackexchange.com/questions/20007/how-does-proof-of-stake-mining-work), in Proof-of-Stake system, **A random Nextcoin is selected to be the next "miner".** Which node is designated to randomly select a node as the next "miner"? Or in other words, how can a system agree on a random number in a way that can't be manipulated?

**Tags:** mining-theory, proof-of-stake


---

## 1 answers

### Answer by username_1 on 2018-05-15. Score: 2

In most proof of stake systems, there isn't really some node that says "this node is the next staker". Rather what many do is, using data from the blockchain, calculate a set of public keys (the set can just be one public key) that can be the next staker. If a node that has the private key for one of those public keys is online, they can construct the next block.

The way that the set of public keys is determined varies by coin, but they all use data from the blockchain and a deterministic algorithm so that all nodes will come to the same set of public keys.

The randomness in these algorithms typically comes from hashing data which could not have been known beforehand (e.g. for block `n`, take the hash of block `n-1`). In this way, a random number is generated such that all nodes on the network will generate the same number.

> **Comments:**
> **username_0**: Is this correct: all the nodes shares the same algorithm to generate the public keys from the blockchain. Then after block `n-1` is generated, all the nodes shares another algorithm so that they will agrees on a public key to determine the `miner` for block `n`.  
> **username_1**: They don't share anything, they use the same algorithm, so given the same blockchain, they will calculate the same thing and thus agree on the public keys. But yes, your idea is correct.  

---

