FTI_Video_Service/src/bswabe/Bswabe.java
/*
	 * Generate a private key with the given set of attributes.
	 */
Generate a private key with the given set of attributes.
Generate a private key with the given set of attributes .
public static BswabePrv keygen(BswabePub pub, BswabeMsk msk, String[] attrs)
			throws NoSuchAlgorithmException {
		BswabePrv prv = new BswabePrv();
		Element g_r, r, beta_inv;
		Pairing pairing;
		/* initialize */
		pairing = pub.p;
		prv.d = pairing.getG2().newElement();
		g_r = pairing.getG2().newElement();
		r = pairing.getZr().newElement();
		beta_inv = pairing.getZr().newElement();
		/* compute */
		r.setToRandom();
		g_r = pub.gp.duplicate();
		g_r.powZn(r);
		prv.d = msk.g_alpha.duplicate();
		prv.d.mul(g_r);
		beta_inv = msk.beta.duplicate();
		beta_inv.invert();
		prv.d.powZn(beta_inv);
		int i, len = attrs.length;
		prv.comps = new ArrayList<BswabePrvComp>();
		for (i = 0; i < len; i++) {
			BswabePrvComp comp = new BswabePrvComp();
			Element h_rp;
			Element rp;
			comp.attr = attrs[i];
			comp.d = pairing.getG2().newElement();
			comp.dp = pairing.getG1().newElement();
			h_rp = pairing.getG2().newElement();
			rp = pairing.getZr().newElement();
			elementFromString(h_rp, comp.attr);
			rp.setToRandom();
			h_rp.powZn(rp);
			comp.d = g_r.duplicate();
			comp.d.mul(h_rp);
			comp.dp = pub.g.duplicate();
			comp.dp.powZn(rp);
			prv.comps.add(comp);
		}
		return prv;
	}
public static BswabePrv keygen ( BswabePub pub , BswabeMsk msk , String [ ] attrs ) throws NoSuchAlgorithmException { BswabePrv prv = new BswabePrv ( ) ; Element g_r , r , beta_inv ; Pairing pairing ; /* initialize */ pairing = pub . p ; prv . d = pairing . getG2 ( ) . newElement ( ) ; g_r = pairing . getG2 ( ) . newElement ( ) ; r = pairing . getZr ( ) . newElement ( ) ; beta_inv = pairing . getZr ( ) . newElement ( ) ; /* compute */ r . setToRandom ( ) ; g_r = pub . gp . duplicate ( ) ; g_r . powZn ( r ) ; prv . d = msk . g_alpha . duplicate ( ) ; prv . d . mul ( g_r ) ; beta_inv = msk . beta . duplicate ( ) ; beta_inv . invert ( ) ; prv . d . powZn ( beta_inv ) ; int i , len = attrs . length ; prv . comps = new ArrayList < BswabePrvComp > ( ) ; for ( i = 0 ; i < len ; i ++ ) { BswabePrvComp comp = new BswabePrvComp ( ) ; Element h_rp ; Element rp ; comp . attr = attrs [ i ] ; comp . d = pairing . getG2 ( ) . newElement ( ) ; comp . dp = pairing . getG1 ( ) . newElement ( ) ; h_rp = pairing . getG2 ( ) . newElement ( ) ; rp = pairing . getZr ( ) . newElement ( ) ; elementFromString ( h_rp , comp . attr ) ; rp . setToRandom ( ) ; h_rp . powZn ( rp ) ; comp . d = g_r . duplicate ( ) ; comp . d . mul ( h_rp ) ; comp . dp = pub . g . duplicate ( ) ; comp . dp . powZn ( rp ) ; prv . comps . add ( comp ) ; } return prv ; }
Generate a private key with the given set of attributes.
Generate a private key with the given set of attributes .