What is Shamir’s secret sharing
Take a file, and read N bytes. Treat those bytes as an integer, and encrypt it using this implementation of the Shamir algorithm. I get n integers, and I write one each to a file. Read N more bytes, and so on until I am done.
Similarly, when decrypting, take n files, read an integer from each I write a byte to denote the length of an integer before each, so I know how many bytes to read , decrypt the n integers to get the original one, and convert it to bytes to get N bytes, and write them to a file, and then read more integers. This is working, but is rather slow - with encrypting to 3 files a MB file, it takes me 5 minutes to encrypt, 4 minutes to decrypt.
How can I speed it up? Of course, any other suggestions are also welcome.
You are probably doing it wrong. The scheme says it all: secret sharing. The algorithm is to share secrets rather than data.
I would rather suggest you to encrypt the whole file using a symmetric key algorithm like AES, using a random key and then share the key using Shamir's. This is the preferred way as going your way is guaranteed to be time intensive. If the number D is long, it is advisable to break it into shorter blocks of bits which are handled separately in order to avoid muti precision arithmetic operations.
Home Questions Tags Users Unanswered. Asked 4 years, 9 months ago. Active 3 years, 8 months ago. Viewed 3k times.
Here's a rough idea of what I'm doing: Take a file, and read N bytes. MainCombine; import com. MainSplit; import java. BigInteger; import java.
Contents of This Article
Files; import java. Paths; import java. ArrayList; import java. Matcher; import java. Pattern; import static java. If all the bytes are zero, out piece will be zero, and we get an exception! It cannot be encrypted.
Secret Sharing Explained Visually
We cannot predict the length of the encrypted result. A byte piece, when encrypted, can be , or or whatever bytes. This means our piece will never have zero bytes at start. Takes care of 1 and 2.
Divide and Manage Secret Data Securely With Shamir's Secret Sharing
From each, we read the first byte. That will give us sizes n1,n Consider using int or long where possible.
Because you already know the size, consider using normal arrays. Lists add a big overhead to your already big overhead of the BigIntegers. What's the difference?
The problem is that Lists create overhead by implementing various methods and, special for the ArrayList, need to recreate the backing array once it's not big enough. This means that you create a new array every time the old one has not enough capacity what uses much memory for long lists and consumes a good amount of time.
For reconstruction, you may regenerate the secret key and reconstruct the file using it. Shamir, in his original paper, " How to share a secret?
Shamir Secret Sharing Scheme
Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name.
Shamir secret sharing scheme pdf converter
Email Required, but never shown. How to create micro-interactions with react-spring: Part 1. This week, StackOverflowKnows syntactic sugar, overfit or nah, and the….
Featured on Meta.
Thank you, Shog9. Thank you, Robert Cartaino. Related 4. Hot Network Questions. Question feed.