Skip to content

Conversation

@lrubiorod
Copy link

@lrubiorod lrubiorod commented Nov 3, 2021

It is included inside of data request section but it could be moved

Close #97

Comment on lines 2 to 5
Witnet requests are currently used to retrieve information from public external APIs to Witnet network and
other blockchains that are connected with it. Moreover, using the structure about Witnet network, another
functionality as Random Number Generator (aka RNG) is possible, providing a real random number created by
several witnesses in a decentralized way.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to beat around the bush. Let's go straight to the point of RNG. This paragraph can be dropped altogether.

## Witnet RNG request
The Witnet RNG request shares the same structure as a normal request with the 3 stages (retrieval,
aggregation and tally) and it will be solved by the same witnesses that are currently working in the Witnet
mainnet. To retrieve this new functionality those are the changes:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mainnet. To retrieve this new functionality those are the changes:
mainnet.

Comment on lines 15 to 16
are not necessary, so the `url` will be empty and the `script` won't be read so we can specify the code
for an empty array. We only use an only retrieval for this kind of requests.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
are not necessary, so the `url` will be empty and the `script` won't be read so we can specify the code
for an empty array. We only use an only retrieval for this kind of requests.
are not necessary: the `url` field must be empty and the `script` field will be ignored, so we can specify the CBOR code for an empty array ([128]`). A single source is used in the retrieval section of this kind of requests.

Comment on lines 29 to 30
Aggregation is not necessary due to RNG requests has only one retrieval. To unwrap the `RadonArray` with
only one element we will use the `Mode` as a `RadonReducer` without filters.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Aggregation is not necessary due to RNG requests has only one retrieval. To unwrap the `RadonArray` with
only one element we will use the `Mode` as a `RadonReducer` without filters.
Aggregation is not necessary due to the fact that RNG requests have only one retrieval. To unwrap the `RadonArray` into a single element, we will use the `Mode` as a `RadonReducer` without filters.

Comment on lines 40 to 42
For the tally stage a new `RadonReducer` is required, `HashConcatenate`. This reducer takes the
`RadonBytes` sent by witnesses, concatenate them in a single vector of bytes and hash them with Sha2_256.
As the aggregation stage, no filters are required.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
For the tally stage a new `RadonReducer` is required, `HashConcatenate`. This reducer takes the
`RadonBytes` sent by witnesses, concatenate them in a single vector of bytes and hash them with Sha2_256.
As the aggregation stage, no filters are required.
For the tally stage, a new `RadonReducer` is required, `HashConcatenate`. This reducer takes the
`RadonBytes` revealed by the witnesses, concatenate them into a single vector of bytes and hash them with SHA256. In the same way as in the aggregation stage, no filters are required.

Comment on lines 51 to 54
## Conclusions
The random number generated by Witnet protocol is the result of a Hash function which its seed comes from
the random bytes provided by several different witnesses selected randomly in the Witnet mainnet. In this
way, randomness comes from the decentralization nature of Witnet protocol.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Conclusions
The random number generated by Witnet protocol is the result of a Hash function which its seed comes from
the random bytes provided by several different witnesses selected randomly in the Witnet mainnet. In this
way, randomness comes from the decentralization nature of Witnet protocol.
## Conclusions
The random numbers (actually, random bytes) generated by the Witnet protocol are the result of applying a hash function on a crowdsourced seed coming from the random bytes provided by several different witnesses, as selected randomly by the Witnet protocol. That is, the randomness property of these are powered by the decentralized nature of the Witnet network.

# Random Number Generation

## Witnet RNG request
The Witnet RNG request shares the same structure as a normal request with the 3 stages (retrieval, aggregation and
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about use a more specific word such as HTTP-GET or even standard?

Suggested change
The Witnet RNG request shares the same structure as a normal request with the 3 stages (retrieval, aggregation and
The Witnet RNG request shares the same structure as an HTTP-GET request with the 3 stages (retrieval, aggregation and

### Retrieval
As a source for RNG requests, we specify a new `RADType` called `Rng`. This new source will trigger the creation of a
random vector of 32 bytes, instead of reading data from an API source. The rest of fields are not necessary: the `url`
field must be empty and the `script` field will be ignored, so we can specify the CBOR code for an empty array
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
field must be empty and the `script` field will be ignored, so we can specify the CBOR code for an empty array
field must be empty and the `script` field will be ignored so we can specify the CBOR code for an empty array


### Retrieval
As a source for RNG requests, we specify a new `RADType` called `Rng`. This new source will trigger the creation of a
random vector of 32 bytes, instead of reading data from an API source. The rest of fields are not necessary: the `url`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
random vector of 32 bytes, instead of reading data from an API source. The rest of fields are not necessary: the `url`
random vector of 32 bytes, instead of reading data from an API source. The rest of the fields are unnecessary: the `url`


### Tally
For the tally stage, a new `RadonReducer` is required, `HashConcatenate`. This reducer takes the `RadonBytes` revealed
by the witnesses, concatenate them into a single vector of bytes and hash them with SHA256. In the same way as in the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
by the witnesses, concatenate them into a single vector of bytes and hash them with SHA256. In the same way as in the
by the witnesses, concatenates them into a single vector of bytes and hash them with SHA256. In the same way, as in the

## Conclusions
The random numbers (actually, random bytes) generated by the Witnet protocol are the result of applying a hash
function on a crowdsourced seed coming from the random bytes provided by several different witnesses, as selected
randomly by the Witnet protocol. That is, the randomness property of these are powered by the decentralized nature
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
randomly by the Witnet protocol. That is, the randomness property of these are powered by the decentralized nature
randomly by the Witnet protocol. That is, the randomness property of these is powered by the decentralized nature

@lrubiorod lrubiorod merged commit c79809a into witnet:master Nov 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Documentation] Add RNG functionality

3 participants