use Crypt::CBC; use Crypt::Blowfish; my $g_i = $pairing->init_GT->e_hat( $Q_i, $P_pub ); my $r = $pairing->init_Zr->random; my $rP = $pairing->init_G2->pow_zn( $P, $r ); my $W1 = $g_i->clone->pow_zn( $r ); my $C1 = new Crypt::CBC({header=>'randomiv', key=>$W1->as_bytes, cipher=>"Blowfish"}); my @m = ($rP, $C1->encrypt("LOL! Funny URL: blither blather message")); # Note that the message is a two tuple, not just the ciphertext. # We transmit @m in the clear. No worries. my $W2 = $pairing->init_GT->e_hat( $d_i, $m[0] ); my $C2 = new Crypt::CBC({header=>"randomiv", key=>$W2->as_bytes, cipher=>"Blowfish"}); my $txt = $C2->decrypt( $m[1] ); print "W1 =? W2\nW1=", substr($W1->as_base64, 0, 80), "\nW2=", substr($W2->as_base64, 0, 80), "\n"; print "And here's the original message: $txt\n\n";