0

Suppose the plaintext is a string, and I map the plaintext to the group using setFromHash function before I can perform the encryption operation, and the final decryption is only the hash of the plaintext, not the plaintext, how can I decrypt the plaintext or perform the bilinear operation without mapping the plaintext to the group? (Can this be achieved without using symmetric encryption)

        setup(pairingParametersFileName, pkFileName, mskFileName);
        keygen(pairingParametersFileName, userAttList, pkFileName, mskFileName, skFileName);

        String msg = "dasddwhqoiuhdaiosnioacjijdqwi0jdaposdjiasojcbndusivbuiweshfsaoindoai";
       //byte[] sha1Result =  sha1(msg);
       //Element message = PairingFactory.getPairing(pairingParametersFileName).getGT().newRandomElement().getImmutable();
       //Element message = PairingFactory.getPairing(pairingParametersFileName).getGT().newElement().setFromHash(sha1Result, 0, sha1Result.length).getImmutable();
        Element message = PairingFactory.getPairing(pairingParametersFileName).getGT().newElement().setFromHash(msg, 0, msg.length).getImmutable();
        System.out.println("plaintext:" + msg);
        encrypt(pairingParametersFileName, message, accessTree, pkFileName, ctFileName);

        Element res = decrypt(pairingParametersFileName, accessTree, ctFileName, skFileName);
        System.out.println("decrypt:" + res);

        if (message.isEqual(res)) {
            System.out.println("successful!");
        }

Pairing bp = PairingFactory.getPairing(pairingParametersFileName);

        Properties pkProp = loadPropFromFile(pkFileName);
        String gString = pkProp.getProperty("g");
        Element g = bp.getG1().newElementFromBytes(Base64.getDecoder().decode(gString)).getImmutable();
        String g_betaString = pkProp.getProperty("g_beta");
        Element g_beta = bp.getG1().newElementFromBytes(Base64.getDecoder().decode(g_betaString)).getImmutable();
        String egg_alphaString = pkProp.getProperty("egg_alpha");
        Element egg_alpha = bp.getGT().newElementFromBytes(Base64.getDecoder().decode(egg_alphaString)).getImmutable();

        Properties ctProp = new Properties();
        //compute CT=M *e(g,g)^(alpha s)
        Element s = bp.getZr().newRandomElement().getImmutable();
        Element CT = message.duplicate().mul(egg_alpha.powZn(s)).getImmutable();
        Element C = g_beta.powZn(s).getImmutable();

1 Answers1

0

this is not achievable, pairing-based CP-ABE, if encrypted, requires plaintext in the G_T group, but there is no good way to encode a message to the G_T group