it.unisa女鞋.dia.gas.crypto.circuit.circuit这是什么库

java 程序在exclipse中运行错误,不知道原因,求大神指点~~~
java运行后出现下面错误,求大神指点:
java.lang.NullPointerException
atit.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory$CTL13MultilinearPairingCreator.create(PairingFactory.java:188)
at it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory.initPairing(PairingFactory.java:109)
at it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory.initPairing(PairingFactory.java:79)
at it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory.getPairing(PairingFactory.java:35)
at it.unisa.dia.gas.crypto.jpbc.fe.abe.gghsw13.GGHSW13KEM.setup(GGHSW13KEM.java:36)
at it.unisa.dia.gas.crypto.jpbc.fe.abe.gghsw13.GGHSW13KEM.main(GGHSW13KEM.java:113) Exception in thread &main& java.lang.IllegalArgumentException: Cannot create pairing instance. Type = ctl13
at it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory.initPairing(PairingFactory.java:111)
at it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory.initPairing(PairingFactory.java:79)
at it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory.getPairing(PairingFactory.java:35)
at it.unisa.dia.gas.crypto.jpbc.fe.abe.gghsw13.GGHSW13KEM.setup(GGHSW13KEM.java:36)
at it.unisa.dia.gas.crypto.jpbc.fe.abe.gghsw13.GGHSW13KEM.main(GGHSW13KEM.java:113)
程序源代码如下:
& &import java.security.SecureR
& &import java.util.A
& &import static it.unisa.dia.gas.crypto.circuit.Circuit.Gate.Type.*;
& &import static it.unisa.dia.gas.crypto.circuit.DefaultCircuit.DefaultG
& &import static org.junit.Assert.*;
Angelo De Caro ()
& &public class GGHSW13KEM {
& & & public GGHSW13KEM() {
& & & &public AsymmetricCipherKeyPair setup(int n) {
& & & & & GGHSW13KeyPairGenerator setup = new GGHSW13KeyPairGenerator();
& & & & & setup.init(new GGHSW13KeyPairGenerationParameters(
& & & & & & & & & new SecureRandom(),
& & & & & & & & & &new GGHSW13ParametersGenerator().init(
& & & & & & & & & & & & & &PairingFactory.getPairing(&toy.properties&),
& & & & & & & & & & & & & &n).generateParameters()
& & & & & &));
& & & & & return setup.generateKeyPair();
& & & &public byte[][] encaps(CipherParameters publicKey, String w) {
& & & & & &try {
& & & & & & & KeyEncapsulationMechanism kem = new GGHSW13KEMEngine();
& & & & & & & &kem.init(true, new GGHSW13EncryptionParameters((GGHSW13PublicKeyParameters) publicKey, w));
& & & & & & & &byte[] ciphertext = kem.process();
& & & & & & & &assertNotNull(ciphertext);
& & & & & & & &assertNotSame(0, ciphertext.length);
& & & & & & & &byte[] key = Arrays.copyOfRange(ciphertext, 0, kem.getKeyBlockSize());
& & & & & & & &byte[] ct = Arrays.copyOfRange(ciphertext, kem.getKeyBlockSize(), ciphertext.length);
& & & & & & & return new byte[][]{key, ct};
& & & & & &} catch (InvalidCipherTextException e) {
& & & & & & & &e.printStackTrace();
& & & & & & & &fail(e.getMessage());
& & & & & }
& & & &public CipherParameters keyGen(CipherParameters publicKey, CipherParameters masterSecretKey, Circuit circuit) {
& & & & & &GGHSW13SecretKeyGenerator keyGen = new GGHSW13SecretKeyGenerator();
& & & & & &keyGen.init(new GGHSW13SecretKeyGenerationParameters(
& & & & & & & & & &(GGHSW13PublicKeyParameters) publicKey,
& & & & & & & & & &(GGHSW13MasterSecretKeyParameters) masterSecretKey,
& & & & & & & & & &circuit
& & & & & &));
& & & & & return keyGen.generateKey();
& & & &public byte[] decaps(CipherParameters secretKey, byte[] ciphertext) {
& & & & & try {
& & & & & & & KeyEncapsulationMechanism kem = new GGHSW13KEMEngine();
& & & & & & & kem.init(false, secretKey);
& & & & & & & &byte[] key = kem.processBlock(ciphertext);
& & & & & & & &assertNotNull(key);
& & & & & & & &assertNotSame(0, key.length);
& & & & & & & &
& & & & & &} catch (InvalidCipherTextException e) {
& & & & & & & &e.printStackTrace();
& & & & & & & &fail(e.getMessage());
& & & & & &}
& & & & & &
& & & &public static void main(String[] args) {
& & & & & &int n = 4;
& & & & & &int q = 3;
& & & & & Circuit circuit = new DefaultCircuit(n, q, 3, new DefaultGate[]{
& & & & & & & & &new DefaultGate(INPUT, 0, 1),
& & & & & & & & & new DefaultGate(INPUT, 1, 1),
& & & & & & & & & new DefaultGate(INPUT, 2, 1),
& & & & & & & & & new DefaultGate(INPUT, 3, 1),
& & & & & & & & & new DefaultGate(AND, 4, 2, new int[]{0, 1}),
& & & & & & & & & new DefaultGate(OR, 5, 2, new int[]{2, 3}),
& & & & & & & & & new DefaultGate(AND, 6, 3, new int[]{4, 5}),
& & & & & });
& & & & & GGHSW13KEM kem = new GGHSW13KEM();
& & & & & // Setup
& & & & & AsymmetricCipherKeyPair keyPair = kem.setup(n);
& & & & & // Keygen
& & & & & CipherParameters secretKey = kem.keyGen(keyPair.getPublic(), keyPair.getPrivate(), circuit);
& & & & & // Encaps/Decaps for satisfying assignment
& & & & & String assignment = &1101&;
& & & & & byte[][] ct = kem.encaps(keyPair.getPublic(), assignment);
& & & & & assertEquals(true, Arrays.equals(ct[0], kem.decaps(secretKey, ct[1])));
& & & & & // Encaps/Decaps for not-satisfying assignment
& & & & & assignment = &1001&;
& & & & & ct = kem.encaps(keyPair.getPublic(), assignment);
& & & & & assertEquals(false, Arrays.equals(ct[0], kem.decaps(secretKey, ct[1])));
引用来自“无敌大坏蛋”的评论109行有空对象 ! 改了程序之后运行错误就变成下面那样的了,这是怎么回事?
Exception in thread &main& java.lang.IllegalArgumentException: No valid resource found!
at it.unisa.dia.gas.plaf.jpbc.pairing.parameters.PropertiesParameters.load(PropertiesParameters.java:190)
at it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory.loadParameters(PairingFactory.java:125)
at it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory.initPairing(PairingFactory.java:79)
at it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory.getPairing(PairingFactory.java:35)
at it.unisa.dia.gas.crypto.jpbc.fe.abe.gghsw13.GGHSW13KEM.setup(GGHSW13KEM.java:36)
at it.unisa.dia.gas.crypto.jpbc.fe.abe.gghsw13.GGHSW13KEM.main(GGHSW13KEM.java:113)
打个断点 一步步走 一下子就知道了
有一个对象没有创建(空对象)
空指针异常最好自己解决 找到问题后定会收获不小 祝你成功
--- 共有 2 条评论 ---
希望你可以给我指点指点呢
OA的程序还有bug,你运行的时候也会出错吗
109行有空对象 !Java Code Example it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory
Java Code Examples for it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory
The following are top voted examples for showing how to use
it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory. These examples are extracted from open source projects.
You can vote up the examples you like and your votes will be used in our system to product
more good examples.
+ Save this class to your library
public void setup(CurveParams params,int numAttributes,int numValues){
Pairing e=PairingFactory.getPairing(params);
Element g=e.getG1().newRandomElement().getImmutable();
Element y=e.getZr().newRandomElement().getImmutable();
Element Y=e.pairing(g,g).powZn(y).getImmutable();
String[] sysAtts=new String[numAttributes];
for (int i=1; i &= numA i++) {
sysAtts[i - 1]=&att& +
MCAttributeComponent mkAtts=new MCAttributeComponent(numAttributes,numValues,numAttributes + 1);
MCAttributeComponent pkAtts=new MCAttributeComponent(numAttributes,numValues,numAttributes + 1);
for (int i=1; i &= numA i++) {
Element exponent=e.getZr().newRandomElement().getImmutable();
mkAtts.setAttributeElement(i,exponent);
pkAtts.setAttributeElement(i,g.powZn(exponent).getImmutable());
this.pk=new MCPublicKey(numAttributes,numValues,numAttributes + 1,params,e,Y,new Element[]{g},new ABESystemAttributeSetObject(sysAtts,numAttributes,numValues),pkAtts);
this.mk=new MCMasterKey(y,mkAtts);
public void setup(CurveParams params,int numAttributes,int numValues){
Pairing e=PairingFactory.getPairing(params);
Element g1=e.getG1().newRandomElement().getImmutable();
Element h=e.getG1().newRandomElement().getImmutable();
Element y=e.getZr().newRandomElement().getImmutable();
Element Y=e.pairing(g1,h).powZn(y).getImmutable();
int size=numAttributes * numV
String[] sysAtts=new String[size];
MCCAttributeComponent mkAtts=new MCCAttributeComponent(numAttributes,numValues,size);
MCCAttributeComponent pkAtts=new MCCAttributeComponent(numAttributes,numValues,size);
for (int i=1, k=0; i &= numA i++) {
for (int j=1; j &= numV j++, k++) {
Element exponent=e.getZr().newRandomElement().getImmutable();
mkAtts.setAttributeElement(&att& + i + &|val&+ j,exponent);
pkAtts.setAttributeElement(&att& + i + &|val&+ j,g1.powZn(exponent).getImmutable());
sysAtts[k]=(&att& + i + &|val&+ j);
this.pk=new MCCPublicKey(numAttributes,numValues,size,params,e,Y,new Element[]{g1,h},new ABESystemAttributeSetObject(sysAtts,numAttributes,numValues),pkAtts);
this.mk=new MCCMasterKey(y,mkAtts);
public void setup(CurveParams params,int numAttributes,int numValues){
int size=(numAttributes * 3) + 1;
Pairing e=PairingFactory.getPairing(params);
Element g=e.getG1().newRandomElement().getImmutable();
Element y=e.getZr().newRandomElement().getImmutable();
Element Y=e.pairing(g,g).powZn(y).getImmutable();
String[] sysAtts=new String[numAttributes];
for (int i=1; i &= numA i++) {
sysAtts[i - 1]=&att& +
CAttributeComponent mkAtts=new CAttributeComponent(numAttributes,numValues,size);
CAttributeComponent pkAtts=new CAttributeComponent(numAttributes,numValues,size);
for (int i=1; i & i++) {
Element exp=e.getZr().newRandomElement().getImmutable();
mkAtts.setAttributeElement(i,exp);
pkAtts.setAttributeElement(i,g.powZn(exp).getImmutable());
CPublicKey pk=new CPublicKey(numAttributes,numValues,size,params,e,Y,new Element[]{g},new ABESystemAttributeSetObject(sysAtts,numAttributes,numValues),pkAtts);
CMasterKey mk=new CMasterKey(y,mkAtts);
public void setup(CurveParams curveParams,int numAttributes,int numValues){
Pairing e=PairingFactory.getPairing(curveParams);
Element g1=e.getG1().newRandomElement().getImmutable();
Element h=e.getG1().newRandomElement().getImmutable();
Element y=e.getZr().newRandomElement().getImmutable();
Element Y=e.pairing(g1,h).powZn(y).getImmutable();
int size=numAttributes * numV
String[] sysAtts=new String[size];
CCAttributeComponent tij=new CCAttributeComponent(numAttributes,numValues,size);
CCAttributeComponent Tij=new CCAttributeComponent(numAttributes,numValues,size);
for (int i=1, k=0; i &= numA i++) {
for (int j=1; j &= numV j++, k++) {
Element exponent=e.getZr().newRandomElement().getImmutable();
tij.setAttributeElement(&att& + i + &|val&+ j,exponent);
Tij.setAttributeElement(&att& + i + &|val&+ j,g1.powZn(exponent).getImmutable());
sysAtts[k]=&att& + i + &|val&+
CCPublicKey pk=new CCPublicKey(numAttributes,numValues,size,curveParams,e,Y,new Element[]{g1,h},new ABESystemAttributeSetObject(sysAtts,numAttributes,numValues),Tij);
CCMasterKey mk=new CCMasterKey(y,tij);
public static void setup(BswabePub pub,BswabeMsk msk){
Element alpha, beta_
CurveParameters params=new DefaultCurveParameters().load(new ByteArrayInputStream(curveParams.getBytes()));
pub.pairingDesc=curveP
pub.p=PairingFactory.getPairing(params);
Pairing pairing=pub.p;
pub.g=pairing.getG1().newElement();
pub.f=pairing.getG1().newElement();
pub.h=pairing.getG1().newElement();
pub.gp=pairing.getG2().newElement();
pub.g_hat_alpha=pairing.getGT().newElement();
alpha=pairing.getZr().newElement();
msk.beta=pairing.getZr().newElement();
msk.g_alpha=pairing.getG2().newElement();
alpha.setToRandom();
msk.beta.setToRandom();
pub.g.setToRandom();
pub.gp.setToRandom();
msk.g_alpha=pub.gp.powZn(alpha);
beta_inv=pairing.getZr().newElement();
beta_inv=msk.beta.invert();
pub.f=pub.g.powZn(beta_inv);
pub.h=pub.g.powZn(msk.beta);
pub.g_hat_alpha=pairing.pairing(pub.g,msk.g_alpha);
public static BswabePub unserializeBswabePub(byte[] b){
pub=new BswabePub();
StringBuffer sb=new StringBuffer(&&);
offset=unserializeString(b,offset,sb);
pub.pairingDesc=sb.substring(0);
CurveParameters params=new DefaultCurveParameters().load(new ByteArrayInputStream(pub.pairingDesc.getBytes()));
pub.p=PairingFactory.getPairing(params);
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);
public MessageReply generateSig(SignatureCreateMessage blsCreate) throws ServiceConnectionException, IOException {
Participant[] participants=new Participant[blsCreate.getNodesToUse().size()];
int index=0;
String name : blsCreate.getNodesToUse()) {
MessageReply seqRep=sendMessage(name,Type.FETCH_SEQUENCE_NO,new KeyIDMessage(blsCreate.getKeyID()));
participants[index]=new Participant(BigIntegerMessage.getInstance(seqRep.getPayload()).getValue().intValue(),name);
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);
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()));
public synchronized AsymmetricCipherKeyPair generateKeyPair(String keyID,Algorithm algorithm,int numberOfPeers,NamedKeyGenParams keyGenParams){
BLS01Parameters domainParameters=paramsMap.get(keyID);
if (domainParameters == null) {
BLS01KeyPairGenerator kpGen=new BLS01KeyPairGenerator();
CurveParameters curveParameters=new DefaultCurveParameters().load(this.getClass().getResourceAsStream(&d8.param&));
Random random=new Random(makeSeed(Strings.toByteArray(keyID)));
Pairing pairing=PairingFactory.getInstance().getPairing(curveParameters,random);
Element g=pairing.getG2().newRandomElement();
random=new SecureRandom();
pairing=PairingFactory.getInstance().getPairing(curveParameters,random);
BLS01Parameters blsParameters=new BLS01Parameters(curveParameters,g.getImmutable());
kpGen.init(new BLS01KeyGenerationParameters((SecureRandom)random,blsParameters));
AsymmetricCipherKeyPair kp=kpGen.generateKeyPair();
sharedPrivateKeyMap.init(keyID,numberOfPeers);
sharedPublicKeyMap.init(keyID,numberOfPeers);
hMap.put(keyID,keyGenParams.getH());
paramsMap.put(keyID,blsParameters);
throw new IllegalStateException(&Key & + keyID + & already exists.&);
@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();
Element sk=pairing.getZr().newElement(share.getValue());
Element pk=g.powZn(sk);
return new PartialPublicKeyInfo(share.getSequenceNo(),SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo(new BLS01PublicKeyParameters(params,pk.getImmutable())));
Example 10
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));
mitmentFactors=new Element[s.size()];
for (int i=0; i != commitmentFactors. 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());
Example 11
* 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 curveP
Element G;
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());
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());
Example 12
public MessageReply handle(SignatureMessage message){
switch ((Type)message.getType()) {
case FETCH_SEQUENCE_NO:
KeyIDMessage keyIDMessage=KeyIDMessage.getInstance(message.getPayload());
return new MessageReply(MessageReply.Type.OKAY,new BigIntegerMessage(BigInteger.valueOf(nodeContext.getPrivateKeyOperator(keyIDMessage.getKeyID()).getSequenceNo())));
case PRIVATE_KEY_SIGN:
BLSPartialCreateMessage partialMessage=BLSPartialCreateMessage.getInstance(message.getPayload());
SubjectPublicKeyInfo pubKeyInfo=nodeContext.getPublicKey(partialMessage.getKeyID());
BLS01Parameters domainParams=BLSPublicKeyFactory.createKey(pubKeyInfo).getParameters();
Pairing pairing=PairingFactory.getInstance().getPairing(domainParams.getCurveParameters());
PrivateKeyOperator operator=nodeContext.getPrivateKeyOperator(partialMessage.getKeyID());
if (!(operator instanceof BLSPrivateKeyOperator)) {
return new MessageReply(MessageReply.Type.ERROR);
BLSPrivateKeyOperator blsOperator=(BLSPrivateKeyOperator)
MessageReply reply=replyOkay(new ShareMessage(blsOperator.getSequenceNo(),new ElementMessage(blsOperator.transform(partialMessage.getH(pairing)))));
nodeContext.getEventNotifier().notify(EventNotifier.Level.ERROR,&Unknown command in NodeSigningService.&);
return new MessageReply(MessageReply.Type.ERROR,new DERUTF8String(&Unknown command in NodeSigningService.&));
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()));
Example 13
* creates an instance over the specified EC domain parameters to share secrets among the specified number of peers
* @param numberOfPeers the number of peers among which the secret is shared
* @param threshold number of peers that must be available for secret reconstruction,
* @param h value to calculate commitment polynomial against.
* @param domainParams domain parameters for the EC group to use.
* @param random a source of randomness,
public BLSNewDKGSecretSplitter(int numberOfPeers,int threshold,Element h,BLS01Parameters domainParams,SecureRandom random){
if (numberOfPeers & threshold) {
throw new IllegalArgumentException(&numberOfPeers must at least be as big as the threshold value.&);
this.domainParams=domainP
this.secretSplitter=new ShamirSecretSplitter(numberOfPeers,threshold,PairingFactory.getPairing(domainParams.getCurveParameters()).getZr().getOrder(),random);
this.random=
Example 14
* Given the secret generate random coefficients (except for a_0 which is the secret) and compute the function for each privacy peer (who is assigned a dedicated alpha). Coefficients are picked from (0, fieldSize).
* @param secret the secret to be shared
* @return the shares of the secret for each privacy peer
public BLSCommittedSplitSecret split(BigInteger secret){
SplitSecret secretShares=secretSplitter.split(secret);
SplitSecret bShares=secretSplitter.split(getRandomInteger(PairingFactory.getPairing(domainParams.getCurveParameters()).getZr().getOrder(),random));
Element[] commitments=new Element[k];
for (int j=0; j & j++) {
commitments[j]=domainParams.getG().mul(secretShares.getCoefficients()[j]).add(h.mul(bShares.getCoefficients()[j]));
return new BLSCommittedSplitSecret(secretShares.getShares(),secretShares.getCoefficients(),bShares.getShares(),commitments);
Example 15
* 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 curveP
Element G;
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());
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());}

我要回帖

更多关于 unisa 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信