Example usage for org.bouncycastle.crypto.params ECDomainParameters getH

List of usage examples for org.bouncycastle.crypto.params ECDomainParameters getH

Introduction

In this page you can find the example usage for org.bouncycastle.crypto.params ECDomainParameters getH.

Prototype

public BigInteger getH() 

Source Link

Usage

From source file:com.licel.jcardsim.crypto.ECKeyImpl.java

License:Apache License

/**
 * Set/*www.  jav  a 2  s .  c  om*/
 * <code>ECDomainParameters</code> for EC curve
 *
 * @param parameters
 * @see ECDomainParameters
 */
final void setDomainParameters(ECDomainParameters parameters) {
    a.setBigInteger(parameters.getCurve().getA().toBigInteger());
    b.setBigInteger(parameters.getCurve().getB().toBigInteger());
    // generator
    g.setBytes(parameters.getG().getEncoded());
    // order
    r.setBigInteger(parameters.getN());
    // cofactor
    setK(parameters.getH().shortValue());
    if (parameters.getCurve() instanceof ECCurve.Fp) {
        ECCurve.Fp ecfp = (ECCurve.Fp) parameters.getCurve();
        fp.setBigInteger(ecfp.getQ());
    } else {
        ECCurve.F2m ecf2m = (ECCurve.F2m) parameters.getCurve();
        setFieldF2M((short) ecf2m.getK1(), (short) ecf2m.getK2(), (short) ecf2m.getK3());
    }
}

From source file:dorkbox.util.crypto.CryptoECC.java

License:Apache License

public static boolean compare(ECPrivateKeyParameters privateA, ECPrivateKeyParameters privateB) {
    ECDomainParameters parametersA = privateA.getParameters();
    ECDomainParameters parametersB = privateB.getParameters();

    // is it the same curve?
    boolean equals = parametersA.getCurve().equals(parametersB.getCurve());
    if (!equals) {
        return false;
    }//from   www.  j a va2s .  c  om

    equals = parametersA.getG().equals(parametersB.getG());
    if (!equals) {
        return false;
    }

    equals = parametersA.getH().equals(parametersB.getH());
    if (!equals) {
        return false;
    }

    equals = parametersA.getN().equals(parametersB.getN());
    if (!equals) {
        return false;
    }

    equals = privateA.getD().equals(privateB.getD());

    return equals;
}

From source file:dorkbox.util.crypto.CryptoECC.java

License:Apache License

/**
 * @return true if publicA and publicB are NOT NULL, and are both equal to eachother
 *///  w  ww  . j a  v a2s. c om
@SuppressWarnings({ "RedundantIfStatement", "SpellCheckingInspection" })
public static boolean compare(ECPublicKeyParameters publicA, ECPublicKeyParameters publicB) {
    if (publicA == null || publicB == null) {
        return false;
    }

    ECDomainParameters parametersA = publicA.getParameters();
    ECDomainParameters parametersB = publicB.getParameters();

    // is it the same curve?
    boolean equals = parametersA.getCurve().equals(parametersB.getCurve());
    if (!equals) {
        return false;
    }

    equals = parametersA.getG().equals(parametersB.getG());
    if (!equals) {
        return false;
    }

    equals = parametersA.getH().equals(parametersB.getH());
    if (!equals) {
        return false;
    }

    equals = parametersA.getN().equals(parametersB.getN());
    if (!equals) {
        return false;
    }

    ECPoint normalizeA = publicA.getQ().normalize();
    ECPoint normalizeB = publicB.getQ().normalize();

    ECFieldElement xCoordA = normalizeA.getXCoord();
    ECFieldElement xCoordB = normalizeB.getXCoord();

    equals = xCoordA.equals(xCoordB);
    if (!equals) {
        return false;
    }

    ECFieldElement yCoordA = normalizeA.getYCoord();
    ECFieldElement yCoordB = normalizeB.getYCoord();

    equals = yCoordA.equals(yCoordB);
    if (!equals) {
        return false;
    }

    return true;
}

From source file:org.cryptacular.adapter.AbstractWrappedECKey.java

License:Open Source License

/** @return  EC domain parameters. */
public ECParameterSpec getParams() {
    final ECDomainParameters params = delegate.getParameters();
    return new ECParameterSpec(EC5Util.convertCurve(params.getCurve(), params.getSeed()),
            new ECPoint(params.getG().normalize().getXCoord().toBigInteger(),
                    params.getG().normalize().getYCoord().toBigInteger()),
            params.getN(), params.getH().intValue());
}

From source file:org.cryptoworkshop.ximix.client.verify.ECDecryptionChallengeVerifier.java

License:Apache License

private boolean isSameParameters(ECDomainParameters a, ECDomainParameters b) {
    return a.getCurve().equals(b.getCurve()) && a.getG().equals(b.getG()) && a.getH().equals(b.getH())
            && a.getN().equals(b.getN());
}