Examples of FullPolynomial


Examples of com.securityinnovation.jNeo.math.FullPolynomial

        // Sanity-check inputs
        if ((h.p.length != keyParams.N) || (f.p.length != keyParams.N))
          throw new IllegalArgumentException("exported key invalid");

        // Convert f to a packed F.
        FullPolynomial F = KeyFormatterUtil.recoverF(f);
        ByteArrayOutputStream os = new ByteArrayOutputStream((f.p.length+4)/5);
        MGF_TP_1.encodeTrinomial(F, os);
        byte encodedF[] = os.toByteArray();

        // Allocate output buffer
View Full Code Here

Examples of com.securityinnovation.jNeo.math.FullPolynomial

        if (headerLen + packedHLen + packedFLen != keyBlob.length)
          throw new IllegalArgumentException("key blob length invalid");

        // Recover h
        int offset = headerLen;
        FullPolynomial h = new FullPolynomial(keyParams.N);
        offset += BitPack.unpack(
            keyParams.N, keyParams.q, keyBlob, offset, h.p, 0);

        // Recover F
        ByteArrayInputStream is =
          new ByteArrayInputStream(keyBlob, offset, keyBlob.length-offset);
        FullPolynomial f = MGF_TP_1.genTrinomial(keyParams.N, is);

        // Compute f = 1+p*F
        for (int i=0; i<f.p.length; i++)
          f.p[i] *= keyParams.p;
        f.p[0]++;
View Full Code Here

Examples of com.securityinnovation.jNeo.math.FullPolynomial

        // Sanity-check inputs
        if ((h.p.length != keyParams.N) || (f.p.length != keyParams.N))
          return null;

        // Convert f to a listed F.
        FullPolynomial F = KeyFormatterUtil.recoverF(f);

        // Allocate output buffer
        int len = (KeyFormatterUtil.fillHeader(tag, keyParams.OIDBytes, null) +
                   BitPack.pack(keyParams.N, keyParams.q) +
                   BitPack.pack(2*keyParams.df, keyParams.N));
View Full Code Here

Examples of com.securityinnovation.jNeo.math.FullPolynomial

        if (headerLen + packedHLen + listedFLen != keyBlob.length)
          throw new IllegalArgumentException("blob length invalid");

        // Recover h
        int offset = headerLen;
        FullPolynomial h = new FullPolynomial(keyParams.N);
        offset += BitPack.unpack(
            keyParams.N, keyParams.q, keyBlob, offset, h.p, 0);

        // Recover F
        FullPolynomial f = new FullPolynomial(keyParams.N);
        offset += KeyFormatterUtil.unpackListedCoefficients(
            f, keyParams.N, keyParams.df, keyParams.df, keyBlob, offset);
        // Compute f = 1+p*F
        for (int i=0; i<f.p.length; i++)
          f.p[i] *= keyParams.p;
View Full Code Here

Examples of com.securityinnovation.jNeo.math.FullPolynomial

        throws NtruException
    {
        for (int t=0; t<tests.length; t++)
        {
            KeyParams keyParams = KeyParams.getKeyParams(tests[t].oid);
            FullPolynomial h = new FullPolynomial(tests[t].h);
           
            // Build a blob using the code being tested.
            PubKeyFormatter encoder = new PubKeyFormatter_PUBLIC_KEY_v1();
            byte pubBlob[] = encoder.encode(keyParams,h);
View Full Code Here

Examples of com.securityinnovation.jNeo.math.FullPolynomial

    // Put f into the appropriate range [-q/2..q/2)
    FullPolynomial recoverf(
        short fBytes[],
        int   q)
    {
        FullPolynomial f = new FullPolynomial(fBytes);
        // Put f into the appropriate range [-q/2..q/2)
        for (int i=0; i<f.p.length; i++)
          if (f.p[i] >= q/2)
            f.p[i] -= q;
        return f;
View Full Code Here

Examples of com.securityinnovation.jNeo.math.FullPolynomial

        throws NtruException
    {
        for (int t=0; t<tests.length; t++)
        {
            KeyParams keyParams = KeyParams.getKeyParams(tests[t].oid);
            FullPolynomial h = new FullPolynomial(tests[t].h);
            FullPolynomial f = recoverf(tests[t].f, keyParams.q);

            // Build the test blob
            PrivKeyFormatter encoder = new PrivKeyFormatter_PrivateKeyListedFv1();
            byte privBlob[] = encoder.encode(keyParams, h, f);
View Full Code Here

Examples of com.securityinnovation.jNeo.math.FullPolynomial

    }

    static FullPolynomial recoverF(
        FullPolynomial f)
    {
        FullPolynomial F = new FullPolynomial(f.p.length);
        F.p[0] = (short) ((f.p[0]-1) / 3);
        for (int i=1; i<f.p.length; i++)
          F.p[i] = (short) (f.p[i] / 3);
        return F;
    }
View Full Code Here

Examples of com.securityinnovation.jNeo.math.FullPolynomial

          throw new IllegalArgumentException(
              "Input public key blob is " + keyBlob.length + " bytes, not " +
              "the expected " + (headerLen + packedHLen));

        // Recover h
        FullPolynomial h = new FullPolynomial(keyParams.N);
        BitPack.unpack(keyParams.N, keyParams.q, keyBlob, headerLen, h.p, 0);

        // Return the key material
        return new RawKeyData(keyParams, h);
    }
View Full Code Here

Examples of com.securityinnovation.jNeo.math.FullPolynomial

        KeyParams keyParams = KeyParams.getKeyParams(oid);

        IGF2 igf = new IGF2(keyParams.N, keyParams.c, prng);

        // Generate trinomial g that is invertible
        FullPolynomial g = null;
        boolean gIsInvertible = false;
        while (!gIsInvertible)
        {
            g = BPGM3.genTrinomial(
                keyParams.N, keyParams.dg+1, keyParams.dg, igf);
            FullPolynomial gInv = keyParams.polyInverter.invert(g);
            gIsInvertible = (gInv != null);
        }

        // Create F, f=1+p*F, and f^-1 mod q
        FullPolynomial F = null, f = null, fInv = null;
        boolean fIsInvertible = false;
        while (!fIsInvertible)
        {
            // Generate random F
            F = BPGM3.genTrinomial(
                keyParams.N, keyParams.df, keyParams.df, igf);
           
            // Calculate f = 1+p*f
            f = new FullPolynomial(keyParams.N);
            for (int i=0; i<keyParams.N; i++)
              f.p[i] = (short) (keyParams.p*F.p[i]);
            f.p[0]++;

            // Compute f^-1 mod q. Check whether the operation succeeded.
            fInv = keyParams.polyInverter.invert(f);
            fIsInvertible = (fInv != null);
        }

        // Calculate h = f^-1 * g * p mod q
        FullPolynomial h = FullPolynomial.convolution(fInv, g);
        for (int i=0; i<h.p.length; i++)
        {
            h.p[i] = (short) ((h.p[i] * keyParams.p) % keyParams.q);
            if (h.p[i] < 0)
              h.p[i] += keyParams.q;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.