本文整理汇总了Java中it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory.getPairing方法的典型用法代码示例。如果您正苦于以下问题:Java PairingFactory.getPairing方法的具体用法?Java PairingFactory.getPairing怎么用?Java PairingFactory.getPairing使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory
的用法示例。
在下文中一共展示了PairingFactory.getPairing方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: BLSCommittedSecretShareMessage
import it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory; //导入方法依赖的package包/类
private BLSCommittedSecretShareMessage(BLS01Parameters blsParameters, ASN1Sequence seq)
{
this.index = ASN1Integer.getInstance(seq.getObjectAt(0)).getValue().intValue();
this.value = ASN1Integer.getInstance(seq.getObjectAt(1)).getValue();
this.witness = ASN1Integer.getInstance(seq.getObjectAt(2)).getValue();
ASN1Sequence s = ASN1Sequence.getInstance(seq.getObjectAt(3));
this.commitmentFactors = new Element[s.size()];
for (int i = 0; i != commitmentFactors.length; i++)
{
commitmentFactors[i] = blsParameters.getG().duplicate();
commitmentFactors[i].setFromBytes(DEROctetString.getInstance(s.getObjectAt(i)).getOctets());
}
Pairing pairing = PairingFactory.getPairing(blsParameters.getCurveParameters());
this.pK = pairing.getG2().newElement();
this.pK.setFromBytes(DEROctetString.getInstance(seq.getObjectAt(4)).getOctets());
}
示例2: initialize
import it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory; //导入方法依赖的package包/类
@Override
public void initialize() {
if (forEncryption) {
if (!(key instanceof FEEncryptionParameters))
throw new IllegalArgumentException("FEEncryptionParameters are required for encryption.");
} else {
if (!(key instanceof IPLOSTW10SecretKeyParameters))
throw new IllegalArgumentException("IPLOSTW10SecretKeyParameters are required for decryption.");
}
IPLOSTW10KeyParameters ipKey = (IPLOSTW10KeyParameters) key;
this.n = ipKey.getParameters().getN();
int N = (2 * n + 3);
this.pairing = PairingFactory.getPairing(ipKey.getParameters().getParameters());
this.productPairing = new ProductPairing(null, pairing, N);
this.keyBytes = pairing.getGT().getLengthInBytes();
this.outBytes = 2 * pairing.getGT().getLengthInBytes() + N * pairing.getG1().getLengthInBytes();
}
示例3: fetchPartialPublicKey
import it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory; //导入方法依赖的package包/类
@Override
public PartialPublicKeyInfo fetchPartialPublicKey(String keyID)
throws IOException
{
if (sharedPrivateKeyMap.containsKey(keyID))
{
BLS01Parameters params = paramsMap.get(keyID);
Share<BigInteger> share = sharedPrivateKeyMap.getShare(keyID, TIME_OUT, TimeUnit.SECONDS);
Pairing pairing = PairingFactory.getPairing(params.getCurveParameters());
Element g = params.getG();
// calculate the public key
Element sk = pairing.getZr().newElement(share.getValue());
Element pk = g.powZn(sk);
return new PartialPublicKeyInfo(share.getSequenceNo(), SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo(new BLS01PublicKeyParameters(params, pk.getImmutable())));
}
return null;
}
示例4: unserializeBswabePub
import it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory; //导入方法依赖的package包/类
public static BswabePub unserializeBswabePub(byte[] b) {
BswabePub pub;
int offset;
pub = new BswabePub();
offset = 0;
StringBuffer sb = new StringBuffer("");
offset = unserializeString(b, offset, sb);
pub.pairingDesc = sb.substring(0);
PropertiesParameters params = new PropertiesParameters()
.load(new ByteArrayInputStream(pub.pairingDesc.getBytes()));
pub.p = PairingFactory.getPairing(params);
// pub.p=PairingFactory.getPairing("params/curves/a.properties");
Pairing pairing = pub.p;
pub.g = pairing.getG1().newElement();
pub.h = pairing.getG1().newElement();
pub.gp = pairing.getG2().newElement();
pub.g_hat_alpha = pairing.getGT().newElement();
offset = unserializeElement(b, offset, pub.g);
offset = unserializeElement(b, offset, pub.h);
offset = unserializeElement(b, offset, pub.gp);
offset = unserializeElement(b, offset, pub.g_hat_alpha);
return pub;
}
示例5: getPairing
import it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory; //导入方法依赖的package包/类
public Pairing getPairing() {
if (p == null) {
PairingParameters params = new PropertiesParameters().load(new ByteArrayInputStream(pairingDesc.getBytes()));
p = PairingFactory.getPairing(params);
}
return p;
}
示例6: generateSig
import it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory; //导入方法依赖的package包/类
public MessageReply generateSig(SignatureCreateMessage blsCreate)
throws ServiceConnectionException, IOException
{
Participant[] participants = new Participant[blsCreate.getNodesToUse().size()];
int index = 0;
for (String name : blsCreate.getNodesToUse())
{
MessageReply seqRep = sendMessage(name, Type.FETCH_SEQUENCE_NO, new KeyIDMessage(blsCreate.getKeyID()));
// TODO: need to drop out people who don't reply.
participants[index] = new Participant(BigIntegerMessage.getInstance(seqRep.getPayload()).getValue().intValue(), name);
index++;
}
FetchPublicKeyMessage fetchMessage = new FetchPublicKeyMessage(blsCreate.getKeyID());
MessageReply reply = connection.sendMessage(ClientMessage.Type.FETCH_PUBLIC_KEY, fetchMessage);
SubjectPublicKeyInfo pubKeyInfo = SubjectPublicKeyInfo.getInstance(reply.getPayload());
BLS01Parameters domainParams = BLSPublicKeyFactory.createKey(pubKeyInfo).getParameters();
Pairing pairing = PairingFactory.getPairing(domainParams.getCurveParameters());
byte[] hash = blsCreate.getMessage();
Element h = pairing.getG1().newElement().setFromHash(hash, 0, hash.length);
// TODO: need to take into account node failure during startup.
Element signature = accumulateElement(participants, Type.PRIVATE_KEY_SIGN, new BLSPartialCreateMessage(blsCreate.getKeyID(), h, participants), pairing, pairing.getZr().getOrder());
signature = signature.powZn(pairing.getZr().newOneElement());
return new MessageReply(MessageReply.Type.OKAY, new DEROctetString(signature.toBytes()));
}
示例7: createKey
import it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory; //导入方法依赖的package包/类
/**
* Create BLS01PublicKeyParameters from an ASN.1 encoding of a SubjectPublicKeyInfo object.
*
* @param publicKeyInfo the info structure containing the BLS public key.
* @return a BLS public key.
*/
public static BLS01PublicKeyParameters createKey(SubjectPublicKeyInfo publicKeyInfo)
{
AlgorithmIdentifier algId = publicKeyInfo.getAlgorithm();
CurveParameters curveParameters;
Element G;
Pairing pairing;
try
{
ASN1Sequence parameters = ASN1Sequence.getInstance(algId.getParameters());
curveParameters = new DefaultCurveParameters().load(new ByteArrayInputStream(DERUTF8String.getInstance(parameters.getObjectAt(0)).getString().getBytes("UTF8")));
pairing = PairingFactory.getPairing(curveParameters);
G = pairing.getG2().newElement();
G.setFromBytes(DEROctetString.getInstance(parameters.getObjectAt(1)).getOctets());
}
catch (IOException e)
{
throw new IllegalStateException("Unable to support encoding: " + e.getMessage(), e);
}
BLS01Parameters blsParameters = new BLS01Parameters(curveParameters, G.getImmutable());
Element pK = pairing.getG2().newElement();
pK.setFromBytes(publicKeyInfo.getPublicKeyData().getBytes());
return new BLS01PublicKeyParameters(blsParameters, pK.getImmutable());
}
示例8: loadQueryKey
import it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory; //导入方法依赖的package包/类
@Override
public CipherParameters loadQueryKey(String queryKeyPath) {
Path secretKeyPath = Paths.get(queryKeyPath);
Path path = Paths.get(getKeyPath(),
"pairing.properties");
byte[] data;
try {
data = Files.readAllBytes(path);
PairingParameters params = new PropertiesParameters()
.load(new ByteArrayInputStream(data));
Pairing p = PairingFactory.getPairing(params);
byte[] secretKeyData = Files.readAllBytes(secretKeyPath);
PairingStreamReader skStreamParser = new PairingStreamReader(p,
secretKeyData, 0);
query[0] = skStreamParser.readString();
query[1] = skStreamParser.readString();
query[2] = skStreamParser.readString();
System.out.println("Query was: "+query[0]+" "+query[1]+" "+query[2]);
Element g1 = skStreamParser.readG1Element();
int n1 = skStreamParser.readInt();
int N = 2 * n1 + 3;
Pairing prodP = new ProductPairing(null, p, N);
IPLOSTW10Parameters parameters2 = new IPLOSTW10Parameters(params,
g1.getImmutable(), n1);
Element k = skStreamParser.readG1Element(prodP);
return new IPLOSTW10SecretKeyParameters(parameters2, k);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
示例9: createAttributeVectorForTriple
import it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory; //导入方法依赖的package包/类
@Override
public Element[] createAttributeVectorForTriple(CipherParameters publicKey,
org.openrdf.model.Statement triple) {
Pairing pairing = PairingFactory
.getPairing(((FEPublicKeyParameters) publicKey).getParameters()
.getParameters());
Element[] result = new Element[4];
MessageDigest sha1;
try {
sha1 = MessageDigest.getInstance("SHA-1");
/***************************************************************/
/***************** Computing 3 Random Elements *****************/
/***************************************************************/
// Instant start = Instant.now();
Element r1 = pairing.getZr().newRandomElement().getImmutable();
Element r2 = pairing.getZr().newRandomElement().getImmutable();
// Duration dur = Duration.between(start, Instant.now());
/***************************************************************/
/***************************************************************/
/******************* Computing SPO Elements ********************/
/***************************************************************/
// start = Instant.now();
byte[] digestS = sha1.digest(triple.getSubject().stringValue()
.getBytes());
Element s = pairing.getZr()
.newElementFromHash(digestS, 0, digestS.length)
.getImmutable();
byte[] digestO = sha1.digest(triple.getObject().stringValue()
.getBytes());
Element o = pairing.getZr()
.newElementFromHash(digestO, 0, digestO.length)
.getImmutable();
// dur = Duration.between(start, Instant.now());
/***************************************************************/
/***************************************************************/
/***************** Computing Attribute Vector ******************/
/***************************************************************/
// start = Instant.now();
result[0] = r1.mul(s.negate());
result[1] = r1;
result[2] = r2.mul(o.negate());
result[3] = r2;
// dur = Duration.between(start, Instant.now());
// System.out.format("Attribute Vector generated in: %sms%n",
// dur.toMillis());
/***************************************************************/
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
示例10: createPredicateVectorForQuery
import it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory; //导入方法依赖的package包/类
@Override
public Element[] createPredicateVectorForQuery(
CipherParameters masterSecKey, String s, String p, String o) {
Pairing pairing = PairingFactory
.getPairing(((IPLOSTW10MasterSecretKeyParameters) masterSecKey)
.getParameters().getParameters());
Element[] result = new Element[4];
MessageDigest sha1;
try {
sha1 = MessageDigest.getInstance("SHA-1");
/***************************************************************/
/******************* Computing SPO Elements ********************/
/***************************************************************/
// Instant start = Instant.now();
byte[] digestS = sha1.digest(s.getBytes());
Element sE = pairing.getZr()
.newElementFromHash(digestS, 0, digestS.length)
.getImmutable();
byte[] digestO = sha1.digest(o.getBytes());
Element oE = pairing.getZr()
.newElementFromHash(digestO, 0, digestO.length)
.getImmutable();
if (s.equals("*")) {
result[0] = pairing.getZr().newZeroElement();
result[1] = pairing.getZr().newZeroElement();
} else {
result[0] = pairing.getZr().newOneElement();
result[1] = sE;
}
if (o.equals("*")) {
result[2] = pairing.getZr().newZeroElement();
result[3] = pairing.getZr().newZeroElement();
} else {
result[2] = pairing.getZr().newOneElement();
result[3] = oE;
}
// Duration dur = Duration.between(start, Instant.now());
// System.out.format("SPO Elements generated in: %sms%n",
// dur.toMillis());
/***************************************************************/
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
示例11: createAttributeVectorForTriple
import it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory; //导入方法依赖的package包/类
@Override
public Element[] createAttributeVectorForTriple(CipherParameters publicKey, org.openrdf.model.Statement triple) {
Pairing pairing = PairingFactory
.getPairing(((FEPublicKeyParameters) publicKey).getParameters().getParameters());
Element[] result = new Element[6];
MessageDigest sha1;
try {
sha1 = MessageDigest.getInstance("SHA-1");
/***************************************************************/
/***************** Computing 3 Random Elements *****************/
/***************************************************************/
// Instant start = Instant.now();
Element r1 = pairing.getZr().newRandomElement().getImmutable();
Element r2 = pairing.getZr().newRandomElement().getImmutable();
Element r3 = pairing.getZr().newRandomElement().getImmutable();
// Duration dur = Duration.between(start, Instant.now());
// System.out.format("3 Random Elements generated in: %sms%n",
// dur.toMillis());
/***************************************************************/
/***************************************************************/
/******************* Computing SPO Elements ********************/
/***************************************************************/
// start = Instant.now();
byte[] digestS = sha1.digest(triple.getSubject().stringValue().getBytes());
Element s = pairing.getZr().newElementFromHash(digestS, 0, digestS.length).getImmutable();
byte[] digestP = sha1.digest(triple.getPredicate().stringValue().getBytes());
Element p = pairing.getZr().newElementFromHash(digestP, 0, digestP.length).getImmutable();
byte[] digestO = sha1.digest(triple.getObject().stringValue().getBytes());
Element o = pairing.getZr().newElementFromHash(digestO, 0, digestO.length).getImmutable();
// dur = Duration.between(start, Instant.now());
/***************************************************************/
/***************************************************************/
/***************** Computing Attribute Vector ******************/
/***************************************************************/
// start = Instant.now();
result[0] = r1.mul(s.negate());
result[1] = r1;
result[2] = r2.mul(p.negate());
result[3] = r2;
result[4] = r3.mul(o.negate());
result[5] = r3;
// dur = Duration.between(start, Instant.now());
// System.out.format("Attribute Vector generated in: %sms%n",
// dur.toMillis());
/***************************************************************/
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
示例12: createPredicateVectorForQuery
import it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory; //导入方法依赖的package包/类
@Override
public Element[] createPredicateVectorForQuery(CipherParameters masterSecKey, String s, String p, String o) {
Pairing pairing = PairingFactory
.getPairing(((IPLOSTW10MasterSecretKeyParameters) masterSecKey).getParameters().getParameters());
Element[] result = new Element[6];
MessageDigest sha1;
try {
sha1 = MessageDigest.getInstance("SHA-1");
/***************************************************************/
/******************* Computing SPO Elements ********************/
/***************************************************************/
Instant start = Instant.now();
byte[] digestS = sha1.digest(s.getBytes());
Element sE = pairing.getZr().newElementFromHash(digestS, 0, digestS.length).getImmutable();
byte[] digestP = sha1.digest(p.getBytes());
Element pE = pairing.getZr().newElementFromHash(digestP, 0, digestP.length).getImmutable();
byte[] digestO = sha1.digest(o.getBytes());
Element oE = pairing.getZr().newElementFromHash(digestO, 0, digestO.length).getImmutable();
if (s.equals("*")) {
result[0] = pairing.getZr().newZeroElement();
result[1] = pairing.getZr().newZeroElement();
} else {
result[0] = pairing.getZr().newOneElement();
result[1] = sE;
}
if (p.equals("*")) {
result[2] = pairing.getZr().newZeroElement();
result[3] = pairing.getZr().newZeroElement();
} else {
result[2] = pairing.getZr().newOneElement();
result[3] = pE;
}
if (o.equals("*")) {
result[4] = pairing.getZr().newZeroElement();
result[5] = pairing.getZr().newZeroElement();
} else {
result[4] = pairing.getZr().newOneElement();
result[5] = oE;
}
Duration dur = Duration.between(start, Instant.now());
System.out.format("SPO Elements generated in: %sms%n", dur.toMillis());
/***************************************************************/
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
示例13: init
import it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory; //导入方法依赖的package包/类
public void init(KeyGenerationParameters param) {
this.param = (IPLOSTW10SecretKeyGenerationParameters) param;
this.n = this.param.getParameters().getParameters().getN();
this.pairing = PairingFactory.getPairing(this.param.getParameters().getParameters().getParameters());
}
示例14: loadPreProcessedKeyPair
import it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory; //导入方法依赖的package包/类
public AsymmetricCipherKeyPair loadPreProcessedKeyPair(String keyPath) {
// IPLOSTW10Parameters parameters = param.getParameters();
Path path = Paths.get(keyPath,"pairing.properties");
byte[] data;
try {
data = Files.readAllBytes(path);
PairingParameters params = new PropertiesParameters().load(new ByteArrayInputStream(data));
Pairing p = PairingFactory.getPairing(params);
Path pubPath = Paths.get(keyPath,"pub.key");
byte[] pubData = Files.readAllBytes(pubPath);
PairingStreamReader streamParser = new PairingStreamReader(p, pubData, 0);
Path privPath = Paths.get(keyPath,"privMaster.key");
byte[] privData = Files.readAllBytes(privPath);
PairingStreamReader privStreamParser = new PairingStreamReader(p, privData, 0);
int fieldType = streamParser.readInt();
if (fieldType == 1) {
Element g1 = streamParser.readG1Element();
int n1 = streamParser.readInt();
System.out.println("n1: " + n1);
IPLOSTW10Parameters parameters2 = new IPLOSTW10Parameters(params, g1.getImmutable(), n1);
int N = 2 * n1 + 3;
Pairing prodP = new ProductPairing(null, p, N);
int nrBElements = streamParser.readInt();
System.out.println("nrBElements: " + nrBElements);
ElementPowPreProcessing[] B2 = streamParser.readElementsandPreProcess(prodP, 1, nrBElements);
int nrBStarElements = privStreamParser.readInt();
System.out.println("nrBStarElements: " + nrBStarElements);
Element[] BStar2 = privStreamParser.readElements(prodP, 1, nrBStarElements);
Element sigma2 = streamParser.readGTElement();
return new AsymmetricCipherKeyPair(new FEPublicKeyParameters(parameters2, B2, sigma2),
new IPLOSTW10MasterSecretKeyParameters(parameters2, BStar2));
} else {
System.out.println(fieldType + " was not 1");
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
示例15: loadKeyPair
import it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory; //导入方法依赖的package包/类
public AsymmetricCipherKeyPair loadKeyPair() {
// IPLOSTW10Parameters parameters = param.getParameters();
Path path = Paths.get("data/pairing.properties");
byte[] data;
try {
data = Files.readAllBytes(path);
PairingParameters params = new PropertiesParameters().load(new ByteArrayInputStream(data));
Pairing p = PairingFactory.getPairing(params);
Path pubPath = Paths.get("data/pub.key");
byte[] pubData = Files.readAllBytes(pubPath);
PairingStreamReader streamParser = new PairingStreamReader(p, pubData, 0);
Path privPath = Paths.get("data/privMaster.key");
byte[] privData = Files.readAllBytes(privPath);
PairingStreamReader privStreamParser = new PairingStreamReader(p, privData, 0);
int fieldType = streamParser.readInt();
if (fieldType == 1) {
Element g1 = streamParser.readG1Element();
int n1 = streamParser.readInt();
System.out.println("n1: " + n1);
IPLOSTW10Parameters parameters2 = new IPLOSTW10Parameters(params, g1.getImmutable(), n1);
int N = 2 * n1 + 3;
Pairing prodP = new ProductPairing(null, p, N);
int nrBElements = streamParser.readInt();
System.out.println("nrBElements: " + nrBElements);
Element[] B2 = streamParser.readElements(prodP, 1, nrBElements);
int nrBStarElements = privStreamParser.readInt();
System.out.println("nrBStarElements: " + nrBStarElements);
Element[] BStar2 = privStreamParser.readElements(prodP, 1, nrBStarElements);
Element sigma2 = streamParser.readGTElement();
return new AsymmetricCipherKeyPair(new FEPublicKeyParameters(parameters2, B2, sigma2),
new IPLOSTW10MasterSecretKeyParameters(parameters2, BStar2));
} else {
System.out.println(fieldType + " was not 1");
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}