Package org.rabinfingerprint.polynomial

Examples of org.rabinfingerprint.polynomial.Polynomial


   * be xor'red with the fingerprint in the inner loop of our own
   * {@link #pushByte} and {@link #popByte}
   */
  private void precomputePushTable() {
    for (int i = 0; i < 512; i++) {
      Polynomial f = Polynomial.createFromLong(i);
      f = f.shiftLeft(poly.degree());
      f = f.xor(f.mod(poly));
      pushTable[i] = f.toBigInteger().longValue();
    }
  }
View Full Code Here


import org.rabinfingerprint.handprint.Handprints.HandPrintFactory;
import org.rabinfingerprint.polynomial.Polynomial;

public class HandprintTest extends TestCase {
  public void testChunkingFiles() throws IOException {
    Polynomial p = Polynomial.createIrreducible(53);
   
    List<InputStream> sims = TestDataGenerator.getSimilarRandomBytes(4);
    HandPrintFactory factory = Handprints.newFactory(p);
    Handprint hand1 = factory.newHandprint(sims.get(0));
    Handprint hand2 = factory.newHandprint(sims.get(1));
View Full Code Here

   *
   * The polys used are from here:
   * http://en.wikipedia.org/wiki/Finite_field_arithmetic#Rijndael.27s_finite_field
   */
  public void testPolynomialArithmetic() {
    Polynomial pa = Polynomial.createFromLong(0x53);
    Polynomial pb = Polynomial.createFromLong(0xCA);
    Polynomial pm = Polynomial.createFromLong(0x11B);
    Polynomial px = pa.multiply(pb);
    assertEquals(0x3F7E, px.toBigInteger().longValue());
    Polynomial pabm = px.mod(pm);
    assertEquals(0x1, pabm.toBigInteger().longValue());
  }
View Full Code Here

  public Stats getSpread(int degree, int tests) {
    int i = 0;
    int last_i = 0;
    Stats stats = new Stats();
    while (tests > 0) {
      Polynomial f = Polynomial.createRandom(degree);
      Reducibility r = f.getReducibility();
      if (r == Reducibility.IRREDUCIBLE) {
        int spread = i - last_i;
        stats.add(spread);
        last_i = i;
        tests--;
View Full Code Here

    byte[] data = new byte[1024];
    Random random = new Random(System.currentTimeMillis());
    random.nextBytes(data);

    // generate random irreducible polynomial
    Polynomial p = Polynomial.createIrreducible(53);
    final Fingerprint<Polynomial> rabin0 = new RabinFingerprintPolynomial(p);
    final Fingerprint<Polynomial> rabin1 = new RabinFingerprintLong(p);
    rabin0.pushBytes(data);
    rabin1.pushBytes(data);
    assertEquals(0, rabin0.getFingerprint().compareTo(rabin1.getFingerprint()));
View Full Code Here

    Random random = new Random(System.currentTimeMillis());
    int windowSize = 8;
   
    for (int i = 0; i < times; i++) {
      // Generate Random Irreducible Polynomial
      Polynomial p = Polynomial.createIrreducible(53);

      final Fingerprint<Polynomial> rabin0, rabin1;
      if (usePolynomials) {
        rabin0 = new RabinFingerprintPolynomial(p, windowSize);
        rabin1 = new RabinFingerprintPolynomial(p);
View Full Code Here

TOP

Related Classes of org.rabinfingerprint.polynomial.Polynomial

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.