Files
i2p.www/www.i2p2/pages/jbigi.html

86 lines
4.4 KiB
HTML
Raw Normal View History

2008-01-31 20:38:37 +00:00
{% extends "_layout.html" %}
{% block title %}jbigi{% endblock %}
{% block content %}<p>Using JNI (Java Native Interface), a bit of C code (thanks ugha!), a little
2004-07-12 10:24:00 +00:00
manual work and a piece of chewinggum it is possible to make the public key
cryptography quite a bit faster.</p>
2004-07-06 20:39:18 +00:00
<h2>Requirements</h2>
2004-07-12 10:24:00 +00:00
<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>
2008-07-23 19:56:53 +00:00
<p>The required code is available in monotone database and the latest source tarball.</p>
2004-07-12 10:24:00 +00:00
<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
2008-07-23 19:56:53 +00:00
<a href="http://gmplib.org/#DOWNLOAD">http://gmplib.org/#DOWNLOAD</a>. Even if you
2004-07-12 10:24:00 +00:00
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
2008-02-27 21:10:19 +00:00
your processor. The latest GMP 4.2.2 is also
possible to be used instead of GMP 4.1.4. But latest GMP 4.2.2 needs more
testing before setting the default requirement for building jbigi.jar.</p>
2004-07-06 20:39:18 +00:00
<h2>Step-by-step instructions</h2>
<ol>
2008-04-01 14:56:49 +00:00
<li>Look at <a href="http://localhost:7657/logs.jsp">your wrapper logs</a>,
at the point where I2P first starts. There should be one of two messages - either
<tt>
INFO: Locally optimized native BigInteger loaded from the library path
</tt>
or
<tt>
INFO: Native BigInteger library jbigi not loaded - using pure java</tt>.
If the native BitInteger library was NOT loaded, you definitely need to
compile your own.
Certain platforms, such as OS X, OpenSolaris, and 64-bit systems,
may require you to compile your own library.
If the BigInteger library was loaded, do at least the next step to see
what your performance is.
</li>
<li>Look on <a href="http://localhost:7657/oldstats.jsp">http://localhost:7657/oldstats.jsp</a>
2008-04-01 14:56:49 +00:00
to see what the lifetime average values for <code>crypto.elGamal.decrypt</code> and
<code>crypto.elGamal.encrypt</code> are. The numbers are times in milliseconds. Copy these somewhere so you can compare
2008-04-01 14:56:49 +00:00
them later on.
The network average for encrypt time is about 20ms.
If your encrypt time is less than 50ms for a relatively new processor, or less than 100ms
for an older processor, and the native BigInteger library was loaded, you are probably fine.
</li>
<li>Get the latest released sourcecode of I2P from
<a href="download.html">the download page</a>, or get the cutting-edge source
out of the monotone database mtn.i2p2.de</li>
2008-07-23 19:56:53 +00:00
<li>Inside the source tree change directory to: <code>core/c/jbigi</code></li>
2008-04-01 14:56:49 +00:00
<li>Read the README file. You must download GMP version 4.2.2 from
2008-07-23 19:56:53 +00:00
from <a href="http://gmplib.org/#DOWNLOAD">http://gmplib.org/#DOWNLOAD</a>, saving it to gmp-4.2.2.tar.bz2.
2004-07-12 10:24:00 +00:00
<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>
2004-07-06 20:39:18 +00:00
<li>Run <code>build.sh</code><br/>
2008-07-23 19:56:53 +00:00
Maybe the built spew out some errors of missing jni.h and jni_md.h files.
Easy solution is to copy these files from your java install into the core/c/jbigi/jbigi/include/ directory.</br>
You can run the <code>build.sh</code> from the <code>core/c/</code> directory which will
build all available jbigi libs into a jbigi.jar.</br>
2004-07-12 10:24:00 +00:00
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
2008-04-01 21:16:31 +00:00
them.</li>
<li>Follow the instructions in core/c/README to install the library and run
the speed test.
Read the final lines of the speed test's output for some additional
2004-07-06 20:39:18 +00:00
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>
2008-04-01 21:16:31 +00:00
If the native is indeed 5-7x faster (or more) then it looks all good. If not, please
2004-07-12 10:24:00 +00:00
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-12 10:24:00 +00:00
<li>On
2008-02-27 21:10:19 +00:00
<a href="http://localhost:7657/oldstats.jsp">http://localhost:7657/oldstats.jsp</a>
2004-07-12 10:24:00 +00:00
the <code>crypto.elGamal.decrypt</code> and <code>crypto.elGamal.encrypt</code>
should be a lot faster.</li>
2004-07-06 20:39:18 +00:00
</ol>
<p>Feedback is appreciated</p>
{% endblock %}