📄 pairingfns.xml
字号:
<chapter><title>Pairing Functions</title><para>An application will most likely need to instantiate a bilinear pairingbefore performing any other operations.The easiest way to do this is to initialize a pairing withpreviously-generated pairing parameters.</para><para>Parameters for various pairings are included withthe PBC library distribution in the<filename>param</filename> subdirectory and shouldbe suitable for cryptographic use. Some programs inthe <filename>gen</filename> subdirectory may be used togenerate parameters (see the chapter on bundled programs).Also, on the PBC website an archive containing many pairingparameters is available for download.</para><para>Particular instantiations of bilinear pairings are stored in the datatype <type>pairing_t</type>. Functions that operate on themstart with <function>pairing_</function>.</para><para>Pairings involve three groups of prime order. The PBC library labels themG1, G2, and GT, and labels the order r. The pairing isa bilinear map that takes two elements as input,one from G1 and one from G2, and outputs an element of GT.</para><para>The elements of G2 are at least as long as G1; G1 is guaranteed to be theshorter of the two. Sometimes G1 and G2 are the same group (i.e. the pairingis symmetric) so their elements can be mixed freely. In this case the<function>pairing_is_symmetric</function> function returns 1.</para><para>A <link linkend="chapter.param">later chapter</link> discusses the differentpairing types.</para><section><title>Initializing Pairings</title><para>The only way to initialize a pairingis to provide pairing parameters to a <type>pairing_t</type>variable using one of the functionsbeginning with <function>pairing_init_inp_</function>. For example,</para><programlisting>{ pairing_t pairing; pairing_init_inp_str(pairing, stdin);}</programlisting><para>will initialize <parameter>pairing</parameter> withparameters are fed to the program on standardinput.</para><para>The format of the pairing parameters is a text format thatis output by the param functions.</para><variablelist>&pairing_init;</variablelist></section><section><title>Applying Pairings</title><para>The function <command>pairing_apply</command>can be called to apply a bilinear map.The order of the inputs is important. The first, which holds the output,must be from the group GT. The second must be from G1, the third from G2,and the fourth must be the <type>pairing_t</type> variable that relates them.(One cannot mix and match G1, G2, and GT groups from different pairings.)</para><para>In some applications, the programmer may know that many pairings with thesame G1 input will be computed. In this case, preprocessing should be usedto avoid repeating many calculations saving time in the long run.A variable of type <type>pairing_pp_t</type> should be declared,initialized with the fixed G1 element, and then used to compute pairings:</para><programlisting>pairing_pp_t pp;pairing_pp_init(pp, x, pairing); //x is some element of G1pairing_pp_apply(r1, y1, pp); //r1 = e(x, y1)pairing_pp_apply(r2, y2, pp); //r2 = e(x, y2)pairing_pp_clear(pp); //don't need pp anymore</programlisting><variablelist>&pairing_apply;</variablelist></section><section><title>Other Pairing Functions</title><variablelist>&pairing_op;</variablelist></section></chapter>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -