List of usage examples for org.bouncycastle.asn1.x9 ECNamedCurveTable getByName
public static X9ECParameters getByName(String name)
From source file:com.github.horrorho.inflatabledonkey.crypto.ec.ECAssistant.java
License:Open Source License
public static X9ECParameters x9ECParameters(String curveName) { X9ECParameters x9ECParameters = ECNamedCurveTable.getByName(curveName); if (x9ECParameters == null) { throw new IllegalArgumentException("unsupported elliptic curve: " + curveName); }/* w ww. jav a 2 s . c om*/ return x9ECParameters; }
From source file:com.github.horrorho.inflatabledonkey.crypto.eckey.ECAssistant.java
License:Open Source License
public static X9ECParameters x9ECParameters(String curveName) { X9ECParameters x9ECParameters = ECNamedCurveTable.getByName(curveName); if (x9ECParameters == null) { throw new IllegalArgumentException("ec curve not found: " + curveName); }/*from w w w. ja v a 2s . c o m*/ return x9ECParameters; }
From source file:com.github.horrorho.inflatabledonkey.crypto.rfc6637.RFC6637.java
License:Open Source License
ECPoint decodePoint(byte[] data) { ECCurve curve = ECNamedCurveTable.getByName(curveName).getCurve(); int compactExportSize = (curve.getFieldSize() + 7) / 8; return data.length == compactExportSize ? ECPointsCompact.decodeFPPoint(curve, data) // Compact keys support, non RFC6636 compliant. : curve.decodePoint(data);//from ww w.jav a 2 s. c o m }
From source file:com.yahoo.athenz.zts.store.DataStore.java
License:Apache License
String getCurveName(org.bouncycastle.jce.spec.ECParameterSpec ecParameterSpec) { String curveName = null;// w ww. j av a2 s . co m for (Enumeration names = ECNamedCurveTable.getNames(); names.hasMoreElements();) { final String name = (String) names.nextElement(); final X9ECParameters params = ECNamedCurveTable.getByName(name); if (params.getN().equals(ecParameterSpec.getN()) && params.getH().equals(ecParameterSpec.getH()) && params.getCurve().equals(ecParameterSpec.getCurve()) && params.getG().equals(ecParameterSpec.getG())) { curveName = name; break; } } return curveName; }
From source file:org.cryptoworkshop.ximix.node.crypto.key.ECKeyPairGenerator.java
License:Apache License
public MessageReply handle(final KeyPairGenerateMessage message) { // TODO: sort out the reply messages try {/*from w w w .j ava2 s .c o m*/ switch (((Type) message.getType())) { case GENERATE: final NamedKeyGenParams ecKeyGenParams = (NamedKeyGenParams) NamedKeyGenParams .getInstance(message.getPayload()); final List<String> involvedPeers = ecKeyGenParams.getNodesToUse(); X9ECParameters params = CustomNamedCurves.getByName(ecKeyGenParams.getDomainParameters()); if (params == null) { params = ECNamedCurveTable.getByName(ecKeyGenParams.getDomainParameters()); } paramsMap.put(ecKeyGenParams.getKeyID(), new ECDomainParameters(params.getCurve(), params.getG(), params.getN(), params.getH(), params.getSeed())); sharedHMap.init(ecKeyGenParams.getKeyID(), involvedPeers.size()); BigInteger h = generateH(params.getN(), new SecureRandom()); // TODO: provide randomness? ECPoint[] messages = new ECPoint[involvedPeers.size()]; for (int i = 0; i != messages.length; i++) { messages[i] = params.getG().multiply(h); } nodeContext.execute( new SendHTask(message.getAlgorithm(), ecKeyGenParams.getKeyID(), involvedPeers, messages)); final List<String> peerList = ecKeyGenParams.getNodesToUse(); ECNewDKGGenerator generator = (ECNewDKGGenerator) nodeContext .getKeyPairGenerator(ecKeyGenParams.getAlgorithm()); ECCommittedSecretShareMessage[] comMessages = generator.generateThresholdKey( ecKeyGenParams.getKeyID(), paramsMap.get(ecKeyGenParams.getKeyID()), peerList.size(), ecKeyGenParams.getThreshold(), sharedHMap.getShare(ecKeyGenParams.getKeyID()).getValue().normalize()); nodeContext.execute(new SendShareTask(generator, message.getAlgorithm(), ecKeyGenParams.getKeyID(), peerList, comMessages)); return new MessageReply(MessageReply.Type.OKAY); case STORE_H: StoreMessage storeMessage = StoreMessage.getInstance(message.getPayload()); ShareMessage shareMessage = ShareMessage.getInstance(storeMessage.getSecretShareMessage()); nodeContext.execute(new StoreHTask(storeMessage.getID(), shareMessage)); return new MessageReply(MessageReply.Type.OKAY); case STORE: StoreMessage sssMessage = StoreMessage.getInstance(message.getPayload()); // we may not have been asked to generate our share yet, if this is the case we need to queue up our share requests // till we can validate them. generator = (ECNewDKGGenerator) nodeContext.getKeyPairGenerator(message.getAlgorithm()); nodeContext.execute( new StoreShareTask(generator, sssMessage.getID(), sssMessage.getSecretShareMessage())); return new MessageReply(MessageReply.Type.OKAY); default: return new MessageReply(MessageReply.Type.ERROR, new DERUTF8String("Unknown command in NodeKeyGenerationService.")); } } catch (Exception e) { nodeContext.getEventNotifier().notify(EventNotifier.Level.ERROR, "NodeKeyGenerationService failure: " + e.getMessage(), e); return new MessageReply(MessageReply.Type.ERROR, new DERUTF8String("NodeKeyGenerationService failure: " + e.getMessage())); } }