天天看點

(3)Pairing Functions & Element Functions

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

本文摘要:

一,Pairing functions

  • 1.1 Initializing pairings
  • 1.2 Applying pairings
  • 1.3 Other pairing functions

二,Element functions

  • 2.1 Initializing elements
  • 2.2 Assigning elements
  • 2.3 Converting elements
  • 2.4 Element arithmetic
  • 2.5 Exponentiating elements
  • 2.6 Comparing elements
  • 2.7 Element I/O
  • 2.8 Random elements
  • 2.9 Element import/export

一.Pairing functions

An application should first initialize a pairing object. This causes PBC to setup curves, groups and other mathematical miscellany. After that, elements can be initialized and manipulated for cryptographic operations.

Parameters for various pairings are included with the PBC library distribution in the param subdirectory, and some are suitable for cryptographic use. Some programs in the gen subdirectory may be used to generate parameters (see Chapter 7). Also, see the PBC website for many more pairing parameters.

Pairings involve three groups of prime order. The PBC library calls them G1, G2, and GT, and calls the order r. The pairing is a bilinear map that takes two elements as input, one from G1 and one from G2, and outputs an element of GT.

The elements of G2 are at least as long as G1; G1 is guaranteed to be the shorter of the two. Sometimes G1 and G2 are the same group (i.e. the pairing is symmetric) so their elements can be mixed freely. In this case the pairing_is_symmetric function returns 1.

Bilinear pairings are stored in the data type pairing_t. Functions that operate on them start with pairing_.

【譯文】

應用程式應首先初始化一個配對對象。這導緻PBC設定曲線,組和其他數學雜項。之後,可以對元素進行初始化和操作以進行加密操作。

param子目錄中的PBC庫分布中包含用于各種配對的參數,其中一些參數适合加密使用。== gen子目錄中的某些程式可用于生成參數(請參見第7章)。另外,請參閱PBC網站以擷取更多配對參數。==

配對涉及三個主要素數階的群。 PBC庫将它們稱為G1,G2和GT,并稱階為r 。配對是一個雙線性映射,它以兩個元素作為輸入,一個來自G1,一個來自G2,并輸出GT元素。

G2的元素至少與G1一樣長; G1保證是兩者中較短的一個。有時G1和G2是同一組(即配對是對稱的),是以它們的元素可以自由組合。在這種情況下,pairing_is_symmetric函數傳回1。

雙線性對存儲在資料類型pairing_t中。對它們進行操作的功能以pairing_開頭。

1.1. Initializing pairings

To initialize a pairing from an ASCIIZ string:

pairing_t pairing; 
pairing_init_set_str(pairing, s); // Where s is a char *.
           

The string s holds pairing parameters in a text format. The param subdirectory contains several examples.

Alternatively, call:

pairing_t pairing;
pairing_init_pbc_param(pairing, param);
           

where param is an initialized pbc_param_t (see Chapter 5).

int pairing_init_set_str(pairing_t pairing, const char *s)

Initialize pairing from parameters in a ASCIIZ string str Returns 0 on success, 1 on failure.

從一個ASCIIZ串的參數初始化配對,初始化成功則傳回0,否則傳回1。

int pairing_init_set_buf(pairing_t pairing, const char *s, size_t len)

Same, but read at most len bytes. If len is 0, it behaves as the previous function. Returns 0 on success, 1 on failure.

同樣,但是最多讀取len個位元組,如果len是0,它就和上一個函數一樣。

void pairing_init_pbc_param(struct pairing_s *pairing, pbc_param_t p)

Initialize a pairing with pairing parameters p.

用配對參數p來初始化一個配對。

void pairing_clear(pairing_t pairing)

Free the space occupied by pairing. Call whenever a pairing_t variable is no longer needed. Only call this after all elements associated with pairing have been cleared, as they need information stored in the pairing structure.

釋放配對所占的空間。當一個pairing_t類型的變量沒用的時候,就可以調用這個函數來釋放該變量所占空間。因為需要存儲在配對結構中的資訊,是以隻有所有與配對有關的元素都聲明之後,才能調用這個函數。

1.2. Applying pairings

The function pairing_apply 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 pairing_t variable that relates them.

In some applications, the programmer may know that many pairings with the same G1 input will be computed. If so, preprocessing should be used to avoid repeating many calculations saving time in the long run. A variable of type pairing_pp_t should be declared, initialized with the fixed G1 element, and then used to compute pairings:

可以調用pairing_apply函數來應用雙線性映射。 輸入的順序很重要。 儲存輸出的第一個必須來自組GT。 第二個必須來自G1,第三個必須來自G2,第四個必須是與它們相關的pairing_t變量。

在某些應用中,程式員可能知道會計算出具有相同G1輸入的許多配對。 如果是這樣,從長遠來看,應該使用預處理以避免重複許多計算,進而節省了時間。 應該聲明類型為pairing_pp_t的變量,并使用固定的G1元素進行初始化,然後将其用于計算配對:

pairing_pp_t pp; 
pairing_pp_init(pp, x, pairing); // x is some element of G1 
pairing_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
           

Never mix and match G1, G2, and GT groups from different pairings.

不要混合搭配來自不同配對的G1,G2和GT群。

void pairing_pp_init(pairing_pp_t p, element_t in1, pairing_t pairing)

Get ready to perform a pairing whose first input is in1,and store the results of time-saving precomputation in p.

準備執行第一個輸入為in1的配對,存儲這個節約時間的預計算結果到p.

void pairing_pp_clear(pairing_pp_t p)

Clear p. This should be called after p is no longer needed.

清除p。當不再用pairing_pp_t類型的變量p的時候,調用這個函數來回收。

void pairing_pp_apply(element_t out, element_t in2, pairing_pp_t p)

Compute a pairing using in2 and the preprocessed information stored in p and store the output in out. The inputs to the pairing are the element previously used to initialize p and the element in2.

使用in2和存儲在p中的預處理資訊計算一個配對,将輸出存儲在out中。

void element_pairing(element_t out, element_t in1, element_t in2)

Computes a pairing: out = e(in1, in2), where in1, in2, out must be in the groups G1, G2, GT.

計算一個配對:out=e(in1,in2),in1屬于G1,in2屬于G2,out屬于GT。

void element_prod_pairing(element_t out, element_t in1[], element_t in2[], int n)

Computes the product of pairings, that is out = e(in1[0], in2[0]) … e(in1[n-1], in2[n-1]). The arrays in1, in2 must have at least n elements belonging to the groups G1, G2 respectively, and out must belong to the group GT.

計算配對的乘積,即out = e(in1 [0],in2 [0])…e(in1 [n-1],in2 [n-1])。 數組in1,in2必須至少具有分别屬于組G1,G2的n個元素,而數組out必須屬于組GT。

1.3. Other pairing functions

int pairing_is_symmetric(pairing_t pairing)

Returns true if G1 and G2 are the same group.

判斷是否對稱。

int pairing_length_in_bytes_G1(pairing_t pairing)

Returns the length in bytes needed to represent an element of G1.

傳回G1元素所需的位元組長度。

int pairing_length_in_bytes_x_only_G1(pairing_t pairing)

Returns the length in bytes needed to represent the x-coordinate of an element of G1.

傳回G1元素的x坐标所需要的位元組長度。

int pairing_length_in_bytes_compressed_G1(pairing_t pairing)

Returns the length in bytes needed to represent a compressed form of an element of G1. There is some overhead in decompressing.

傳回G1元素壓縮格式所需的位元組長度 ,解壓縮會有一些開銷。

int pairing_length_in_bytes_G2(pairing_t pairing)

Returns the length in bytes needed to represent an element of G2.

傳回G2元素所需的位元組長度。

int pairing_length_in_bytes_compressed_G2(pairing_t pairing)

Returns the length in bytes needed to represent a compressed form of an element of G2. There is some overhead in decompressing.

傳回G2元素壓縮格式所需的位元組長度 ,解壓縮會有一些開銷。

int pairing_length_in_bytes_x_only_G2(pairing_t pairing)

Returns the length in bytes needed to represent the x-coordinate of an element of G2.

傳回G2元素的x坐标所需要的位元組長度。

int pairing_length_in_bytes_GT(pairing_t pairing)

Returns the length in bytes needed to represent an element of GT.

傳回GT元素所需的位元組長度。

int pairing_length_in_bytes_Zr(pairing_t pairing)

Returns the length in bytes needed to represent an element of Zr.

傳回Zr元素所需的位元組長度。

二.Element functions

Elements of groups, rings and fields are stored in the element_t data type. Variables of this type must be initialized before use, and should be cleared after they are no longer needed.

The element_ functions must be used with caution. Just as division by zero does not make sense for integers, some operations may not make sense for particular elements. For example, in a ring, one cannot in general invert elements.

Another caveat is that many of these functions assume their arguments come from the same ring, group or field. No implicit type casting is performed.

For debug builds, turn on run-time checks by defining PBC_DEBUG before including pbc.h:

#define PBC_DEBUG 
#include <pbc.h>
           

Also, when PBC_DEBUG is defined, the following macros are active. Normally they are replaced with empty statements.

PBC_ASSERT(expr,msg)
           

Macro: if expr evaluates to 0, print msg and exit.

PBC_ASSERT_MATCH2(a,b)
           

Macro: if elements a and b are from different fields then exit.

PBC_ASSERT_MATCH3(a,b,c)
           

Macro: if elements a, b and c are from different fields then exit.

【譯文】

群,環和域的元素存儲在element_t資料類型中。此類型的變量必須在使用前進行初始化,并在不再需要它們後清除。

必須謹慎使用element_函數。正如零除對整數沒有意義,某些操作對特定元素可能沒有意義。例如,在一環中,通常不能反轉元素。另一個警告是,這些函數中的許多函數都假定它們的參數來自同一環,組或字段。不執行隐式類型轉換。

對于調試版本,通過在包含

pbc.h

之前定義

PBC_DEBUG

來打開運作時檢查:

#define PBC_DEBUG 
#include<pbc.h>
           

另外,定義

PBC_DEBUG

時,以下宏處于活動狀态。通常,它們用空語句替換。

PBC_ASSERT(expr,msg)
           

Macro:如果expr計算為0,則列印msg并退出。

PBC_ASSERT_MATCH2(a,b)
           

Macro:如果元素a和b來自不同的字段,則退出。

PBC_ASSERT_MATCH3(a,b,c)
           

Macro:如果元素a,b和c來自不同的字段,則退出。

2.1. Initializing elements

When an element is initialized it is associated with an algebraic structure, such as a particular finite field or elliptic curve group.

We use G1 and G2 to denote the input groups to the pairing, and GT for the output group. All have order r, and Zr means the ring of integers modulo r. G1 is the smaller group (the group of points over the base field). With symmetric pairings, G1 = G2.

當元素被初始化時,它與代數結構相關聯,例如特定的有限域或橢圓曲線組。

我們使用G1和G2表示配對的輸入組,并使用GT表示輸出組。都具有r階,Zr表示以r為模的整數環。 G1是較小的組(基域上的點組)。對于對稱配對,G1 = G2。

void element_init_G1(element_t e, pairing_t pairing)

初始化e為G1群上的元素。

void element_init_G2(element_t e, pairing_t pairing)

初始化e為G2群上的元素。

void element_init_GT(element_t e, pairing_t pairing)

Initialize e to be an element of the group G1, G2 or GT of pairing.

初始化e為GT群上的元素。

void element_init_Zr(element_t e, pairing_t pairing)

Initialize e to be an element of the ring Z_r of pairing. r is the order of the groups G1, G2 and GT that are involved in the pairing.

初始化e為配對上的環Zr上的一個元素。r是配對中的群G1,G2,GT的階。

void element_init_same_as(element_t e, element_t e2)

Initialize e to be an element of the algebraic structure that e2 lies in.

初始化e為e2所在代數結構的一個元素。

void element_clear(element_t e)

Free the space occupied by e. Call this when the variable e is no longer needed.

當變量e不再使用的時候調用這個函數來釋放e占用的空間。

2.2. Assigning elements

These functions assign values to elements. When integers are assigned, they are mapped to algebraic structures canonically if it makes sense (e.g. rings and fields).

void element_set0(element_t e)

Set e to zero.

設定e的值為0。

void element_set1(element_t e)

Set e to one.

設定e的值為1。

void element_set_si(element_t e, signed long int i)

Set e to i.

設定e的值為i。

void element_set_mpz(element_t e, mpz_t z)

Set e to z.

設定e的值為z的值。

void element_set(element_t e, element_t a)

Set e to a.

設定e的值為元素a的值。

2.3. Converting elements

void element_to_mpz(mpz_t z, element_t e)

Converts e to a GMP integer z if such an operation makes sense.

在有意義的前提下,将z轉化為一個GMP整數。

void element_from_hash(element_t e, void *data, int len)

Generate an element e deterministically from the len bytes stored in the buffer data.

根據存儲在緩沖區的len位元組長度的資料,确定性地生成一個元素e。

2.4. Element arithmetic

Unless otherwise stated, all element_t arguments to these functions must have been initialized to be from the same algebraic structure. When one of these functions expects its arguments to be from particular algebraic structures, this is reflected in the name of the function.

The addition and multiplication functions perform addition and multiplication operations in rings and fields. For groups of points on an ellitpic curve, such as the G1 and G2 groups associated with pairings, both addition and multiplication represent the group operation (and similarly both 0 and 1 represent the identity element). It is recommended that programs choose and one convention and stick with it to avoid confusion.

In contrast, the GT group is currently implemented as a subgroup of a finite field, so only multiplicative operations should be used for GT.

【譯文】

除非另有說明,否則這些函數的所有element_t參數都必須已初始化為來自相同的代數結構。 當某個函數的參數是特定的代數結構時,将以函數的名稱反映出來。

加法和乘法功能在環和域中執行加法和乘法運算。 對于橢圓曲線上的點組,例如與配對關聯的群G1和G2,加法和乘法均表示群操作(類似地,0和1均表示辨別元素)。 建議程式選擇一個約定,并遵守約定以避免混淆。

相比之下,群GT目前被實作為有限域的子群,是以GT僅使用乘法運算。

void element_add(element_t n, element_t a, element_t b)

Set n to a + b.

void element_sub(element_t n, element_t a, element_t b)

Set n to a - b.

void element_mul(element_t n, element_t a, element_t b)

Set n = a*b.

void element_mul_mpz(element_t n, element_t a, mpz_t z)
void element_mul_si(element_t n, element_t a, signed long int z)

Set n = a z, that is a + a + … + a where there are z a’s.

設定n = a*z,即a + a + … + a,其中有z 個a。

void element_mul_zn(element_t c, element_t a, element_t z)

z must be an element of a integer mod ring (i.e.Zn for some n). Set c = a*z, that is a + a + … + a where there are z a’s.

z必須是一個整數模環的元素(即對于某個n的環Zn)。設定 c = a*z,即a + a + … + a,z個a相加。

void element_div(element_t n, element_t a, element_t b)

Set n = a / b.

void element_double(element_t n, element_t a)

Set n = a + a.

void element_halve(element_t n, element_t a)

Set n = a/2.

void element_square(element_t n, element_t a)

Set n = a2.

設定n為a的平方。

void element_neg(element_t n, element_t a)

Set n = -a.

void element_invert(element_t n, element_t a)

Set n to the inverse of a.

設定n為a的倒數。

2.5. Exponentiating elements(求幂元素)

Exponentiation and multiexponentiation functions. If it is known in advance that a particular element will be exponentiated several times in the future, time can be saved in the long run by first calling the preprocessing function:

求幂和乘幂函數。 如果事先知道某個特定元素将來會被取幂,那麼從長遠來看,可以通過首先調用預處理函數來節省時間:

element_pp_t g_pp; 
element_pp_init(g_pp, g); 
element_pp_pow(h, pow1, g_pp); // h = g^pow1 
element_pp_pow(h, pow2, g_pp); // h = g^pow2 
element_pp_pow(h, pow3, g_pp); // h = g^pow3 
element_pp_clear(g_pp);
           
void element_pow_mpz(element_t x, element_t a, mpz_t n)

Set x = an, that is a times a times … times a where there are n a’s.

設定x = an。

void element_pow_zn(element_t x, element_t a, element_t n)

Set x=an,where n is an element of a ring ZN for some N (typically the order of the algebraic structure x lies in).

令x=an,n是某個整數N的環ZN上的元素(N通常是x所在代數結構的階)。

void element_pow2_mpz(element_t x, element_t a1, mpz_t n1, element_t a2, mpz_t n2)

Sets x = a1n1 a2 n2, and is generally faster than performing two separate exponentiations.

令x=a1n1 a2n2,通常比分别執行求幂運算要快。

void element_pow2_zn(element_t x, element_t a1, element_t n1, element_t a2, element_t n2)

Also sets x = a1n1 a2n2, but n1, n2 must be elements of a ring Zn for some integer n.

同上,但是要求n1,n2必須是對于某個整數n的環Zn上的元素;

void element_pow3_mpz(element_t x, element_t a1, mpz_t n1, element_t a2, mpz_t n2, element_t a3, mpz_t n3)

Sets x = a1n1 a2n2 a3n3, generally faster than performing three separate exponentiations.

x = a1n1 a2n2 a3n3,通常比執行三個單獨的求幂運算要快;

void element_pow3_zn(element_t x, element_t a1, element_t n1, element_t a2, element_t n2, element_t a3, element_t n3)

Also sets x = a1n1 a2n2 a3n3, but n1, n2, n3 must be elements of a ring Zn for some integer n.

x = a1n1 a2n2 a3n3,但是,n1,n2,n3必須是對于某個整數n上的環Zn的元素;

void element_pp_init(element_pp_t p, element_t in)

Prepare to exponentiate an element in, and store preprocessing information in p.

準備在p中對元素求幂,并且将預處理資訊儲存到p中;

void element_pp_clear(element_pp_t p)

Clear p. Should be called after p is no longer needed.

當p不再使用的時候,清除p;

void element_pp_pow(element_t out, mpz_t power, element_pp_t p)

Raise in to power and store the result in out, where in is a previously

preprocessed element, that is, the second argument passed to a previouselement_pp_initcall.

将in提高到power以将結果存儲到out中,其中in是先前預處理的元素,即,傳遞給先前element_pp_init調用的第二個參數。

void element_pp_pow_zn(element_t out, element_t power, element_pp_t p)

Same except power is an element ofZn for some integer n.

power是基于整數n的環Zn的一個元素,除此之外都

void element_dlog_brute_force(element_t x, element_t g, element_t h)

Computes x such that gx= h by brute force, where x lies in a field where element_set_mpz() makes sense.

以暴力的方式計算x,使得gx=h,其中x位于使element_set_mpz()有意義的域中;

void element_dlog_pollard_rho(element_t x, element_t g, element_t h)

Computes x such that gx = h using Pollard rho method, where x lies in a field where element_set_mpz() makes sense.

使用Pollard rho方法計算x,使得gx=h,其中x位于使得element_set_mpz()有意義的域中;

2.6. Comparing elements

These functions compare elements from the same algebraic structure.

int element_is1(element_t n)

Returns true if n is 1.

int element_is0(element_t n)

Returns true if n is 0.

int element_cmp(element_t a, element_t b)

Returns 0 if a and b are the same, nonzero otherwise.

如果a,b相等,傳回0;否則傳回非0值;

int element_is_sqr(element_t a)

Returns nonzero if a is a perfect square (quadratic residue), zero otherwise.

如果a是一個完全平方數(二次剩餘),傳回非0值;否則,傳回0;

int element_sgn(element_t a)
int element_sign(element_t a)

If a is zero, returns 0. For nozero a the behaviour depends on the algebraic structure, but has the property that element_sgn(a) = -element_sgn(-a) and element_sgn(a) = 0 implies a = 0 with overwhelming probability.

如果a為零,則傳回0。對于非零a,其行為取決于代數結構,但具有element_sgn(a)= -element_sgn(-a)和element_sgn(a)= 0的性質表示a = 0的可能性很大。

2.7. Element I/O

Functions for producing human-readable outputs for elements. Converting elements to and from bytes are discussed later.

這些函數用于生成可讀的元素輸出。稍後讨論元素與位元組之間的轉換。

size_telement_out_str(FILE * stream, int base, element_t e)

Output e on stream in base base. The base must be between 2 and 36.

以基數為基礎在流上輸出e。底數必須在2到36之間。

int element_printf(const char *format, …)
int element_fprintf(FILE * stream, const char *format, …)
int element_snprintf(char *buf, size_t size, const char *fmt, …)
int element_vsnprintf(char *buf, size_t size, const char *fmt, va_list ap)

Same as printf family except also has the B conversion specifier for types ofelement_t, and Y, Z conversion specifiers for mpz_t.

For example if e is of type element_t then

element_printf("%B\n", e);

will print the value of e in a human-readable form on standard output.

與printf家族相同,除了對element_t類型具有B轉換說明符,對于mpz_t具有Y,Z轉換說明符。

例如,如果e是一個element_t類型的元素,那麼,element_printf(“%B\n”,e);将會以一種可讀的方式将e的值輸出到标準輸出中;

int element_snprint(char *s, size_t n, element_t e)

Convert an element to a human-friendly string. Behaves as snprintfbut only on one element at a time.

将元素轉換為人類友好的字元串。表現為snprintf,但一次僅作用于一個元素。

int element_set_str(element_t e, const char *s, int base)

Set the element e from s, a null-terminated C string in base base. Whitespace is ignored. Points have the form “[x,y]” or “O”, while polynomials have the form “[a0,…,an]”. Returns number of characters read (unlike GMP’s mpz_set_str). A return code of zero means PBC could not find a well-formed string describing an element.

從s設定元素e,s是基數為null終止的C字元串。空格被忽略。點的形式為“ [x,y]”或“ O”,而多項式的形式為“ [a0,…,an]”。傳回讀取的字元數(與GMP的mpz_set_str不同)。傳回碼為零表示PBC無法找到描述元素的格式正确的字元串。

2.8. Random elements

Only works for finite algebraic structures. Effect on polynomial rings, fields of characteristic zero, etc. undefined.

See Section 6.1 for how PBC gets random bits.

僅适用于有限的代數結構。 未定義對多項式環,特征零域等的影響。

有關PBC如何擷取随機位的資訊,請參見第6.1節。

void element_random(element_t e)

If the e lies in a finite algebraic structure, assigns a uniformly random element to e.

如果e位于有限的代數結構中,則将均勻随機元素配置設定給e。

2.9. Element import/export

Functions for serializing and deserializing elements.

進行元素序列化和元素反序列化的函數。

int element_length_in_bytes(element_t e)

Returns the length in bytes the element e will take to represent

傳回元素e的位元組長度;

int element_to_bytes(unsigned char *data, element_t e)

Converts e to byte, writing the result in the buffer data. The number of bytes it will write can be determined from callingelement_length_in_bytes(). Returns number of bytes written.

把元素e轉化為位元組,并把結果寫到緩存區資料。通過調用函數element_length_in_bytes()來确定寫入的位元組數。并傳回寫入的位元組數。

int element_from_bytes(element_t e, unsigned char *data)

Reads e from the buffer data, and returns the number of bytes read.

從緩沖區資料讀取e,并且傳回讀取的位元組數。

int element_to_bytes_x_only(unsigned char *data, element_t e)

Assumes e is a point on an elliptic curve. Writes the x-coordinate of e to the buffer data

假設e是橢圓曲線上的一個點。把e的x坐标寫到緩沖區資料。

int element_from_bytes_x_only(element_t e, unsigned char *data)

Assumes e is a point on an elliptic curve. Sets e to a point with x-coordinate represented by the buffer data. This is not unique.For each x-coordinate, there exist two different points,at least for the elliptic curves in PBC. (They are inverses of each other.)

假設e是一個橢圓曲線上的點。根據緩沖區資料所存儲的x坐标來設定e的值。這個值并不是唯一的。對于每個x坐标,在PBC的橢圓曲線上都至少有兩個不同的點與之對應。(它們是互為倒數)

int element_length_in_bytes_x_only(element_t e)

Assumes e is a point on an elliptic curve. Returns the length in bytes needed to hold the x-coordinate of e.

假設e是一個橢圓曲線上的點。傳回存儲e的x坐标所需要的位元組長度。

int element_to_bytes_compressed(unsigned char *data, element_t e)

If possible, outputs a compressed form of the element e to the buffer of bytes data.Currently only implemented for points on an elliptic curve.

如果可能,将元素e的壓縮形式輸出到位元組資料緩沖區。目前僅對橢圓曲線上的點實施。

int element_from_bytes_compressed(element_t e, unsigned char *data)

Sets element e to the element in compressed form in the buffer of bytes data. Currently only implemented for points on an elliptic curve.

在位元組資料緩沖區中将元素e設定為壓縮形式的元素。目前僅對橢圓曲線上的點實施。

int element_length_in_bytes_compressed(element_t e)

Returns the number of bytes needed to hold e in compressed form. Currently only implemented for points on an elliptic curve.

傳回以壓縮形式儲存e所需的位元組數。目前僅對橢圓曲線上的點實施。

int element_item_count(element_t e)

For points, returns the number of coordinates. For polynomials, returns the number of coefficients. Otherwise returns zero.

對于點,傳回坐标數。對于多項式,傳回系數數。否則傳回零。

element_telement_item(element_t e, int i)

For points, returns nth coordinate. For polynomials, returns coefficient of xn. Otherwise returns NULL. The element the return value points to may be modified.

對于點,傳回第n個坐标。對于多項式,傳回系數xn。否則傳回NULL。傳回值指向的元素可以修改。

element_telement_x(element_t a)

Equivalent to element_item(a, 0).

等價于element_item(a,0);

element_telement_y(element_t a)

Equivalent to element_item(a, 1).

等價于element_telement_y(element_t a)