README.md in sharing-0.2.0 vs README.md in sharing-0.3.0
- old
+ new
@@ -1,8 +1,8 @@
# Sharing
-![GitHub Workflow Status](https://img.shields.io/github/workflow/status/davidwilliam/sharing/Ruby)
+![GitHub Workflow Status](https://github.com/davidwilliam/sharing/actions/workflows/main.yml/badge.svg) [![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop) ![GitHub](https://img.shields.io/github/license/davidwilliam/sharing) ![Gem](https://img.shields.io/gem/v/sharing) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/davidwilliam/sharing)
Sharing is a Ruby gem with implmementations of secret sharing schemes with homomorphic properties. Although secret sharing schemes and multiparty computation protocols are distinct notions, multiparty computation protocols are typically enabled by secret sharing schemes. In this setting, security comes from the use of multiple parties. If they collude, all security is lost, but satisfactory levels of security can be established by trusting a subset of them will not to collude. In many settings where corrupting security requires corrupting all the parties, and considering you are one of the computing parties, security is guaranteed if you are one of the parties.
Computing linear functions is trivial. Each non-linear operation however requires interaction between the parties/extra steps (for most secret sharing schemes).
@@ -262,10 +262,94 @@
# => 25
```
Everything else works the sabe as before except the fact that only `3` shares are required to reconstruct the secret.
+### Division
+
+Here we simulate a division algorithm computed over the shares. Consider the following configuration:
+
+```ruby
+{:lambda_=>16, :total_shares=>6, :threshold=>3}
+sss = Sharing::Polynomial::Shamir::V1.new(params)
+```
+
+and the rational numbers
+
+```ruby
+rat1 = Rational(2, 3)
+rat2 = Rational(-5, 7)
+```
+
+We compute their Hensel code so we define our secrets:
+
+```ruby
+secret1 = HenselCode::TFPE.new(sss.p, 1, rat1).hensel_code
+# => 40896
+secret2 = HenselCode::TFPE.new(sss.p, 1, rat2).hensel_code
+# => 52579
+```
+
+We then comute the shares for each secret:
+
+```ruby
+shares1 = sss.create_shares(secret1)
+# => [[1, 22792], [2, 38518], [3, 26731], [4, 48774], [5, 43304], [6, 10321]]
+shares2 = sss.create_shares(secret2)
+# => [[1, 37982], [2, 294], [3, 858], [4, 39674], [5, 55399], [6, 48033]]
+```
+
+We select a subset of the shares of eacg secret based on the threshold:
+
+```ruby
+selected_shares1 = shares1.sample(sss.threshold)
+# => [[1, 22792], [5, 43304], [6, 10321]]
+selected_shares2 = shares2.sample(sss.threshold)
+# => [[6, 48033], [2, 294], [1, 37982]]
+```
+
+A party that is not one of the selected parties (a trusted party for instance) generates three random values that will later used:
+
+```ruby
+r1, r2, r3 = Sharing::Polynomial::Shamir::V1.generate_division_masking(sss.p)
+=> [23078, 18925, 18812]
+```
+
+Each party multiply their shares of the first operand by `r1` and the shares of the second operand by `r2`. For convenience (given our simulation), this step is here done all at once as follows:
+
+```ruby
+cs, ds = Sharing::Polynomial::Shamir::V1.compute_numerator_denominator(selected_shares1, selected_shares2, r1, r2, sss.p)
+=> [[[1, 38894], [5, 30899], [6, 54512]], [[6, 43951], [2, 43080], [1, 53419]]]
+```
+
+`cs` denote the shares representing the numerator of the division and `ds` represent the shares of the denominator of the division, as in `c/d`.
+
+Finally, in the reconstruction step, `c` and `d` are reconstructed and `r3` is used to invert the multiplication by `r1` and `r2` that was previously computed by the parties. With the correct values recovered, we compute the Hensel decoding and then we obtain the final result without revealing what the numerator and denominator were. For convenience, we execute these steps as follows:
+
+```ruby
+sss.reconstruct_division(cs, ds, r3)
+# => (-14/15)
+```
+
+We can also use only a subset of the shares:
+
+```ruby
+selected_cs = cs.sample(sss.threshold)
+=> [[5, 30899], [1, 38894], [6, 54512]]
+selected_ds = ds.sample(sss.threshold)
+# => [[2, 43080], [1, 53419], [6, 43951]]
+sss.reconstruct_division(selected_cs, selected_ds, r3)
+=> (-14/15)
+```
+
+And we can check that
+
+```ruby
+rat1 / rat2
+# => (-14/15)
+```
+
## Asmuth-Bloom V2
The Asmuth-Bloom V2 was proposed by Ersoy et al. in in [Homomorphic extensions of CRT-based secret sharing](https://www.sciencedirect.com/science/article/pii/S0166218X20303012)). The reference is a CRT-based secret sharing scheme introduced by Asmuth-Bloom in [A modular approach to key safeguarding](https://ieeexplore.ieee.org/abstract/document/1056651).
We have currently the class `Sharing::CRT::AsmuthBloom::V2`. To initialize it, we need to pass the following parameters:
@@ -324,10 +408,23 @@
# => 53
```
and we can check that 5 + 8 = 13, 5 * 8 = 40, and 13 + 40 = 53.
+## Author
+
+David William Silva
+
+## Contributors
+
+David William Silva (Algemetric)
+Marcio Junior (Algemetric)
+
+## Acknowledgements
+
+Luke Harmon (Algemetric) and Gaetan Delavignette (Algemetric) have been instrumental by providing/conducting mathematical analyses, tests, and overall recommendations for improving the gem.
+
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
@@ -336,6 +433,6 @@
Bug reports and pull requests are welcome on GitHub at https://github.com/davidwilliam/sharing.
## License
-The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
\ No newline at end of file
+The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).