(2)一起来读PBC Library manual !!!

本文是PBC Library手册的解读,主要介绍了如何使用PBC库实现Boneh-Lynn-Shacham(BLS)签名方案。通过初始化配对、生成系统参数、公私钥以及签名和验证过程,详细阐述了BLS签名的实现步骤。
摘要由CSDN通过智能技术生成

以下内容源自PBC Library 的 英文manual(Chapter 2)。

本文摘要:

一,Basics
二,Tutorial
三,BLS Signature
四,Import / Export
五,完整示例

一,Basics

Programs using the PBC library should include the file pbc.h:

#include <pbc.h>

and linked against the PBC library and the GMP library, e.g.

$ gcc program.c -L. -lpbc -lgmp

The file pbc.h already includes gmp.h.

PBC follows GMP in several respects:

• Output arguments generally precede input arguments.

• The same variable can be used as input and output in one call.

• Before a variable may be used it must be initialized exactly once. When no longer needed it must be cleared. For efficiency, unnecessary initializating and clearing should be avoided.

• PBC variables ending with _t behave the same as GMP variables in function calls: effectively as call-by references. In other words, as in GMP, if a function that modifies an input variable, that variable remains modified when control return is returned to the caller.

• Like GMP, variables automatically allocate memory when needed. By default, malloc() and friends are called but this can be changed.

• PBC functions are mostly reentrant.

Since the PBC library is built on top of GMP, the GMP types are available. PBC types are similar to GMP types. The following example is paraphrased from an example in the GMP manual, and shows how to declare the PBC data type element_t.

element_t sum;
struct foo {
    element_t x, y; }; 
element_t vec[20];

GMP has the mpz_t type for integers, mpq_t for rationals and so on. In contrast, PBC uses the element_t data type for elements of different algebraic structures, such as elliptic curve groups, polynomial rings and finite fields. Functions assume their inputs come from appropriate algebraic structures.

GMP具有用于整数的mpz_t类型,用于有理数的mpq_t等。 相反,PBC将element_t数据类型用于不同代数结构的元素,例如椭圆曲线群,多项式环和有限域。 函数假定其输入来自适当的代数结构。

PBC data types and functions can be categorized as follows. The first two alone suffice for a range PBC of applications.

PBC数据类型和功能可以分类如下。 头两个应用程序就可以满足要求。

• element_t: elements of an algebraic structure.

• pairing_t: pairings where elements belong; can initialize from sample pairing parameters bundled with PBC in the param subdirectory.

【译】
pairing_t:元素所属的配对; 可以根据param子目录中与PBC捆绑在一起的样品配对参数进行初始化。

• pbc_param_t: used to generate pairing parameters.

• pbc_cm_t: parameters for constructing curves via the CM method; sometimes required by pbc_param_t.

• field_t: algebraic structures: groups, rings and fields; used internally by pairing_t.

• a few miscellaneous functions, such as ones controlling how random bits are generated.
Functions operating on a given data type usually have the same prefix, e.g. those involving element_t objects begin with element_.

二,Tutorial (介绍)

This chapter walks through how one might implement the Boneh-Lynn-Shacham (BLS) signature scheme using the PBC library. It is based on the file example/bls.c.

We have three groups G1, G2, GT of prime order r, and a bilinear map e that takes an element from G1 and an element from G2, and outputs an element of GT. We publish these along with the system parameter g, which is a randomly chosen element of G2.

Alice wishes to sign a message. She generates her public and private keys as follows. Her private key is a random element x of Zr, and her corresponding public key is g x g^{x} gx.

To sign a message, Alice hashes the message to some element h of G1, and then outputs the signature h x h^x hx.

To verify a signature σ, Bob checks that e(h, g x g^x gx) = e(σ, g).

We now translate the above to C code using the PBC library.

【译文】

本章介绍如何使用PBC库实现Boneh-Lynn-Shacham(BLS)签名方案。 它基于文件example / bls.c。(bls.c这个文件在pbc 库中example目录下)

我们有三组素数阶为r的群G1,G2,GT,以及一个双线性映射e,它需要一个G1的元素和一个G2的元素,然后输出GT元素。 我们将它们与系统参数g一起发布,系统参数g是从G2中随机选择的一个元素。

爱丽丝想要对一个消息签名。 她按如下方式生成她的公钥和私钥。 她的私钥是Zr(模r的剩余环)中的一个随机选取的元素x,而她对应的公钥是 g x g^x gx

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值