Java 8 EllipticCurve - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 EllipticCurve class.

This code example shows how to use the following methods:getA, getB, getField
       EllipticCurve curve, 
       byte[] encoded)
    { 
        ECCurve c = null;
         
        if (curve.getField() instanceof ECFieldFp)
        { 
            c = new ECCurve.Fp(
                    ((ECFieldFp)curve.getField()).getP(), curve.getA(), curve.getB());
        } 
        else 
        { 
            int k[] = ((ECFieldF2m)curve.getField()).getMidTermsOfReductionPolynomial();
             
            if (k.length == 3)
            { 
                c = new ECCurve.F2m(
                        ((ECFieldF2m)curve.getField()).getM(), k[2], k[1], k[0], curve.getA(), curve.getB());
            } 
            else 

7
CodeRank
This code example shows how to use the following methods:getA, getB, getField
    } 
 
    public static ECCurve convertCurve( 
        EllipticCurve ec)
    { 
        ECField field = ec.getField();
        BigInteger a = ec.getA();
        BigInteger b = ec.getB();
 
        if (field instanceof ECFieldFp)
        { 
            ECCurve.Fp curve = new ECCurve.Fp(((ECFieldFp)field).getP(), a, b);
 
            if (customCurves.containsKey(curve))
            { 
                return (ECCurve)customCurves.get(curve);
            } 
 
            return curve;
        } 
7
CodeRank
This code example shows how to use the following methods:getA, getB, getField
    } 
 
    public static ECCurve convertCurve( 
        EllipticCurve ec)
    { 
        ECField field = ec.getField();
        BigInteger a = ec.getA();
        BigInteger b = ec.getB();
 
        if (field instanceof ECFieldFp)
        { 
            return new ECCurve.Fp(((ECFieldFp)field).getP(), a, b);
        } 
        else 
        { 
            ECFieldF2m fieldF2m = (ECFieldF2m)field;
            int m = fieldF2m.getM();
            int ks[] = ECUtil.convertMidTerms(fieldF2m.getMidTermsOfReductionPolynomial());
            return new ECCurve.F2m(m, ks[0], ks[1], ks[2], a, b); 
        } 
6
CodeRank
This code example shows how to use the following methods:getA, getB, getField
       EllipticCurve curve, 
       byte[] encoded)
    { 
        ECCurve c = null;
         
        if (curve.getField() instanceof ECFieldFp)
        { 
            c = new ECCurve.Fp(
                    ((ECFieldFp)curve.getField()).getP(), curve.getA(), curve.getB());
        } 
        else 
        { 
            int k[] = ((ECFieldF2m)curve.getField()).getMidTermsOfReductionPolynomial();
             
            if (k.length == 3)
            { 
                c = new ECCurve.F2m(
                        ((ECFieldF2m)curve.getField()).getM(), k[2], k[1], k[0], curve.getA(), curve.getB());
            } 
            else 

6
CodeRank
This code example shows how to use the following methods:getA, getB, getField
    } 
 
    public static ECCurve convertCurve( 
        EllipticCurve ec)
    { 
        ECField field = ec.getField();
        BigInteger a = ec.getA();
        BigInteger b = ec.getB();
 
        if (field instanceof ECFieldFp)
        { 
            ECCurve.Fp curve = new ECCurve.Fp(((ECFieldFp)field).getP(), a, b);
 
            if (customCurves.containsKey(curve))
            { 
                return (ECCurve)customCurves.get(curve);
            } 
 
            return curve;
        } 
6
CodeRank
This code example shows how to use the following methods:getA, getB, getField
    } 
 
    public static ECCurve convertCurve( 
        EllipticCurve ec)
    { 
        ECField field = ec.getField();
        BigInteger a = ec.getA();
        BigInteger b = ec.getB();
 
        if (field instanceof ECFieldFp)
        { 
            return new ECCurve.Fp(((ECFieldFp)field).getP(), a, b);
        } 
        else 
        { 
            ECFieldF2m fieldF2m = (ECFieldF2m)field;
            int m = fieldF2m.getM();
            int ks[] = ECUtil.convertMidTerms(fieldF2m.getMidTermsOfReductionPolynomial());
            return new ECCurve.F2m(m, ks[0], ks[1], ks[2], a, b); 
        } 
6
CodeRank
This code example shows how to use the following methods:equals
                BigInteger.valueOf(19L),
                new byte[25]); 
        assertFalse(c1.equals(c2) || c2.equals(c1));
 
        // test case 6: not equal objects - one seed is null 
        c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
                BigInteger.ONE,
                BigInteger.valueOf(19L),
                null); 
        c2 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
                BigInteger.valueOf(1L),
                BigInteger.valueOf(19L),
                new byte[24]); 
        assertFalse(c1.equals(c2) || c2.equals(c1));
 
        // test case 7: not equal objects - field class 
        c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
                BigInteger.ONE,
                BigInteger.valueOf(19L),
                new byte[24]); 
5
CodeRank
This code example shows how to use the following methods:getA, getB, getField
    /** 
     * @tests java/security/spec/EllipticCurve#EllipticCurve(EcField,BigInteger,BigInteger) 
     */ 
    public final void testEllipticCurveECFieldBigIntegerBigInteger05() { 
        // Regression for Harmony-731 
        EllipticCurve ec = new EllipticCurve(new testECField(), BigInteger
                .valueOf(4L), BigInteger.ONE);
        assertEquals("incorrect a", ec.getA(), BigInteger.valueOf(4L));
        assertEquals("incorrect b", ec.getB(), BigInteger.ONE);
        assertEquals("incorrect size", ec.getField().getFieldSize(), 2);
    } 
 
    /** 
     * Test for <code>getB()</code> method<br> 
     * Assertion: returns coefficient <code>b</code><br> 
     * Test preconditions: <code>ECFieldF2m</code> instance 
     * created using valid parameters<br> 
     * Expected: must return coefficient <code>b</code> which is equal 
     * to the one passed to the constructor; (both must refer 
     * the same object) 
5
CodeRank
This code example shows how to use the following methods:
            } 
            else 
            { 
                ks = new int[] { curveF2m.getK3(), curveF2m.getK2(), curveF2m.getK1() };
 
                return new EllipticCurve(new ECFieldF2m(curveF2m.getM(), ks), curve.getA().toBigInteger(), curve.getB().toBigInteger(), seed);
            }  
        } 
 
    } 
     
    private static ECPoint convertPoint(
        org.bouncycastle.math.ec.ECPoint  g)
    { 
        g = g.normalize();
        return new ECPoint(g.getAffineXCoord().toBigInteger(), g.getAffineYCoord().toBigInteger());
    } 
     
    public ECNamedCurveSpec( 
        String                              name,
5
CodeRank
This code example shows how to use the following methods:
        X9ECParameters x9ECParameters = NISTNamedCurves.getByName("P-192");
        ECCurve curve = x9ECParameters.getCurve();
 
        ECPrivateKeySpec privKeySpec = new ECPrivateKeySpec(new BigInteger("6FAB034934E4C0FC9AE67F5B5659A9D7D1FEFD187EE09FD4", 16),
            new ECParameterSpec(
                new EllipticCurve(new ECFieldFp(((ECCurve.Fp)curve).getQ()), curve.getA().toBigInteger(), curve.getB().toBigInteger(), null),
                new ECPoint(x9ECParameters.getG().getXCoord().toBigInteger(), x9ECParameters.getG().getYCoord().toBigInteger()),
                x9ECParameters.getN(), x9ECParameters.getH().intValue())
            ); 
 
        KeyFactory keyFact = KeyFactory.getInstance("ECDSA", "BC");
 
        PrivateKey privKey = keyFact.generatePrivate(privKeySpec);
 
        doTestHMACDetECDSASample("SHA1withDETECDSA", privKey,   new BigInteger("98C6BD12B23EAF5E2A2045132086BE3EB8EBD62ABF6698FF", 16), new BigInteger("57A22B07DEA9530F8DE9471B1DC6624472E8E2844BC25B64", 16));
        doTestHMACDetECDSASample("SHA224withDETECDSA", privKey, new BigInteger("A1F00DAD97AEEC91C95585F36200C65F3C01812AA60378F5", 16), new BigInteger("E07EC1304C7C6C9DEBBE980B9692668F81D4DE7922A0F97A", 16));
        doTestHMACDetECDSASample("SHA256withDETECDSA", privKey, new BigInteger("4B0B8CE98A92866A2820E20AA6B75B56382E0F9BFD5ECB55", 16), new BigInteger("CCDB006926EA9565CBADC840829D8C384E06DE1F1E381B85", 16));
        doTestHMACDetECDSASample("SHA384withDETECDSA", privKey, new BigInteger("DA63BF0B9ABCF948FBB1E9167F136145F7A20426DCC287D5", 16), new BigInteger("C3AA2C960972BD7A2003A57E1C4C77F0578F8AE95E31EC5E", 16));
        doTestHMACDetECDSASample("SHA512withDETECDSA", privKey, new BigInteger("4D60C5AB1996BD848343B31C00850205E2EA6922DAC2E4B8", 16), new BigInteger("3F6E837448F027A1BF4B34E796E32A811CBB4050908D8F67", 16));
 
5
CodeRank
See Code Examples for Java 8 EllipticCurve Methods: