List of usage examples for org.bouncycastle.crypto.agreement ECDHBasicAgreement calculateAgreement
public BigInteger calculateAgreement(CipherParameters pubKey)
From source file:card.CardClient.java
License:Open Source License
/** * Get an attribute from the card//from w w w . j a v a 2 s.co m * * @param i Index of the attribute. * @return Blinded public key, blinded attribute signature and the attribute */ public BigInteger[] getAttribute(byte id, ECPoint nonce) { BigInteger[] result = new BigInteger[3]; int i = 0; while (i < attribute.length && attribute_id[i] != id) i++; if (i >= attribute.length || attribute_id[i] != id) { return null; } result[ATTRIBUTE] = attribute[i]; // generate a blinding factor b blinder = (ECPrivateKey) keyGen.generateKeyPair().getPrivate(); // blind public key, attribute signature and signed nonce try { ECDHBasicAgreement agreement = new ECDHBasicAgreement(); agreement.init(new ECPrivateKeyParameters(blinder.getD(), ecDom)); result[BLINDED_KEY] = agreement .calculateAgreement(new ECPublicKeyParameters(((ECPublicKey) keys.getPublic()).getQ(), ecDom)); result[BLINDED_SIGNATURE] = agreement .calculateAgreement(new ECPublicKeyParameters(signature[i], ecDom)); result[SIGNED_NONCE] = agreement.calculateAgreement( new ECPublicKeyParameters(nonce.multiply(((ECPrivateKey) keys.getPrivate()).getD()), ecDom)); } catch (Exception e) { e.printStackTrace(); } // return blinded public key, blinded attribute signature, blinded signed nonce, attribute return result; }
From source file:org.fdroid.enigtext.crypto.KeyUtil.java
License:Open Source License
public static BigInteger calculateAgreement(ECDHBasicAgreement agreement, ECPublicKeyParameters remoteKey) { synchronized (curve) { return agreement.calculateAgreement(remoteKey); }//w ww . j a v a 2s . co m }