JPBC库实现基于身份的签名体制
JPBC库实现基于身份的签名体制---Hess体制
Hess算法:
代码:
Hess类:
import it.unisa.dia.gas.jpbc.Element;
import it.unisa.dia.gas.jpbc.Field;
import it.unisa.dia.gas.jpbc.Pairing;
import it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory;
import java.lang.reflect.Proxy;public class Hess implements Ident{private Element s,r,P,Ppub,Su,Qu,W,h,P1,T,TT,T1,T2,W1,W2;private Field G1,Zr;private Pairing pairing;public Hess(){init();}private void init(){pairing = PairingFactory.getPairing("a.properties");PairingFactory.getInstance().setUsePBCWhenPossible(true);checkSymmetric(pairing);Zr = pairing.getZr();G1 = pairing.getG1();Ppub = G1.newElement();Su = G1.newElement();Qu = G1.newElement();W = G1.newElement();W1 = G1.newElement();W2 = G1.newElement();h = Zr.newElement();Field GT = pairing.getGT();T = GT.newElement();T1 = GT.newElement();T2 = GT.newElement();}private void checkSymmetric(Pairing pairing){if(!pairing.isSymmetric()){throw new RuntimeException("密钥不对称");}}@Overridepublic void buildSystem() {System.out.println("---------系统建立阶段--------------");s = Zr.newRandomElement().getImmutable();P = G1.newRandomElement().getImmutable();Ppub = P.mulZn(s).getImmutable();System.out.println("P=" + P);System.out.println("s=" + s);System.out.println("Ppub=" + Ppub);}@Overridepublic void extractSecretKey() {Qu = pairing.getG1().newElement().setFromHash("IDu".getBytes(),0,3).getImmutable();Su = Qu.mulZn(s).getImmutable();System.out.println("Qu=" + Qu);System.out.println("Su=" + Su);}@Overridepublic void sign() {System.out.println("---------签名阶段--------------");r = Zr.newRandomElement().getImmutable();P1 = G1.newRandomElement().getImmutable();T = pairing.pairing(P1,P);T = T.powZn(r);h = Zr.newRandomElement().getImmutable();//模拟h = H2(m,T)W1 = P1.mulZn(r);W2 = Su.mulZn(h);W = W2.add(W1);System.out.println("h=" + h);System.out.println("W=" + W);}@Overridepublic void verify() {System.out.println("--------------验证阶段------------------");T1 = pairing.pairing(W,P);Ppub = Ppub.invert();//求Ppub的乘法逆元T2 = pairing.pairing(Qu,Ppub);//Ppub实际上是-PpubT2 = T2.powZn(h);TT = T1.mul(T2);if(TT.isEqual(T))System.out.println("T");elseSystem.out.println("F");int byte1 = W.toBytes().length;int byte2 = h.toBytes().length;System.out.println("签名的长度=" + (byte1+byte2));}public static void main(String[] args){Hess hess = new Hess();Ident identProxy = (Ident) Proxy.newProxyInstance(Hess.class.getClassLoader(),new Class[]{Ident.class},new TimeCountProxyHandle(hess));identProxy.buildSystem();identProxy.extractSecretKey();identProxy.sign();identProxy.verify();}
}
Ident 接口:
public interface Ident {void buildSystem();void extractSecretKey();void sign();void verify();
}
TimeCountProxyHandle 类:
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;public class TimeCountProxyHandle implements InvocationHandler {private Object proxied;public TimeCountProxyHandle(Object obj){proxied = obj;}@Overridepublic Object invoke(Object proxy, Method method, Object[] args) throws Throwable {long begin = System.currentTimeMillis();Object result = method.invoke(proxied,args);long end = System.currentTimeMillis();System.out.println(method.getName() + "耗时" +(end-begin) +"ms");return result;}
}
JPBC库实现基于身份的签名体制相关推荐
- JPBC库的使用实例——BLS签名
这里展示了一个简单的对JPBC库的调用的实例. 可以参考JPBC库的官方文档进行学习: http://gas.dia.unisa.it/projects/jpbc/docs/ecpg.html#Typ ...
- JPBC库(基于配对的密码学)入门和避坑指南
视频地址:https://www.bilibili.com/video/BV1o5411Y77r/ 1. JPBC简介 Java Pairing-Based Cryptography Library ...
- JPBC库应用之身份基加密IBE
身份基加密 (Identity based Encryption)算法 视频地址 https://www.bilibili.com/video/BV1Rq4y117Zw?share_source=co ...
- 基于身份的加密和签名方案——1985年Adi Shamir
基于身份的加密和签名方案--1985年Adi Shamir 在这篇论文中,我们介绍了一种新型的加密方案,这个加密方案在不需要交换公私钥,不需要密钥目录,也不需要第三方服务的情况之下,可以确保任何一对用 ...
- 使用JPBC实现双线性对加密算法(BasicIdent体制的java实现)
转自 http://blog.csdn.net/qifuchenluo/article/details/45100851 前言 现在网上关于Java版的双线性对算法的实现的代码很少,我在前段时间想找 ...
- JPBC库应用之BLS签名
JPBC库应用之BLS签名 视频地址 https://www.bilibili.com/video/BV1jA41147vt/ BLS签名简单介绍 Initialization 生成pairing参数 ...
- 基于身份的常数级环签名
0x00 写在前面 没错,又是一期的环签名,其实最近一直都在研究环签名的改进方向,论文看到现在,发现环签名或者说所有的签名机制的改进也无外乎这几个方面:时间效率(计算复杂度),签名长度(空间效率),安 ...
- 基于身份的加密(IBE)——使用PBC库实现 Identity Based Encryption(IBE) - Pairings Based Crypto (PBC) library
基于身份的加密(IBE)--使用PBC库实现 Identity Based Encryption(IBE) - Pairings Based Crypto (PBC) library 前言: 近期在学 ...
- 三种公钥密码体系(传统公开密钥体系 / 基于身份的公开密钥体系 / 基于无证书的公开密钥体系 )
公开密钥体系 分类 基于证书的公开密钥体系 基于身份的公开密钥体系 基于无证书的公开密钥体系 基于证书的公开密钥体系 第一种方案是采用证书机制实现用户的身份和用户的钥匙之间的安全对应.证书机制一般都采 ...
最新文章
- RSS - 简单方便的follow资讯
- MaxAlertView 强大的弹框试图
- 华为锁屏后微信无法连接服务器,怎么解决华为p9锁屏收不到微信信息【教程详解】...
- ubuntu 64 12.04 oracle,ubuntu server 12.04 x86_64 下安装oracle xe 11 x86_64
- mysql group where_[MySQL] 测试where group by order by的索引问题
- 关于编译FFMPEG的初级教程
- apache gobblin mysql_incubator-gobblin-master
- R语言ggplot2画图3
- IIS+PHP本地开发环境配置
- a的n次方的快速算法及大数相乘
- Objective-C对象模型及应用
- Linux源码编译nginx
- 炫酷又实用的发送邮箱链接修改密码
- c盘瘦身。清理四个垃圾文件夹
- 线性代数笔记【空间向量】
- 蕴含深刻道理的经典语录
- AXI中READY与VALID之间握手关系
- 算法题——立方体的体对角线穿过多少个正方体?
- 数据分析 学习小结记录
- 聊天界面的制作(三)——表情列表发送功能