Skip to content

Commit d1caf50

Browse files
authored
Merge pull request #2 from SenseiCaz/patch-1
Update README.md
2 parents ddb6a18 + 13616ba commit d1caf50

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

README.md

+29-29
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# VRF
2-
This repository contains basic code for verifiable random function(vrf.go), and a simple selection mechanism(sortition.go).
2+
This repository contains basic code for verifiable random function (vrf.go), and a simple selection mechanism (sortition.go).
33

4-
Note that vrf implementation is originally from Yahoo's work(2017, Apache 2.0), which retrieved from [here](https://github.com/r2ishiguro/vrf/tree/master/go/vrf_ed25519).
4+
Note that this vrf implementation is originally from Yahoo's work (2017, Apache 2.0), which can be retrieved [here](https://github.com/r2ishiguro/vrf/tree/master/go/vrf_ed25519).
55

6-
In this repository, I modified it because 1) it was far away from go convention(I'm not good at the convention though), 2) It was not good for utilizing vrf output, which can be used for cryptographic sortition or selection mechanism in blockchain technologies.
6+
In this repository, I modified it because 1) it was far away from the go convention (though I'm not good at the convention), 2) it was not good for utilizing vrf output for cryptographic sortition or selection mechanisms in blockchain technologies.
77

8-
So, here's the change log. 1) all the function names changed to be carmelCase instead of snake_case. 2) all the functions became private except Prove(), Hash(), Verify(). 3) Prove() function now returns not only proof(pi) but also vrf output so that users can easily use them without calling Hash() function.
8+
This is the change log: 1) All the function names were changed to be carmelCase instead of snake_case. 2) All the functions became private except Prove(), Hash(), Verify(). 3) Prove() function now returns not only proof(pi) but also vrf output so that users can easily use them without calling Hash() function.
99

10-
In addition, I made a simple selection mechanism(can be called a kind of cryptographic sortition). This may help you to understand how to use vrf output. For more details, [click here](https://github.com/yoseplee/vrf#3-a-simple-selection-mechanism).
10+
In addition, I made a simple selection mechanism (this can be called a kind of cryptographic sortition). This may help you to understand how to use vrf output. For more details, [click here](https://github.com/yoseplee/vrf#3-a-simple-selection-mechanism).
1111

12-
Any kind of contribution will be welcomed. Thanks!
12+
Any kind of contribution will be welcome. Thanks!
1313

1414
# Appendix
1515
## 1. Available VRF Implementations
@@ -24,50 +24,50 @@ Any kind of contribution will be welcomed. Thanks!
2424
* uses SHA512 instead of SHA256
2525
## 2. Concept of VRF(Verifiable Random Function)
2626
![the concept of vrf](https://github.com/yoseplee/vrf/blob/master/resources/vrf-concept.png?raw=true)
27-
* A pseudorandom number can be verified by anyone who has sender's public key
28-
* A sender can generate a pseudorandom number with his/her private key and message
29-
* its result(a random number) and the proof is returned and throw them to a receiver
30-
* A receiver can verify the number that sender generated that pseudorandom number with (sender's public key, proof, pseudorandom number, message)
27+
* A pseudorandom number can be verified by anyone who has a sender's public key
28+
* A sender can generate a pseudorandom number with their private key and message
29+
* the result (a random number) and the proof is returned and both are sent to a receiver
30+
* The receiver can verify the number the sender generated with the sender's public key, proof, pseudorandom number, and message
3131

3232
### 2.1. Functions in VRF
33-
> Generally, VRF implementation has 3 function below
34-
1. Keygen(VRF_GEN): generates key pair(secret key, public key)
35-
2. Evaluate(VRF_EVAL): generates pseudorandom number and its proof
36-
3. Verify(VRF_VER): verify the random number with proof
33+
> Generally, VRF implementation has the 3 functions below
34+
1. Keygen (VRF_GEN): generates a key pair (secret key, public key)
35+
2. Evaluate (VRF_EVAL): generates a pseudorandom number and its proof
36+
3. Verify (VRF_VER): verifies the random number with proof
3737

38-
### 2.2. Three Properties of VRF
38+
### 2.2. The Three Properties of VRF
3939
> [Gorka Irazoqui Apecechea's article posted to Medium - see how it works would be great for you](https://medium.com/witnet/cryptographic-sortition-in-blockchains-the-importance-of-vrfs-ad5c20a4e018)
4040
1. Collision resistance: it is hard to find two inputs that map to the same output
41-
2. Pseudorandomness: the output is indistinguishable from random by anyone not knowing the secret key
42-
3. Trusted Uniqueness: That requires that, given a public key, a VRF input m corresponding to a unique output for the same input value, result should be unique
41+
2. Pseudorandomness: the output is unidentifiable as a random number for anyone not knowing the secret key
42+
3. Trusted Uniqueness: This requires that, given a public key, for a VRF input m corresponding to a unique output for the same input value, the result should be unique
4343

4444
## 3. A simple selection mechanism
45-
> This also called as cryptographic sortition
45+
> This is also called cryptographic sortition
4646
### 3.1. Calculate Random number from hash(vrf output)
4747
![Probability mass](https://github.com/yoseplee/vrf/blob/master/resources/sortitionProbMass.gif?raw=true)
48-
* Can calculate a random ratio range in [0, 1] from vrf output which is unique for a message, and verifiable for all the others who have issuer's public key and its proof
48+
* Can calculate a random ratio range [0, 1] from the vrf output which is unique to a message and verifiable for everyone who has the issuer's public key and its proof
4949
* The Ratio can be calculated as follows:
5050
* ratio = hash / (2^hashlen)
5151
* And **its probability is uniformly distributed**
5252
> To calculate the result by yourself, just run the main function. It's ready for you! e.g. $go run .
5353
5454
### 3.2. Implement the selection mechanism
5555
![an overview of simple cryptographic sortition](https://github.com/yoseplee/vrf/blob/master/resources/simple-sortition-overview.png?raw=true)
56-
* Now we can implement a cryptographic sortition using VRF by setting a threshold or range which can represents selection by itself
56+
* Now we can implement a cryptographic sortition using VRF by setting a threshold or range which can represent a selection by itself.
5757
* Example
58-
* let's say we have set range [0, 0.1] and any ratios which value is in it means the selected one
59-
* Peer 'A' calculated ratio and its value is 0.03
60-
* Then 'A' can claim that he/she is selected and can verify it by providing the proof
61-
* Peer 'B' calculated ratio and its value is 0.5
62-
* Then 'B' cannot claim that he/she is selected as its value is out of range [0, 0.1]
58+
* Let's say we have set a range [0, 0.1] and any ratio whose value falls in that range is a selected value
59+
* Peer 'A' calculated a ratio and its value is 0.03
60+
* Then 'A' can claim that they have selected a value and can verify it by providing the proof
61+
* Peer 'B' calculated a ratio and its value is 0.5
62+
* Then 'B' cannot claim that they have selected a value as its value is outside of the range [0, 0.1]
6363

6464
### 3.3. Result
65-
* In the code written in sortition, the threshold set for 0.3, which means that only participants who got the value under 0.3 will be selected
66-
* To execute experiment to see if its expected rate of selection, test code is ready for run sortition for 1000 times and count the ratio of success
65+
* In the code written in the sortition, the threshold was set to 0.3, which means that only participants who got a value under 0.3 will be selected
66+
* To see if it falls in the expected selection ratio, I ran the test code, which runs sortition 1000 times and counts the ratio of success
6767
```sh
6868
# at the root directory of the project
6969
cd sortition/
7070
go test
7171
```
72-
* As the random variable from vrf output is from the uniform distribution, expected ratio of success will be almost the same as the threshold
73-
* if you are very lucky, you would see fail as this is probability case.
72+
* As the random variable from vrf output is from a uniform distribution, the expected ratio of success will be almost the same as the threshold
73+
* As this is probability-based test, there is a small chance that you get lucky and see it fail.

0 commit comments

Comments
 (0)