2004-07-06 20:39:18 +00:00
|
|
|
<h1>jbigi</h1>
|
|
|
|
<p>Using JNI (Java Native Interface), a bit of C code
|
|
|
|
(thanks <a href="/user/view/8?PHPSESSID=8efeebc6ed1c132cdcb12821e7ab4a27">ughabugha</a>!), a little manual work and
|
|
|
|
a piece of chewinggum it is possible to make the public key cryptography
|
|
|
|
quite a bit faster.</p>
|
|
|
|
|
|
|
|
|
|
|
|
<h2>Requirements</h2>
|
|
|
|
<p>This works on Linux, and with a few changes in build.sh probably also on other
|
|
|
|
platforms. FreeBSD has also been reported to work too. On Kaffee the speedup is very
|
|
|
|
small, because it already uses native BitInteger internally. Blackdown seems to cause
|
|
|
|
strange errors. Because you are going to do compilation, you need JDK; JRE won't work.</p>
|
|
|
|
|
|
|
|
<p>The required code is available in CVS and the latest source tarball.</p>
|
|
|
|
|
|
|
|
<p>The GNU MP Bignum library (libgmp) needs to be installed, if it isn't included in
|
|
|
|
your OS / distribution or installed already, it can be received from
|
|
|
|
<a href="http://www.swox.com/gmp/">http://www.swox.com/gmp/</a>. Even if you have already
|
|
|
|
installed it as binary, it might still be worth a try to compile GMP yourself, since then
|
|
|
|
it will be able to use the specific instructions of your processor.</p>
|
|
|
|
|
|
|
|
<h2>Step-by-step instructions</h2>
|
|
|
|
<ol>
|
|
|
|
<li>Look on <a href="http://localhost:7655/routerStats.html">http://localhost:7655/routerStats.html</a>
|
|
|
|
to see what the values for <code>crypto.elGamal.decrypt</code> and <code>crypto.elGamal.encrypt</code> are.
|
|
|
|
Copy this somewhere so you can compare it later on.</li>
|
|
|
|
|
|
|
|
<li>Get the latest sourcecode</li>
|
|
|
|
<li>Inside the source tree change directory to: <code>core/c</code></li>
|
|
|
|
<li>Take a look at <code>build.sh</code>, if your <code>JAVA_HOME</code> environment variable is set and
|
|
|
|
you are using Linux then it might just work. Otherwise change the settings.</li>
|
|
|
|
<li>Run <code>build.sh</code><br/>
|
|
|
|
A file named <code>libjbigi.so</code> should be created in the current directory.
|
|
|
|
If this doesn't happen and/or you get errors then please report them.<br/>
|
|
|
|
|
|
|
|
Also some tests are done. Read the final lines of output for some additional
|
|
|
|
info, it will be something like this:
|
|
|
|
<pre>
|
|
|
|
native run time: 5842ms ( 57ms each)
|
|
|
|
java run time: 41072ms (406ms each)
|
|
|
|
native = 14.223802103622907% of pure java time
|
|
|
|
</pre>
|
|
|
|
If the native is indeed 5-7x faster then it looks all good. If not, please report.</li>
|
|
|
|
|
2004-07-06 21:38:20 +00:00
|
|
|
<li>Copy <code>libjbigi.so</code> to your i2p directory</li>
|
|
|
|
<li>Restart your I2P programs.</li>
|
2004-07-06 20:39:18 +00:00
|
|
|
|
|
|
|
<li>On <a href="http://localhost:7655/routerStats.html">http://localhost:7655/routerStats.html</a>
|
|
|
|
the <code>crypto.elGamal.decrypt</code> and <code>crypto.elGamal.encrypt</code> should be a lot faster.</li>
|
|
|
|
</ol>
|
|
|
|
|
|
|
|
<p>Feedback is appreciated</p>
|