BLS48581

package
v0.0.0-...-975b9e6 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const AESKEY int = 32
View Source
const ALLOW_ALT_COMPRESS bool = false
View Source
const ATE_BITS int = 33
View Source
const BAD_PARAMS int = -11
View Source
const BAD_PIN int = -19
View Source
const BASEBITS uint = 60
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 BIG_ENDIAN_SIGN bool = false
View Source
const BLS12 int = 2
View Source
const BLS24 int = 3
View Source
const BLS48 int = 4
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 = 1
View Source
const CURVE_Cof_I int = 0
View Source
const CURVE_PAIRING_TYPE int = BLS48
View Source
const DNLEN int = 2 * NLEN
View Source
const D_TYPE int = 0

Pairing Twist type

View Source
const ECDH_ERROR int = -3
View Source
const ECDH_INVALID_PUBLIC_KEY int = -2
View Source
const EDDSA_INVALID_PUBLIC_KEY int = -2
View Source
const EDWARDS int = 1
View Source
const EFS int = int(MODBYTES)

const INVALID int = -4

View Source
const EGS int = int(MODBYTES)
View Source
const FEXCESS int32 = ((int32(1) << 19) - 1)
View Source
const FP_DENSE int = 5
View Source
const FP_ONE int = 1
View Source
const FP_SPARSE int = 4
View Source
const FP_SPARSER int = 3
View Source
const FP_SPARSEST int = 2
View Source
const FP_ZERO int = 0

Sparsity

View Source
const G2_TABLE int = 36
View Source
const GENERALISED_MERSENNE int = 3
View Source
const HASH_TYPE int = 64
View Source
const HBITS uint = (BASEBITS / 2)
View Source
const HTC_ISO int = 0
View Source
const HTC_ISO_G2 int = 0
View Source
const INVALID_POINT int = -14
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 MODBITS uint = 581 /* Number of bits in Modulus */

Modulus details

View Source
const MODBYTES uint = 73

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 NEGATOWER int = 0
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 PM1D2 uint = 1 /* Modulus mod 8 */
View Source
const POSITIVEX int = 0

Pairing x parameter sign

View Source
const POSITOWER int = 1
View Source
const PSEUDO_MERSENNE int = 1
View Source
const QNRI int = 0 // Fp2 QNR
View Source
const RIADZ int = 2 /* hash-to-point Z */
View Source
const RIADZG2A int = 2 /* G2 hash-to-point Z */
View Source
const RIADZG2B int = 0 /* G2 hash-to-point Z */
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 TOWER int = POSITOWER // Tower type
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 CRu = [...]Chunk{0x4DE9AC5E1C79B90, 0x5CD8E3F88E5DE82, 0xAB21F74F7421A20, 0x6694B9B60DB5D62, 0x73422B5FB82F431, 0xFF46A846B5FA6AA, 0x83D66C1E5FCBED6, 0x2096384F2AFA565, 0x8B75055DD5D1F4E, 0x2C6}
View Source
var CURVE_B = [...]Chunk{0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
View Source
var CURVE_Bnx = [...]Chunk{0x140000381, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
View Source
var CURVE_Cof = [...]Chunk{0x140000382, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
View Source
var CURVE_Gx = [...]Chunk{0xBCE8732315AF640, 0x74DA5D3A1E6D8C3, 0x57DB368B11786CB, 0x665D859236EBDBC, 0x46A9DF6F9645847, 0xEDFFB9F75445505, 0xE86868CF61ABDBA, 0x93F860DE3F257E0, 0x40F2BAF2B73DF1E, 0x2AF59B7AC3}
View Source
var CURVE_Gy = [...]Chunk{0xDBB5DE3E2587A70, 0xF37AEF7B926B576, 0xF77C2876D1B2E35, 0x78584C3EF22F487, 0xFFB98AEE53E80F6, 0xD41B720EF7BB7BE, 0xFEB8A52E991279D, 0xB398A488A553C9E, 0x31F91F86B3A2D1F, 0xCEFDA44F65}
View Source
var CURVE_HTPC = [...]Chunk{0x393F0BE031193EC, 0xC28896440758243, 0xDBE4AA8E70D4620, 0x6B27BD55EFD560E, 0x24A9624BEECD070, 0xE2626AD7C53B361, 0xDD845A98030C755, 0x29389B4E6A62C2D, 0x5AF94F05D8A9FD4, 0x92348CD5DC}
View Source
var CURVE_Order = [...]Chunk{0x8A5FE6FCD671C01, 0xBE599467C24DA11, 0xC7CD0562303C4CC, 0x9D34C4C92016A85, 0xBC972C2E6E74196, 0x3F0B3CBE003FAD6, 0x615C0D6C635387A, 0xE2885E233A9CCC1, 0x2386F8A925, 0x0}
View Source
var CURVE_Pxaaa = [...]Chunk{0x34FD0B4ACE8BFAB, 0xB79766322154DEC, 0x4D80491F510317, 0x3CA0612F4005030, 0xBAAD1A8C42281A6, 0x3A2EF156C46FF79, 0x344DBCCB7DE64DB, 0x2775DEBABBEFC70, 0x71E4A38237FA45A, 0x5D615D9A78}
View Source
var CURVE_Pxaab = [...]Chunk{0x669B36676B47C57, 0x5556A01AFA143F1, 0x7630D979630FFD7, 0x6AFFA62504F0C3C, 0xABFEDF16214A7, 0x12307F4E1C3943A, 0xE1623E9526F6DA, 0xBC07E8B22BB6D98, 0x258512069B0E86A, 0x7C4973ECE2}
View Source
var CURVE_Pxaba = [...]Chunk{0x488156CA55A3E6A, 0xEF4CDED6B3F0B46, 0xCBDFBB879D5FEA8, 0x66F0D2A6D55F028, 0xC1DBD19242FFAE7, 0xCCBAB5AB6860161, 0xAE237CA7A6D6957, 0xAD83BC73A8A6CA9, 0xF1334E1B2EA1853, 0x1FCCC70198}
View Source
var CURVE_Pxabb = [...]Chunk{0x9A7033CBB7FEAFE, 0x10B8CB4E80BC3F0, 0x1C5257C200CA523, 0x43B1B279B9468C3, 0x5F63E1C776E6EC1, 0x393F8BE0CC218A9, 0x62F3E5821B7B92A, 0x54D4BFE8F5985AC, 0xEB6185C78D80129, 0xBE2218C25C}
View Source
var CURVE_Pxbaa = [...]Chunk{0x39C3A1C53F8CCE5, 0x5B5F746C9D4CBB7, 0xD55FC1889AA80C6, 0xEF492AE589274FA, 0x9E48199D5AC10B2, 0xC5805386699981F, 0xB1642B5675FF0E7, 0xA9DD63007C675D0, 0x35913A3C598E4CA, 0x38B91C600B}
View Source
var CURVE_Pxbab = [...]Chunk{0x2004D914A3C093A, 0x7960910FCE3370F, 0xA9F177612F097FC, 0x40B9C0B15DD7595, 0x3835D28997EB57B, 0x7BB037418181DF6, 0xEF0977A3D1A5867, 0xCDA088F7B8F35DC, 0x738603F1311E4E, 0xC96C7797EB}
View Source
var CURVE_Pxbba = [...]Chunk{0x41607E60750E057, 0x4B5B0E205C3354E, 0xCBE4324C22D6333, 0xAA5EFCF3432AAD1, 0xF293B13CED0FD0C, 0xA2C0B7A449CEF11, 0x9D13852B6DB908B, 0x8AEE660DEA41B3, 0x61EE3F0197A4989, 0xB9B7951C60}
View Source
var CURVE_Pxbbb = [...]Chunk{0xE19DA00FBC6AE34, 0x6AF2FC9E97C3F84, 0x9BD6AEBF9FC44E5, 0x90B7E2B0D458547, 0xA93F29CFF364A71, 0x719728A7F9F8CFC, 0xFAF47B5211CF741, 0x4AAA2B1E5D7A9DE, 0x2BDEC5282624C4F, 0x827D5C22FB}
View Source
var CURVE_Pyaaa = [...]Chunk{0x3EDD3FE4D2D7971, 0x45012AB12C0FF32, 0x9ABF77EEA6D6590, 0x336D8AE5163C159, 0x35AFA27748D90F7, 0xBFC435FAAB09062, 0x59A577E6F3B39E, 0x2F3024B918B4238, 0x75B5DFA49721645, 0xEB53356C3}
View Source
var CURVE_Pyaab = [...]Chunk{0x1471DB936CD5665, 0x8B423525FFC7B11, 0x2FA097D760E2E58, 0xD1892AB24E1DD21, 0x6B243B1F192C5C3, 0x64732FCBF3AFB09, 0xA325E6FBA01D729, 0x5FCADC2B75A422B, 0xE0FF144DA653181, 0x284DC75979}
View Source
var CURVE_Pyaba = [...]Chunk{0x8332A526A2A8474, 0xBC7C46FC3B8FDE6, 0x1D35D51A652269C, 0x36CA3295E5E2F0C, 0xC99D0E904115155, 0xD370514475F7D5, 0x216D5B119D3A48, 0x67669EF2C2FC503, 0x8523E421EFB703, 0xB36A201DD0}
View Source
var CURVE_Pyabb = [...]Chunk{0x6213DA92841589D, 0xB3D8B8A1E533731, 0x7BDA503EE5E578F, 0x817742770BA10D6, 0x224333FA40DCED2, 0x10E122D2742C89B, 0x60DCEE23DD8B0E7, 0x78762B1C2CDED33, 0xEDC0688223FBBD4, 0xAEC25A4621}
View Source
var CURVE_Pybaa = [...]Chunk{0x47831F982E50137, 0x857FDDDFCF7A43F, 0x30135945D137B08, 0xCA4E512B64F59F4, 0x7FA238CDCE8A1E2, 0x5F1129857ED85C7, 0xB43DD93B5A95980, 0x88325A2554DC541, 0xA9C46916503FA5A, 0xD209D5A223}
View Source
var CURVE_Pybab = [...]Chunk{0x4EEDC58CF90BEE4, 0xA59ED8226CF3A59, 0xFC198CAA72B679D, 0xF47C180D139E3AA, 0xE8C270841F6824, 0x55AB7504FA8342, 0xB16722B589D82E2, 0xD537B90421AD66E, 0x36B7A513D339D5A, 0x7D0D037457}
View Source
var CURVE_Pybba = [...]Chunk{0xD41FAEAFEB23986, 0xE884017D9AA62B3, 0x40FA639F53DCCC9, 0xAB8C74B2618B5BB, 0x5AE3A2864F22C1F, 0xE4C819A6DF98F42, 0xC0841B064155F14, 0xD17AF8A006F364F, 0xE65EA25C2D05DFD, 0x896767811B}
View Source
var CURVE_Pybbb = [...]Chunk{0x667FFCB732718B6, 0x5AC66E84069C55D, 0xD8C4AB33F748E, 0x333EC7192054173, 0x8E69C31E97E1AD0, 0xEF8ECA9A9533A3F, 0x6BE8E50C87549B6, 0x4F981B5E068F140, 0x9029D393A5C07E8, 0x35E2524FF8}
View Source
var Fra = [...]Chunk{0x62EB6CFE42AEB25, 0xDB41942760AD3F9, 0xA7DF2570715ECE4, 0x90377B51208AC0F, 0x6848493E1C8C418, 0xF496307E298187E, 0x58740E3CAFD6B62, 0xF6067D047983E78, 0x49FA75CD7E73E55, 0xFD30DB501}
View Source
var Frb = [...]Chunk{0x62EB6CFE42AEB25, 0xDB41942760AD3F9, 0xA7DF2570715ECE4, 0x90377B51208AC0F, 0x6848493E1C8C418, 0xF496307E298187E, 0x58740E3CAFD6B62, 0xF6067D047983E78, 0x49FA75CD7E73E55, 0xFD30DB501}
View Source
var G2_TAB []*FP16
View Source
var Modulus = [...]Chunk{0xEDC154E6565912B, 0x8FDF721A4A48AC3, 0x7A5513170EE0A57, 0x394F4736DAF6836, 0xAF6E082ACD9CD30, 0xF3975444A48AE43, 0x22131BB3BE6C0F1, 0x12A0056E84F8D1, 0x76F313824E31D47, 0x1280F73FF34}

Base Bits= 60

View Source
var R2modp = [...]Chunk{0x79868479F1B5833, 0xFB6EBA8FCB82D07, 0x9CC8A7F1FD84C7F, 0x402C51CF5CC3CBB, 0x3F3114F078502C, 0xFC90829BDC8336E, 0xC7BE91DE9CA8EED, 0xD4D273BB17BFADB, 0x6EC7C9A81E792CA, 0x1DC317A6E4}
View Source
var ROI = [...]Chunk{0xEDC154E6565912A, 0x8FDF721A4A48AC3, 0x7A5513170EE0A57, 0x394F4736DAF6836, 0xAF6E082ACD9CD30, 0xF3975444A48AE43, 0x22131BB3BE6C0F1, 0x12A0056E84F8D1, 0x76F313824E31D47, 0x1280F73FF34}
View Source
var SQRTm3 = [...]Chunk{0x51EDFC2A1D65A0A, 0xD62DAA292D8CDBF, 0x24112478269D616, 0x6C25D3CABF8AD71, 0xC8E9B16B5D3E4CD, 0xF50A03B738960EE, 0x1A664376FED4343, 0xBFFD8FB8925AE06, 0x600908C6A28DEAA, 0x1280F73F9A7}
View Source
var TWK = [...]Chunk{0x7B433D25F426953, 0xACE45923B9863D, 0xC28BBDFA2D37E16, 0x62FFCC8AFB4BC18, 0x661B4392F002C4F, 0x2ED27E951A14781, 0x670A6683B853246, 0xAEB8C9BA138A075, 0xC10075769CDDD9E, 0x3A65A537B}

Functions

func Another

func Another(r []*FP48, P1 *ECP8, Q1 *ECP)

Accumulate another set of line functions for n-pairing

func Another_pc

func Another_pc(r []*FP48, T []*FP16, QV *ECP)

func AuthDecap

func AuthDecap(config_id int, skR []byte, pkE []byte, pkR []byte, pkS []byte) []byte

func AuthEncap

func AuthEncap(config_id int, skE []byte, skS []byte, pkE []byte, pkR []byte, pkS []byte) []byte

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 Core_Sign

func Core_Sign(SIG []byte, M []byte, S []byte) int

Sign message m using private key S to produce signature SIG

func Core_Verify

func Core_Verify(SIG []byte, M []byte, W []byte) int

func Decap

func Decap(config_id int, skR []byte, pkE []byte, pkR []byte) []byte

func DeriveKeyPair

func DeriveKeyPair(config_id int, SK []byte, PK []byte, SEED []byte) bool

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 *core.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 *core.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, typ int) int
IEEE-1363 Diffie-Hellman online calculation Z=S.WD

type = 0 is just x coordinate output type = 1 for standard compressed output type = 2 for standard uncompress output 04|x|y

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_IN_RANGE

func ECDH_IN_RANGE(S []byte) bool

return true if S is in ranger 0 < S < order , else return false

func ECDH_KEY_PAIR_GENERATE

func ECDH_KEY_PAIR_GENERATE(RNG *core.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_PUBLIC_KEY_VALIDATE

func ECDH_PUBLIC_KEY_VALIDATE(W []byte) int

validate public key

func Encap

func Encap(config_id int, skE []byte, pkE []byte, pkR []byte) []byte

func FP_tpo

func FP_tpo(i *FP, s *FP) int

Two for the price of one - See Hamburg https://eprint.iacr.org/2012/309.pdf Calculate inverse of i and square root of s, return QR

func G1member

func G1member(P *ECP) bool

test G1 group membership

func G2member

func G2member(P *ECP8) bool

test G2 group membership

func GTcyclotomic

func GTcyclotomic(m *FP48) bool

Check that m is in cyclotomic sub-group Check that m!=1, conj(m)*m==1, and m.m^{p^16}=m^{p^8}

func GTmember

func GTmember(m *FP48) bool

test for full GT membership

func Init

func Init() int

func KEY_PAIR_GENERATE

func KEY_PAIR_GENERATE(RNG *core.RAND, D []byte, Q []byte) int

Calculate a public/private EC GF(p) key pair. Q=D.G mod EC(p), * where D is the secret key and Q is the public key * and G is fixed generator. * RNG is a cryptographically strong RNG * If RNG==NULL, D is provided externally

func KeyPairGenerate

func KeyPairGenerate(IKM []byte, S []byte, W []byte) int

generate key pair, private key S, public key W

func KeySchedule

func KeySchedule(config_id int, mode int, Z []byte, info []byte, psk []byte, pskID []byte) ([]byte, []byte, []byte)

func MPIN_CLIENT_1

func MPIN_CLIENT_1(CID []byte, rng *core.RAND, X []byte, pin int, TOKEN []byte, SEC []byte, xID []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_ENCODE_TO_CURVE

func MPIN_ENCODE_TO_CURVE(DST []byte, ID []byte, HCID []byte)

func MPIN_EXTRACT_PIN

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

func MPIN_GET_CLIENT_SECRET

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

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_HASH_ID

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

func MPIN_RANDOM_GENERATE

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

create random secret S

func MPIN_SERVER

func MPIN_SERVER(HID []byte, Y []byte, SST []byte, xID []byte, mSEC []byte) int

Implement step 2 of MPin protocol on server side

func RFC7748

func RFC7748(r *BIG)

Transform a point multiplier to RFC7748 form

func SIGNATURE

func SIGNATURE(ph bool, D []byte, ctx []byte, M []byte, SIG []byte) int

Generate a signature using key pair (D,Q) on message M Set ph=true if message has already been pre-hashed if ph=false, then context should be NULL for ed25519. However RFC8032 mode ed25519ctx is supported by supplying a non-NULL or non-empty context

func VERIFY

func VERIFY(ph bool, Q []byte, ctx []byte, M []byte, SIG []byte) bool

Types

type BIG

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

func BIG_frombytearray

func BIG_frombytearray(b []byte, n int) *BIG

convert from byte array to BIG

func FromBytes

func FromBytes(b []byte) *BIG

func Modadd

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

return a+b mod m

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 Random

func Random(rng *core.RAND) *BIG

get 8*MODBYTES size random number

func Randomnum

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

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

func Randtrunc

func Randtrunc(q *BIG, trunc int, rng *core.RAND) *BIG

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(m *BIG)

reduce this mod m

func (*BIG) Nbits

func (r *BIG) Nbits() int

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 = 0x148B81FC39D5A7D
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 DBIG_fromBytes

func DBIG_fromBytes(b []byte) *DBIG

convert from byte array to BIG

func NewDBIG

func NewDBIG() *DBIG

func NewDBIGcopy

func NewDBIGcopy(x *DBIG) *DBIG

func NewDBIGscopy

func NewDBIGscopy(x *BIG) *DBIG

func (*DBIG) Mod

func (r *DBIG) Mod(m *BIG) *BIG

reduces this DBIG mod a BIG, and returns the BIG

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_hap2point

func ECP_hap2point(h *BIG) *ECP

Hunt and Peck a BIG to a curve point

func ECP_map2point

func ECP_map2point(h *FP) *ECP

Constant time Map to Point

func ECP_mapit

func ECP_mapit(h []byte) *ECP

func ECP_muln

func ECP_muln(n int, X []*ECP, e []*BIG) *ECP

Generic multi-multiplication, fixed 4-bit window, P=Sigma e_i*X_i

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) Cfp

func (E *ECP) Cfp()

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) Neg

func (E *ECP) Neg()

this=-this

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 ECP8

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

func ECP8_fromBytes

func ECP8_fromBytes(b []byte) *ECP8

convert from byte array to point

func ECP8_generator

func ECP8_generator() *ECP8

func ECP8_hap2point

func ECP8_hap2point(h *BIG) *ECP8

func ECP8_map2point

func ECP8_map2point(H *FP8) *ECP8

Deterministic mapping of Fp to point on curve

func ECP8_mapit

func ECP8_mapit(h []byte) *ECP8

Map octet string to curve point

func G2mul

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

Multiply P by e in group G2

func NewECP8

func NewECP8() *ECP8

func NewECP8fp8

func NewECP8fp8(ix *FP8, s int) *ECP8

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

func NewECP8fp8s

func NewECP8fp8s(ix *FP8, iy *FP8) *ECP8

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

func (*ECP8) Add

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

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

func (*ECP8) Affine

func (E *ECP8) Affine()

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

func (*ECP8) Cfp

func (E *ECP8) Cfp()

needed for SOK

func (*ECP8) Copy

func (E *ECP8) Copy(P *ECP8)

copy this=P

func (*ECP8) Equals

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

Test if P == Q

func (*ECP8) GetX

func (E *ECP8) GetX() *FP8

extract affine x as FP2

func (*ECP8) GetY

func (E *ECP8) GetY() *FP8

extract affine y as FP2

func (*ECP8) Is_infinity

func (E *ECP8) Is_infinity() bool

Test this=O?

func (*ECP8) Mul

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

Public version

func (*ECP8) Sub

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

set this-=Q

func (*ECP8) ToBytes

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

convert to byte array

func (*ECP8) ToString

func (E *ECP8) ToString() string

convert this to hex string

type FP

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

func FP_fromBytes

func FP_fromBytes(b []byte) *FP

func NewFP

func NewFP() *FP

func NewFPbig

func NewFPbig(a *BIG) *FP

func NewFPcopy

func NewFPcopy(a *FP) *FP

func NewFPint

func NewFPint(a int) *FP

func NewFPrand

func NewFPrand(rng *core.RAND) *FP

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

func (*FP) ToBytes

func (F *FP) ToBytes(b []byte)

func (*FP) ToString

func (F *FP) ToString() string

type FP16

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

func FP16_fromBytes

func FP16_fromBytes(bf []byte) *FP16

func NewFP16

func NewFP16() *FP16

func NewFP16copy

func NewFP16copy(x *FP16) *FP16

func NewFP16fp8

func NewFP16fp8(c *FP8) *FP16

func NewFP16fp8s

func NewFP16fp8s(c *FP8, d *FP8) *FP16

func NewFP16int

func NewFP16int(a int) *FP16

Constructors

func (*FP16) Equals

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

test this=x?

func (*FP16) ToBytes

func (F *FP16) ToBytes(bf []byte)

type FP2

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

func ECP8_frob_constants

func ECP8_frob_constants() [3]*FP2

func FP2_fromBytes

func FP2_fromBytes(bf []byte) *FP2

func NewFP2

func NewFP2() *FP2

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 NewFP2ints

func NewFP2ints(a int, b int) *FP2

func NewFP2rand

func NewFP2rand(rng *core.RAND) *FP2

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

func (*FP2) ToBytes

func (F *FP2) ToBytes(bf []byte)

func (*FP2) ToString

func (F *FP2) ToString() string

output to hex string

type FP4

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

func FP4_fromBytes

func FP4_fromBytes(bf []byte) *FP4

func NewFP4

func NewFP4() *FP4

func NewFP4copy

func NewFP4copy(x *FP4) *FP4

func NewFP4fp

func NewFP4fp(c *FP) *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 NewFP4ints

func NewFP4ints(a int, b int) *FP4

Constructors

func NewFP4rand

func NewFP4rand(rng *core.RAND) *FP4

func (*FP4) Equals

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

test this=x?

func (*FP4) ToBytes

func (F *FP4) ToBytes(bf []byte)

type FP48

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

func Ate

func Ate(P1 *ECP8, Q1 *ECP) *FP48

Optimal R-ate pairing

func Ate2

func Ate2(P1 *ECP8, Q1 *ECP, R1 *ECP8, S1 *ECP) *FP48

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

func FP48_fromBytes

func FP48_fromBytes(w []byte) *FP48

convert from byte array to FP48

func Fexp

func Fexp(m *FP48) *FP48

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

func GTpow

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

f=f^e Note that this method requires a lot of RAM!

func Initmp

func Initmp() []*FP48

prepare for multi-pairing

func Miller

func Miller(r []*FP48) *FP48

basic Miller loop

func NewFP48

func NewFP48() *FP48

func NewFP48copy

func NewFP48copy(x *FP48) *FP48

func NewFP48fp16

func NewFP48fp16(d *FP16) *FP48

Constructors

func NewFP48fp16s

func NewFP48fp16s(d *FP16, e *FP16, f *FP16) *FP48

func NewFP48int

func NewFP48int(d int) *FP48

func (*FP48) Copy

func (F *FP48) Copy(x *FP48)

copy this=x

func (*FP48) Equals

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

return 1 if x==y, else 0

func (*FP48) Inverse

func (F *FP48) Inverse()

this=1/this

func (*FP48) Isunity

func (F *FP48) Isunity() bool

test x==1 ?

func (*FP48) Mul

func (F *FP48) Mul(y *FP48)

FP48 full multiplication this=this*y

func (*FP48) Pow

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

this=this^e

func (*FP48) ToBytes

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

convert this to byte array

func (*FP48) ToString

func (F *FP48) ToString() string

convert to hex string

type FP8

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

func FP8_fromBytes

func FP8_fromBytes(bf []byte) *FP8

func NewFP8

func NewFP8() *FP8

func NewFP8copy

func NewFP8copy(x *FP8) *FP8

func NewFP8fp

func NewFP8fp(c *FP) *FP8

func NewFP8fp4

func NewFP8fp4(c *FP4) *FP8

func NewFP8fp4s

func NewFP8fp4s(c *FP4, d *FP4) *FP8

func NewFP8int

func NewFP8int(a int) *FP8

Constructors

func NewFP8ints

func NewFP8ints(a int, b int) *FP8

Constructors

func NewFP8rand

func NewFP8rand(rng *core.RAND) *FP8

func RHS8

func RHS8(x *FP8) *FP8

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

func (*FP8) Equals

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

test this=x?

func (*FP8) ToBytes

func (F *FP8) ToBytes(bf []byte)

Jump to

Keyboard shortcuts

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