BN254

package
v0.1.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const AESKEY int = 16
View Source
const ATE_BITS int = 66
View Source
const BAD_PARAMS int = -11
View Source
const BAD_PIN int = -19
View Source
const BASEBITS uint = 56
View Source
const BFS int = int(MODBYTES)
View Source
const BGS int = int(MODBYTES)
View Source
const BIGBITS int = int(MODBYTES * 8)
View Source
const BLS int = 2
View Source
const BLS_FAIL int = -1
View Source
const BLS_OK int = 0
View Source
const BN int = 1
View Source
const CHUNK int = 64 /* Set word size */
View Source
const CURVETYPE int = WEIERSTRASS
View Source
const CURVE_A int = 0
View Source
const CURVE_B_I int = 2
View Source
const CURVE_Cof_I int = 1
View Source
const CURVE_PAIRING_TYPE int = BN
View Source
const DNLEN int = 2 * NLEN
View Source
const D_TYPE int = 0

Pairing Twist type

View Source
const EDWARDS int = 1
View Source
const EFS int = int(MODBYTES)
View Source
const EGS int = int(MODBYTES)
View Source
const ERROR int = -3
View Source
const FEXCESS int32 = ((int32(1) << 26) - 1)
View Source
const FP_DENSE int = 4
View Source
const FP_ONE int = 1
View Source
const FP_SPARSE int = 3
View Source
const FP_SPARSER int = 2
View Source
const FP_ZERO int = 0

Sparsity

View Source
const GENERALISED_MERSENNE int = 3
View Source
const HASH_TYPE int = 32
View Source
const HBITS uint = (BASEBITS / 2)
View Source
const INVALID int = -4
View Source
const INVALID_POINT int = -14
View Source
const INVALID_PUBLIC_KEY int = -2
View Source
const MAXPIN int32 = 10000 /* PIN less than this */
View Source
const MFS int = int(MODBYTES)
View Source
const MGS int = int(MODBYTES)
View Source
const MOD8 uint = 3 /* Modulus mod 8 */
View Source
const MODBITS uint = 254 /* Number of bits in Modulus */

Modulus details

View Source
const MODBYTES uint = 32

BIG length in bytes and number base

View Source
const MODTYPE int = NOT_SPECIAL //NOT_SPECIAL
View Source
const MONTGOMERY int = 2
View Source
const MONTGOMERY_FRIENDLY int = 2
View Source
const M_TYPE int = 1
View Source
const NEGATIVEX int = 1
View Source
const NEXCESS int = (1 << (uint(CHUNK) - BASEBITS - 1))
View Source
const NLEN int = int((1 + ((8*MODBYTES - 1) / BASEBITS)))

BIG lengths and Masks

View Source
const NOT int = 0

Pairing Friendly?

View Source
const NOT_SPECIAL int = 0

Modulus types

View Source
const PBLEN int32 = 14 /* Number of bits in PIN */
View Source
const POSITIVEX int = 0

Pairing x parameter sign

View Source
const PSEUDO_MERSENNE int = 1
View Source
const SEXTIC_TWIST int = D_TYPE
View Source
const SIGN_OF_X int = NEGATIVEX
View Source
const TBITS uint = MODBITS % BASEBITS // Number of active bits in top word
View Source
const TRAP int = 200 /* 200 for 4 digit PIN, 2000 for 6-digit PIN  - approx 2*sqrt(MAXPIN) */
View Source
const TS int = 10 /* 10 for 4 digit PIN, 14 for 6-digit PIN - 2^TS/TS approx = sqrt(MAXPIN) */
View Source
const USE_GLV bool = true
View Source
const USE_GS_G2 bool = true
View Source
const USE_GS_GT bool = true
View Source
const WEIERSTRASS int = 0

Curve types

View Source
const WRONG_ORDER int = -18

Variables

View Source
var CURVE_B = [...]Chunk{0x2, 0x0, 0x0, 0x0, 0x0}
View Source
var CURVE_BB = [4][4][5]Chunk{{{0x8000000000000D, 0x80000000001060, 0x8000000007FF9F, 0x40000001BA344D, 0x25236482}, {0x8000000000000C, 0x80000000001060, 0x8000000007FF9F, 0x40000001BA344D, 0x25236482}, {0x8000000000000C, 0x80000000001060, 0x8000000007FF9F, 0x40000001BA344D, 0x25236482}, {0x2, 0x81, 0x0, 0x0, 0x0}}, {{0x1, 0x81, 0x0, 0x0, 0x0}, {0x8000000000000C, 0x80000000001060, 0x8000000007FF9F, 0x40000001BA344D, 0x25236482}, {0x8000000000000D, 0x80000000001060, 0x8000000007FF9F, 0x40000001BA344D, 0x25236482}, {0x8000000000000C, 0x80000000001060, 0x8000000007FF9F, 0x40000001BA344D, 0x25236482}}, {{0x2, 0x81, 0x0, 0x0, 0x0}, {0x1, 0x81, 0x0, 0x0, 0x0}, {0x1, 0x81, 0x0, 0x0, 0x0}, {0x1, 0x81, 0x0, 0x0, 0x0}}, {{0x80000000000002, 0x40, 0x0, 0x0, 0x0}, {0x2, 0x102, 0x0, 0x0, 0x0}, {0xA, 0x80000000001020, 0x8000000007FF9F, 0x40000001BA344D, 0x25236482}, {0x80000000000002, 0x40, 0x0, 0x0, 0x0}}}
View Source
var CURVE_Bnx = [...]Chunk{0x80000000000001, 0x40, 0x0, 0x0, 0x0}
View Source
var CURVE_Cof = [...]Chunk{0x1, 0x0, 0x0, 0x0, 0x0}
View Source
var CURVE_Cru = [...]Chunk{0x80000000000007, 0x6CD, 0x40000000024909, 0x49B362, 0x0}
View Source
var CURVE_Gx = [...]Chunk{0x12, 0x13A7, 0x80000000086121, 0x40000001BA344D, 0x25236482}
View Source
var CURVE_Gy = [...]Chunk{0x1, 0x0, 0x0, 0x0, 0x0}
View Source
var CURVE_Order = [...]Chunk{0xD, 0x800000000010A1, 0x8000000007FF9F, 0x40000001BA344D, 0x25236482}
View Source
var CURVE_Pxa = [...]Chunk{0xEE4224C803FB2B, 0x8BBB4898BF0D91, 0x7E8C61EDB6A464, 0x519EB62FEB8D8C, 0x61A10BB}
View Source
var CURVE_Pxb = [...]Chunk{0x8C34C1E7D54CF3, 0x746BAE3784B70D, 0x8C5982AA5B1F4D, 0xBA737833310AA7, 0x516AAF9}
View Source
var CURVE_Pya = [...]Chunk{0xF0E07891CD2B9A, 0xAE6BDBE09BD19, 0x96698C822329BD, 0x6BAF93439A90E0, 0x21897A0}
View Source
var CURVE_Pyb = [...]Chunk{0x2D1AEC6B3ACE9B, 0x6FFD739C9578A, 0x56F5F38D37B090, 0x7C8B15268F6D44, 0xEBB2B0E}
View Source
var CURVE_SB = [2][2][5]Chunk{{{0x4, 0x80000000000285, 0x6181, 0x0, 0x0}, {0x1, 0x81, 0x0, 0x0, 0x0}}, {{0x1, 0x81, 0x0, 0x0, 0x0}, {0xA, 0xE9D, 0x80000000079E1E, 0x40000001BA344D, 0x25236482}}}
View Source
var CURVE_W = [2][5]Chunk{{0x3, 0x80000000000204, 0x6181, 0x0, 0x0}, {0x1, 0x81, 0x0, 0x0, 0x0}}
View Source
var CURVE_WB = [4][5]Chunk{{0x80000000000000, 0x80000000000040, 0x2080, 0x0, 0x0}, {0x80000000000005, 0x54A, 0x8000000001C707, 0x312241, 0x0}, {0x80000000000003, 0x800000000002C5, 0xC000000000E383, 0x189120, 0x0}, {0x80000000000001, 0x800000000000C1, 0x2080, 0x0, 0x0}}
View Source
var Fra = [...]Chunk{0x7DE6C06F2A6DE9, 0x74924D3F77C2E1, 0x50A846953F8509, 0x212E7C8CB6499B, 0x1B377619}
View Source
var Frb = [...]Chunk{0x82193F90D5922A, 0x8B6DB2C08850C5, 0x2F57B96AC8DC17, 0x1ED1837503EAB2, 0x9EBEE69}
View Source
var Modulus = [...]Chunk{0x13, 0x13A7, 0x80000000086121, 0x40000001BA344D, 0x25236482}

Base Bits= 56

View Source
var R2modp = [...]Chunk{0x2F2A96FF5E7E39, 0x64E8642B96F13C, 0x9926F7B00C7146, 0x8321E7B4DACD24, 0x1D127A2E}

Functions

func AES_CBC_IV0_DECRYPT

func AES_CBC_IV0_DECRYPT(K []byte, C []byte) []byte

returns plaintext if all consistent, else returns null string

func AES_CBC_IV0_ENCRYPT

func AES_CBC_IV0_ENCRYPT(K []byte, M []byte) []byte

AES encryption/decryption. Encrypt byte array M using key K and returns ciphertext

func Comp

func Comp(a *BIG, b *BIG) int

Compare a and b, return 0 if a==b, -1 if a<b, +1 if a>b. Inputs must be normalised

func ECDH_ECIES_DECRYPT

func ECDH_ECIES_DECRYPT(sha int, P1 []byte, P2 []byte, V []byte, C []byte, T []byte, U []byte) []byte

IEEE1363 ECIES decryption. Decryption of ciphertext V,C,T using private key U outputs plaintext M

func ECDH_ECIES_ENCRYPT

func ECDH_ECIES_ENCRYPT(sha int, P1 []byte, P2 []byte, RNG *amcl.RAND, W []byte, M []byte, V []byte, T []byte) []byte

IEEE1363 ECIES encryption. Encryption of plaintext M uses public key W and produces ciphertext V,C,T

func ECDH_ECPSP_DSA

func ECDH_ECPSP_DSA(sha int, RNG *amcl.RAND, S []byte, F []byte, C []byte, D []byte) int

IEEE ECDSA Signature, C and D are signature on F using private key S

func ECDH_ECPSVDP_DH

func ECDH_ECPSVDP_DH(S []byte, WD []byte, Z []byte) int

IEEE-1363 Diffie-Hellman online calculation Z=S.WD

func ECDH_ECPVP_DSA

func ECDH_ECPVP_DSA(sha int, W []byte, F []byte, C []byte, D []byte) int

IEEE1363 ECDSA Signature Verification. Signature C and D on F is verified using public key W

func ECDH_KDF1

func ECDH_KDF1(sha int, Z []byte, olen int) []byte

Key Derivation Functions Input octet Z Output key of length olen

func ECDH_KDF2

func ECDH_KDF2(sha int, Z []byte, P []byte, olen int) []byte

func ECDH_KEY_PAIR_GENERATE

func ECDH_KEY_PAIR_GENERATE(RNG *amcl.RAND, S []byte, W []byte) int

Calculate a public/private EC GF(p) key pair W,S where W=S.G mod EC(p), * where S is the secret key and W is the public key * and G is fixed generator. * If RNG is NULL then the private key is provided externally in S * otherwise it is generated randomly internally

func ECDH_PBKDF2

func ECDH_PBKDF2(sha int, Pass []byte, Salt []byte, rep int, olen int) []byte

Password based Key Derivation Function Input password p, salt s, and repeat count Output key of length olen

func ECDH_PUBLIC_KEY_VALIDATE

func ECDH_PUBLIC_KEY_VALIDATE(W []byte) int

validate public key

func HMAC

func HMAC(sha int, M []byte, K []byte, tag []byte) int

Calculate HMAC of m using key k. HMAC is tag of length olen (which is length of tag)

func KeyPairGenerate

func KeyPairGenerate(rng *amcl.RAND, S []byte, W []byte) int

func MPIN_CLIENT

func MPIN_CLIENT(sha int, date int, CLIENT_ID []byte, RNG *amcl.RAND, X []byte, pin int, TOKEN []byte, SEC []byte, xID []byte, xCID []byte, PERMIT []byte, TimeValue int, Y []byte) int

One pass MPIN Client

func MPIN_CLIENT_1

func MPIN_CLIENT_1(sha int, date int, CLIENT_ID []byte, rng *amcl.RAND, X []byte, pin int, TOKEN []byte, SEC []byte, xID []byte, xCID []byte, PERMIT []byte) int

Implement step 1 on client side of MPin protocol

func MPIN_CLIENT_2

func MPIN_CLIENT_2(X []byte, Y []byte, SEC []byte) int

Implement step 2 on client side of MPin protocol

func MPIN_CLIENT_KEY

func MPIN_CLIENT_KEY(sha int, G1 []byte, G2 []byte, pin int, R []byte, X []byte, H []byte, wCID []byte, CK []byte) int

calculate common key on client side wCID = w.(A+AT)

func MPIN_DECODING

func MPIN_DECODING(D []byte) int

func MPIN_ENCODING

func MPIN_ENCODING(rng *amcl.RAND, E []byte) int

these next two functions implement elligator squared - http://eprint.iacr.org/2014/043 Elliptic curve point E in format (0x04,x,y} is converted to form {0x0-,u,v} Note that u and v are indistinguisible from random strings

func MPIN_EXTRACT_FACTOR

func MPIN_EXTRACT_FACTOR(sha int, CID []byte, factor int32, facbits int32, TOKEN []byte) int

Extract factor from TOKEN for identity CID

func MPIN_EXTRACT_PIN

func MPIN_EXTRACT_PIN(sha int, CID []byte, pin int, TOKEN []byte) int

func MPIN_GET_CLIENT_PERMIT

func MPIN_GET_CLIENT_PERMIT(sha, date int, S []byte, CID []byte, CTT []byte) int

Time Permit CTT=S*(date|H(CID)) where S is master secret

func MPIN_GET_CLIENT_SECRET

func MPIN_GET_CLIENT_SECRET(S []byte, CID []byte, CST []byte) int

Client secret CST=S*H(CID) where CID is client ID and S is master secret CID is hashed externally

func MPIN_GET_G1_MULTIPLE

func MPIN_GET_G1_MULTIPLE(rng *amcl.RAND, typ int, X []byte, G []byte, W []byte) int

W=x*H(G); if RNG == NULL then X is passed in if RNG != NULL the X is passed out if type=0 W=x*G where G is point on the curve, else W=x*M(G), where M(G) is mapping of octet G to point on the curve

func MPIN_GET_SERVER_SECRET

func MPIN_GET_SERVER_SECRET(S []byte, SST []byte) int

Extract Server Secret SST=S*Q where Q is fixed generator in G2 and S is master secret

func MPIN_GET_TIME

func MPIN_GET_TIME() int

return time since epoch

func MPIN_GET_Y

func MPIN_GET_Y(sha int, TimeValue int, xCID []byte, Y []byte)

Generate Y = H(epoch, xCID/xID)

func MPIN_HASH_ALL

func MPIN_HASH_ALL(sha int, HID []byte, xID []byte, xCID []byte, SEC []byte, Y []byte, R []byte, W []byte) []byte

func MPIN_HASH_ID

func MPIN_HASH_ID(sha int, ID []byte) []byte

func MPIN_KANGAROO

func MPIN_KANGAROO(E []byte, F []byte) int

Pollards kangaroos used to return PIN error

func MPIN_PRECOMPUTE

func MPIN_PRECOMPUTE(TOKEN []byte, CID []byte, G1 []byte, G2 []byte) int

func MPIN_RANDOM_GENERATE

func MPIN_RANDOM_GENERATE(rng *amcl.RAND, S []byte) int

create random secret S

func MPIN_RECOMBINE_G1

func MPIN_RECOMBINE_G1(R1 []byte, R2 []byte, R []byte) int

R=R1+R2 in group G1

func MPIN_RECOMBINE_G2

func MPIN_RECOMBINE_G2(W1 []byte, W2 []byte, W []byte) int

W=W1+W2 in group G2

func MPIN_RESTORE_FACTOR

func MPIN_RESTORE_FACTOR(sha int, CID []byte, factor int32, facbits int32, TOKEN []byte) int

Restore factor to TOKEN for identity CID

func MPIN_SERVER

func MPIN_SERVER(sha int, date int, HID []byte, HTID []byte, Y []byte, SST []byte, xID []byte, xCID []byte, SEC []byte, E []byte, F []byte, CID []byte, TimeValue int) int

One pass MPIN Server

func MPIN_SERVER_1

func MPIN_SERVER_1(sha int, date int, CID []byte, HID []byte, HTID []byte)

Outputs H(CID) and H(T|H(CID)) for time permits. If no time permits set HID=HTID

func MPIN_SERVER_2

func MPIN_SERVER_2(date int, HID []byte, HTID []byte, Y []byte, SST []byte, xID []byte, xCID []byte, mSEC []byte, E []byte, F []byte) int

Implement step 2 of MPin protocol on server side

func MPIN_SERVER_KEY

func MPIN_SERVER_KEY(sha int, Z []byte, SST []byte, W []byte, H []byte, HID []byte, xID []byte, xCID []byte, SK []byte) int

func Sign

func Sign(SIG []byte, m string, S []byte) int

func Today

func Today() int

return time in slots since epoch

func Verify

func Verify(SIG []byte, m string, W []byte) int

Types

type BIG

type BIG struct {
	// contains filtered or unexported fields
}

func FromBytes

func FromBytes(b []byte) *BIG

func Modmul

func Modmul(a1, b1, m *BIG) *BIG

return a*b mod m

func Modneg

func Modneg(a1, m *BIG) *BIG

return -a mod m

func Modsqr

func Modsqr(a1, m *BIG) *BIG

return a^2 mod m

func NewBIG

func NewBIG() *BIG

func NewBIGcopy

func NewBIGcopy(x *BIG) *BIG

func NewBIGdcopy

func NewBIGdcopy(x *DBIG) *BIG

func NewBIGint

func NewBIGint(x int) *BIG

func NewBIGints

func NewBIGints(x [NLEN]Chunk) *BIG

func Randomnum

func Randomnum(q *BIG, rng *amcl.RAND) *BIG

Create random BIG in portable way, one bit at a time

func (*BIG) Invmodp

func (r *BIG) Invmodp(p *BIG)

this=1/this mod p. Binary method

func (*BIG) Jacobi

func (r *BIG) Jacobi(p *BIG) int

Jacobi Symbol (this/p). Returns 0, 1 or -1

func (*BIG) Minus

func (r *BIG) Minus(x *BIG) *BIG

return this-x

func (*BIG) Mod

func (r *BIG) Mod(m1 *BIG)

reduce this mod m

func (*BIG) Plus

func (r *BIG) Plus(x *BIG) *BIG

return this+x

func (*BIG) Powmod

func (r *BIG) Powmod(e1 *BIG, m *BIG) *BIG

return this^e mod m

func (*BIG) ToBytes

func (r *BIG) ToBytes(b []byte)

func (*BIG) ToString

func (r *BIG) ToString() string

Convert to Hex String

type Chunk

type Chunk int64
const BMASK Chunk = ((Chunk(1) << BASEBITS) - 1)
const HMASK Chunk = ((Chunk(1) << HBITS) - 1)
const MConst Chunk = 0x435E50D79435E5
const OMASK Chunk = ((Chunk(-1)) << (MODBITS % BASEBITS))

Modulus Masks

const TMASK Chunk = (Chunk(1) << TBITS) - 1

type DBIG

type DBIG struct {
	// contains filtered or unexported fields
}

func NewDBIG

func NewDBIG() *DBIG

func NewDBIGcopy

func NewDBIGcopy(x *DBIG) *DBIG

func NewDBIGscopy

func NewDBIGscopy(x *BIG) *DBIG

type ECP

type ECP struct {
	// contains filtered or unexported fields
}

func ECP_fromBytes

func ECP_fromBytes(b []byte) *ECP

convert from byte array to point

func ECP_generator

func ECP_generator() *ECP

func ECP_mapit

func ECP_mapit(h []byte) *ECP

func G1mul

func G1mul(P *ECP, e *BIG) *ECP

Multiply P by e in group G1

func NewECP

func NewECP() *ECP

Constructors

func NewECPbig

func NewECPbig(ix *BIG) *ECP

set from x - calculate y from curve equation

func NewECPbigint

func NewECPbigint(ix *BIG, s int) *ECP

set (x,y) from BIG and a bit

func NewECPbigs

func NewECPbigs(ix *BIG, iy *BIG) *ECP

set (x,y) from two BIGs

func (*ECP) Add

func (E *ECP) Add(Q *ECP)

this+=Q

func (*ECP) Affine

func (E *ECP) Affine()

set to affine - from (x,y,z) to (x,y)

func (*ECP) Copy

func (E *ECP) Copy(P *ECP)

this=P

func (*ECP) Equals

func (E *ECP) Equals(Q *ECP) bool

Test P == Q

func (*ECP) GetS

func (E *ECP) GetS() int

get sign of Y

func (*ECP) GetX

func (E *ECP) GetX() *BIG

extract x as a BIG

func (*ECP) GetY

func (E *ECP) GetY() *BIG

extract y as a BIG

func (*ECP) Is_infinity

func (E *ECP) Is_infinity() bool

test for O point-at-infinity

func (*ECP) Mul

func (E *ECP) Mul(e *BIG) *ECP

Public version

func (*ECP) Mul2

func (E *ECP) Mul2(e *BIG, Q *ECP, f *BIG) *ECP

func (*ECP) Sub

func (E *ECP) Sub(Q *ECP)

this-=Q

func (*ECP) ToBytes

func (E *ECP) ToBytes(b []byte, compress bool)

convert to byte array

func (*ECP) ToString

func (E *ECP) ToString() string

convert to hex string

type ECP2

type ECP2 struct {
	// contains filtered or unexported fields
}

func ECP2_fromBytes

func ECP2_fromBytes(b []byte) *ECP2

convert from byte array to point

func ECP2_generator

func ECP2_generator() *ECP2

func ECP2_mapit

func ECP2_mapit(h []byte) *ECP2

needed for SOK

func G2mul

func G2mul(P *ECP2, e *BIG) *ECP2

Multiply P by e in group G2

func NewECP2

func NewECP2() *ECP2

func NewECP2fp2

func NewECP2fp2(ix *FP2) *ECP2

construct this from x - but set to O if not on curve

func NewECP2fp2s

func NewECP2fp2s(ix *FP2, iy *FP2) *ECP2

construct this from (x,y) - but set to O if not on curve

func (*ECP2) Add

func (E *ECP2) Add(Q *ECP2) int

this+=Q - return 0 for add, 1 for double, -1 for O

func (*ECP2) Affine

func (E *ECP2) Affine()

set to Affine - (x,y,z) to (x,y)

func (*ECP2) Copy

func (E *ECP2) Copy(P *ECP2)

copy this=P

func (*ECP2) Equals

func (E *ECP2) Equals(Q *ECP2) bool

Test if P == Q

func (*ECP2) GetX

func (E *ECP2) GetX() *FP2

extract affine x as FP2

func (*ECP2) GetY

func (E *ECP2) GetY() *FP2

extract affine y as FP2

func (*ECP2) Is_infinity

func (E *ECP2) Is_infinity() bool

Test this=O?

func (*ECP2) Mul

func (E *ECP2) Mul(e *BIG) *ECP2

Public version

func (*ECP2) Sub

func (E *ECP2) Sub(Q *ECP2) int

set this-=Q

func (*ECP2) ToBytes

func (E *ECP2) ToBytes(b []byte)

convert to byte array

func (*ECP2) ToString

func (E *ECP2) ToString() string

convert this to hex string

type FP

type FP struct {
	XES int32
	// contains filtered or unexported fields
}

func NewFPbig

func NewFPbig(a *BIG) *FP

func NewFPcopy

func NewFPcopy(a *FP) *FP

func NewFPint

func NewFPint(a int) *FP

Constructors

func RHS

func RHS(x *FP) *FP

Calculate RHS of curve equation

func (*FP) Equals

func (F *FP) Equals(a *FP) bool

return TRUE if this==a

type FP12

type FP12 struct {
	// contains filtered or unexported fields
}

func Ate

func Ate(P1 *ECP2, Q1 *ECP) *FP12

Optimal R-ate pairing

func Ate2

func Ate2(P1 *ECP2, Q1 *ECP, R1 *ECP2, S1 *ECP) *FP12

Optimal R-ate double pairing e(P,Q).e(R,S)

func FP12_fromBytes

func FP12_fromBytes(w []byte) *FP12

convert from byte array to FP12

func Fexp

func Fexp(m *FP12) *FP12

final exponentiation - keep separate for multi-pairings and to avoid thrashing stack

func GTpow

func GTpow(d *FP12, e *BIG) *FP12

f=f^e Note that this method requires a lot of RAM! Better to use compressed XTR method, see FP4.java

func NewFP12copy

func NewFP12copy(x *FP12) *FP12

func NewFP12fp4

func NewFP12fp4(d *FP4) *FP12

Constructors

func NewFP12fp4s

func NewFP12fp4s(d *FP4, e *FP4, f *FP4) *FP12

func NewFP12int

func NewFP12int(d int) *FP12

func (*FP12) Compow

func (F *FP12) Compow(e *BIG, r *BIG) *FP4

Fast compressed FP4 power of unitary FP12

func (*FP12) Copy

func (F *FP12) Copy(x *FP12)

copy this=x

func (*FP12) Equals

func (F *FP12) Equals(x *FP12) bool

return 1 if x==y, else 0

func (*FP12) Inverse

func (F *FP12) Inverse()

this=1/this

func (*FP12) Isunity

func (F *FP12) Isunity() bool

test x==1 ?

func (*FP12) Mul

func (F *FP12) Mul(y *FP12)

FP12 full multiplication this=this*y

func (*FP12) Pow

func (F *FP12) Pow(e *BIG) *FP12

this=this^e

func (*FP12) ToBytes

func (F *FP12) ToBytes(w []byte)

convert this to byte array

func (*FP12) ToString

func (F *FP12) ToString() string

convert to hex string

type FP2

type FP2 struct {
	// contains filtered or unexported fields
}

func NewFP2big

func NewFP2big(c *BIG) *FP2

func NewFP2bigs

func NewFP2bigs(c *BIG, d *BIG) *FP2

func NewFP2copy

func NewFP2copy(x *FP2) *FP2

func NewFP2fp

func NewFP2fp(c *FP) *FP2

func NewFP2fps

func NewFP2fps(c *FP, d *FP) *FP2

func NewFP2int

func NewFP2int(a int) *FP2

Constructors

func RHS2

func RHS2(x *FP2) *FP2

Calculate RHS of twisted curve equation x^3+B/i

func (*FP2) Equals

func (F *FP2) Equals(x *FP2) bool

test this=x

func (*FP2) GetA

func (F *FP2) GetA() *BIG

extract a

func (*FP2) GetB

func (F *FP2) GetB() *BIG

extract b

type FP4

type FP4 struct {
	// contains filtered or unexported fields
}

func NewFP4copy

func NewFP4copy(x *FP4) *FP4

func NewFP4fp2

func NewFP4fp2(c *FP2) *FP4

func NewFP4fp2s

func NewFP4fp2s(c *FP2, d *FP2) *FP4

func NewFP4int

func NewFP4int(a int) *FP4

Constructors

func (*FP4) Equals

func (F *FP4) Equals(x *FP4) bool

test this=x?

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL