Couple Things I've Learned
I just completed my research project my professor had given me to work on. I am very happy that it is finally done, and I feel I have learned quite a bit from the experience. This was the first project I had done that was outside of standard school assignments or for my own interest so I am proud to get that under my belt. I think I leveled up.
If you are curious as to what the encrypted data is like compared to the original here is a sample pdf file I made to use as a test, and a 'share' that was generated from it:
Here are a couple things that I think are important that I learned that I feel need to be shared or written down for my own benefit:
Comment your own code often and clearly
I thought I did this well, or at least thoroughly enough that I would not run into any issues during the project, but I was wrong. A majority of the time I was working on this I was in school, so while I didn't work on it enough as I would have liked, it was easy to pick up and go whenever I could. However in April I ran into exam crunch time and almost a month had passed between time that I worked on this project. Needless to say there was quite a few WTF moments as I looked over my code for errors or tweaking sections of it and what not and most of my comments made little sense to me. commenting often is not always enough to get by, being CLEAR in your comments is equally, if not more important. Just because you can easily understand a block of code one day does not mean it will as easy in a week or two.
Make sure you understand someone else's code well before using it
I was given some code to use as a base for my project for which I am thankful for. However I learned that its not all benefit when dealing with other peoples code. One issue is like I mentioned previously, if their comments are not clear, you are going to have a tough time understanding whats going on or how they are going about doing it. The person who had written the code used lots of abbreviations with variable names, which is fine since I know the code worked, but in many cases when I was trying to track down bugs and had to step through the code, looking at variable names such as MI and pt are kind of a pain in the ass.
Taking a step back can help
Some times I found myself working on this project for hours straight and would get hung up on a bug or ironing out a certain method. I usually found that taking a small break 15-20 minutes helped me immensely with completing tasks or finding a bug with a fresh eyes.
Finally...test,test,test and then retest twice
I ran into a bug that I had created early, but did not come across until months later and the day before I was giving my professor a demo(Yikes!). If you have read my earlier post, I had mentioned that my project involves Secret Sharing and encrypting data in pdf files. Anyway when I was originally testing my code, I was just using text documents as it was quicker and easier to do. The problem was that shares were created were stored in variables and then reconstructed into a text document. That all worked perfectly fine. So I then moved onto doing the same with pdf files, where my share files would be outputted to pdf files this time, and then I would select which ones I wished to use, read them back into my program and then reconstruct my original document. The problem that I ran into was that reconstruction of my secret only worked if I used shares 1,2 and 3, any other combination would result in gibberish. It didn't make any sense! I went back over to my tests with tests and the code was the same, I would add the shares, and then it would produce the correct secret values regardless of what combinations of shares I used. I was baffled. I was beating my head trying to figure out the problem, my assumptions were that there was an issue reading/writing pdf documents that I did not know about, and spent hours trying to pin point it. Needless to say I came up empty handed. Finally one night when I was losing sleep over this problem, it just popped into my head: The share objects from my text documents were just being directly passed into the object that would handle reconstruction, however in the case of the pdf documents, I had to create new share objects, fill them with the content of the pdf 'shares' and then add them to the reconstruction object. The key issue here is that since they are new share objects, their share numbers were being defaulted to 1,2 and 3, when in reality they should have been any combination of 1 to 5. Without getting into details on reconstruction, the share number is equally as important as the share content in reconstruction and since I was not giving the shares the correct number, this resulted in an error if Shares 4 and/or 5 were being used. In conclusion, since the text document code worked with any combo of shares, I had wrongly assumed the same was true for the pdf shares and simply always used shares 1,2,3 when running my program and continuously over looked such a serious flaw!
These were just a few 'gotcha!' moments that I had over the course of this project, If you have any yourself you wish to share please do so!