#include "mailaddress.wml"
#include "commontools.wml"
#use wml::std::grid
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>

<head>
<title>Multikey</title>
</head>

<body>
<div align="center"><img src="multikey.jpg"><BR><B>Multikey</B></div><P>

<hr noshade><P>

<megahref "multikey.tar.gz"><P>

<hr noshade><P>

download, unpack. run ./compile.sh<BR>
create a secret file.<P>
now with multikey you can create n files from which you must take
at least k files to reproduce the original secret file. (k&lt;n)
<P>

for example if you have an account number of a 100000$ account.
you store the account number in a file. the one who can read the file can
get the money. you have 10 persons. you want that if at least 3 of those persons
want to get the money, they can go to the bank and get the money.<BR>
with multikey you can create 10 files out of your account number file.
all of those files have absolutly no meaning. they are all like random data.
only if you have 3 arbitrary of those files, you will be able to reconstruct your account number.
<P>

<h1>How does multikey work?</h1>

multikey consists of several programs.

<h2>randsplit</h2>
randsplit takes a file with a size of n bits. it creates k files that are also
of size n bits. k-1 of the k files are pure random data. (the random data
get's created by linux /dev/urandom entropy generator. the security of multikey
bases on the security of randsplit which bases on the randomness of the entropy generator.
keep this in mind)
the last of the k files
is the original file bitwise XORed with the k-1 pure random data files.<BR>
so what you get is k files which are all like pure random data.<BR>
an example: if k=10 it does not matter if you have zero, one, two, ... , nine of
the 10 files, you always have pure random data. only if you have 10 of the files you get
the original.

<h2>randjoin</h2>
randjoin reverses the effect of randsplit. it takes k files of n bits size.
it creates one output file also of n bits size. each bit in the output file
is the XOR of the bits of the k input files.

<h2>redun</h2>
the idea of "redun" comes from the stone-age of computer science. in those days you used
floppy discs to carry data. often a single disc was too small. so it took let's say
10 discs to carry your data. you needed 2 hours to drive to your friend and give him
your data. if one disc got damaged, the 2 hours have been wasted. so what could you do?
carry 20 discs. then there are always 2 discs with the same data. but if just the right
two discs crashed that carried the same data, you where lost again. the idea of the
"redun" program is to take let's say 12 discs and then 2 ARBITRARY of the discs may
crash. you can also take 15 discs. then 5 ARBITRARY of the discs may crash and you still
have your original data.
<P>

you use redun like this:
create some files. (EQUALLY SIZED)
let'S say you created the files f1 f2 f4
now type
<PRE>
./redun f1 f2 f3 f4
</pre>
"redun" looks and sees f1,f2,f4 exist, so it will READ those files.
it sees that f3 does not exist, so it will WRITE this file.
the order of parameters is IMPORTANT and must keep always the same. if you mix
the keys to wrong positions in the parameter list, wrong results will be calculated.<BR>
now since we used 3 original files, we have only created one single redundancy file.
so let's delete one arbitrary of the files.
<PRE>
rm f1
</pre>
now let's reconstruct f1.
<PRE>
./redun f1 f2 f3 f4
</pre>
redun will see f2,f3,f4 exist, so it will READ those files.
it sees that f1 does not exist, so it will WRITE this file.
easy ain't it?
<P>

how this works is nothing magic and is based on old known facts in mathematics.
if you have a polynom of 9th degree, you need 10 points to fully specify it.
lets say the 10 discs give us the 10 points in the polynom. then we can calculate
other points in the polynom and store them on disc. now we can take an arbitrary set
of 10 points from disc and recalculate the polynom. that's all.
for calculating i use the GF&#40;2&#94;8&#41; system. because there we can always divide
without reminder. and we can use the bytes as y values in our polynom. so for every n-th
byte in the discs i create a polynom and calculate the other n-th bytes for the other discs.
if you need further information, don't try to understand my sourcecode ;) better read
some books.
<P>

as explained "redun" is nothing new, and indeed you find other programs that
do this job like <megahref "http://www.cleaton.net/ras/">.
<P>

<h1>makekeys.sh</h1>
makekeys.sh is just a rudimentary shell script that unites the above programs.
give it a secret file, it will first use "randsplit" to create n files. then it uses
"redun" to build additional redundancy files.

<h1>unlockdoor.sh</h1>
unlockdoor.sh is also just a rudimentary shell script that unites the above programs.
give it a set of keys and tell it how many keys you need at minimum. (giving the wrong
value here results in wrong results). it will first call "redun" to rebuild the needed
first n keys. then it uses "randjoin" to recalculate the original file.

<h1>show me an example</h1>

<PRE>
erik&#64;vulcain&#58;&#126;&#47;prj&#47;multikey&#47;multikey &#62; cat &#62;secret
I am very important secret file
erik&#64;vulcain&#58;&#126;&#47;prj&#47;multikey&#47;multikey &#62; &#46;&#47;makekeys&#46;sh 

Usage&#58; makekeys&#46;sh plainfile keyprefix numkeys numenoughkeys

Example&#58; makekeys&#46;sh plain key&#95; 10 7

erik&#64;vulcain&#58;&#126;&#47;prj&#47;multikey&#47;multikey &#62; &#46;&#47;makekeys&#46;sh secret key&#95; 5 2
Randomized splitting of your key into 2 keys&#46;
Building redundant additional 3 keys&#46;
all done&#46; you now have the keyfiles
key&#95;0 key&#95;1 key&#95;2 key&#95;3 key&#95;4
You only need 2 of those files to reconstruct your file &#34;secret&#34;

erik&#64;vulcain&#58;&#126;&#47;prj&#47;multikey&#47;multikey &#62; ls &#45;l key&#42;
&#45;rw&#45;r&#45;&#45;&#45;&#45;&#45;    1 erik     erik           32 Jan 24 20&#58;50 key&#95;0
&#45;rw&#45;r&#45;&#45;&#45;&#45;&#45;    1 erik     erik           32 Jan 24 20&#58;50 key&#95;1
&#45;rw&#45;r&#45;&#45;&#45;&#45;&#45;    1 erik     erik           32 Jan 24 20&#58;50 key&#95;2
&#45;rw&#45;r&#45;&#45;&#45;&#45;&#45;    1 erik     erik           32 Jan 24 20&#58;50 key&#95;3
&#45;rw&#45;r&#45;&#45;&#45;&#45;&#45;    1 erik     erik           32 Jan 24 20&#58;50 key&#95;4
erik&#64;vulcain&#58;&#126;&#47;prj&#47;multikey&#47;multikey &#62; rm key&#95;3 key&#95;0 key&#95;2
erik&#64;vulcain&#58;&#126;&#47;prj&#47;multikey&#47;multikey &#62; ls &#45;l key&#42;
&#45;rw&#45;r&#45;&#45;&#45;&#45;&#45;    1 erik     erik           32 Jan 24 20&#58;50 key&#95;1
&#45;rw&#45;r&#45;&#45;&#45;&#45;&#45;    1 erik     erik           32 Jan 24 20&#58;50 key&#95;4
erik&#64;vulcain&#58;&#126;&#47;prj&#47;multikey&#47;multikey &#62; &#46;&#47;unlockdoor&#46;sh 

Usage&#58; unlockdoor&#46;sh keyprefix outputsecret numenoughkeys

Example&#58; unlockdoor&#46;sh key&#95; mysecret 7

erik&#64;vulcain&#58;&#126;&#47;prj&#47;multikey&#47;multikey &#62; &#46;&#47;unlockdoor&#46;sh key&#95; output 2
i found 2 keyfiles&#46;
Thats enough keyfiles&#46; proceeding&#46;&#46;&#46;
Now rebuilding the eventually missing keys&#46;
Now reuniting the keys to get the secret file&#46;
all done&#46; you now have the secret file &#34;output&#34;

erik&#64;vulcain&#58;&#126;&#47;prj&#47;multikey&#47;multikey &#62; cat output 
I am very important secret file
erik&#64;vulcain&#58;&#126;&#47;prj&#47;multikey&#47;multikey &#62; 
</PRE>
<P>

<hr noshade>
<grid layout=2x1 align=lr width=100%>
<cell><clickableerikemail></cell> <cell><a href="../">back</a></cell>
</grid>

</body>

</html>
