List of usage examples for org.bouncycastle.crypto.params ECDomainParameters getG
public ECPoint getG()
From source file:com.licel.jcardsim.crypto.ECKeyImpl.java
License:Apache License
/** * Set/* www.j a va 2 s . c o m*/ * <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 ww w . j a v a2s . co m*/ 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 *///from w ww. jav a 2 s .com @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:dorkbox.util.serialization.EccPrivateKeySerializer.java
License:Apache License
public static void write(Output output, ECPrivateKeyParameters key) throws KryoException { byte[] bytes; int length;//from w w w . ja v a2 s.c o m ECDomainParameters parameters = key.getParameters(); ECCurve curve = parameters.getCurve(); EccPrivateKeySerializer.serializeCurve(output, curve); ///////////// BigInteger n = parameters.getN(); ECPoint g = parameters.getG(); ///////////// bytes = n.toByteArray(); length = bytes.length; output.writeInt(length, true); output.writeBytes(bytes, 0, length); serializeECPoint(g, output); ///////////// bytes = key.getD().toByteArray(); length = bytes.length; output.writeInt(length, true); output.writeBytes(bytes, 0, length); }
From source file:dorkbox.util.serialization.EccPublicKeySerializer.java
License:Apache License
public static void write(Output output, ECPublicKeyParameters key) throws KryoException { byte[] bytes; int length;//from www . j a va 2 s.com ECDomainParameters parameters = key.getParameters(); ECCurve curve = parameters.getCurve(); EccPrivateKeySerializer.serializeCurve(output, curve); ///////////// BigInteger n = parameters.getN(); ECPoint g = parameters.getG(); ///////////// bytes = n.toByteArray(); length = bytes.length; output.writeInt(length, true); output.writeBytes(bytes, 0, length); EccPrivateKeySerializer.serializeECPoint(g, output); EccPrivateKeySerializer.serializeECPoint(key.getQ(), output); }
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()); }
From source file:org.cryptoworkshop.ximix.common.crypto.threshold.ECCommittedSecretShare.java
License:Apache License
/** * Return true if the share value is revealed by the commitment we carry, false otherwise. * * @param shareNumber the number of this share. * @param domainParams the domain parameters of the curve we expect to be on. * @param hValue the value of h used to commit against. * @return true if share is revealed by commitment, false otherwise. *///from w w w . j ava 2 s . com public boolean isRevealed(int shareNumber, ECDomainParameters domainParams, ECPoint hValue) { return getCommitment(shareNumber).equals(domainParams.getG().multiply(share).add(hValue.multiply(witness))); }
From source file:org.cryptoworkshop.ximix.demo.admin.Main.java
License:Apache License
private static ECPoint generatePoint(ECDomainParameters params, SecureRandom rand) { return params.getG().multiply(getRandomInteger(params.getN(), rand)); }
From source file:org.cryptoworkshop.ximix.demo.ballot.Main.java
License:Apache License
private static ECPoint generatePoint(ECDomainParameters params, SecureRandom rand) { return params.getG().multiply(getRandomInteger(params.getN(), rand)).normalize(); }