Documentation ¶
Index ¶
- Constants
- Variables
- func Another(r []*FP24, P1 *ECP4, Q1 *ECP)
- func Another_pc(r []*FP24, T []*FP8, QV *ECP)
- func AuthDecap(config_id int, skR []byte, pkE []byte, pkR []byte, pkS []byte) []byte
- func AuthEncap(config_id int, skE []byte, skS []byte, pkE []byte, pkR []byte, pkS []byte) []byte
- func Comp(a *BIG, b *BIG) int
- func Core_Sign(SIG []byte, M []byte, S []byte) int
- func Core_Verify(SIG []byte, M []byte, W []byte) int
- func Decap(config_id int, skR []byte, pkE []byte, pkR []byte) []byte
- func DeriveKeyPair(config_id int, SK []byte, PK []byte, SEED []byte) bool
- func ECDH_ECIES_DECRYPT(sha int, P1 []byte, P2 []byte, V []byte, C []byte, T []byte, U []byte) []byte
- func ECDH_ECIES_ENCRYPT(sha int, P1 []byte, P2 []byte, RNG *core.RAND, W []byte, M []byte, V []byte, ...) []byte
- func ECDH_ECPSP_DSA(sha int, RNG *core.RAND, S []byte, F []byte, C []byte, D []byte) int
- func ECDH_ECPSVDP_DH(S []byte, WD []byte, Z []byte, typ int) int
- func ECDH_ECPVP_DSA(sha int, W []byte, F []byte, C []byte, D []byte) int
- func ECDH_IN_RANGE(S []byte) bool
- func ECDH_KEY_PAIR_GENERATE(RNG *core.RAND, S []byte, W []byte) int
- func ECDH_PUBLIC_KEY_VALIDATE(W []byte) int
- func Encap(config_id int, skE []byte, pkE []byte, pkR []byte) []byte
- func FP_tpo(i *FP, s *FP) int
- func G1member(P *ECP) bool
- func G2member(P *ECP4) bool
- func GTcyclotomic(m *FP24) bool
- func GTmember(m *FP24) bool
- func Init() int
- func KEY_PAIR_GENERATE(RNG *core.RAND, D []byte, Q []byte) int
- func KeyPairGenerate(IKM []byte, S []byte, W []byte) int
- func KeySchedule(config_id int, mode int, Z []byte, info []byte, psk []byte, pskID []byte) ([]byte, []byte, []byte)
- func MPIN_CLIENT_1(CID []byte, rng *core.RAND, X []byte, pin int, TOKEN []byte, SEC []byte, ...) int
- func MPIN_CLIENT_2(X []byte, Y []byte, SEC []byte) int
- func MPIN_ENCODE_TO_CURVE(DST []byte, ID []byte, HCID []byte)
- func MPIN_EXTRACT_PIN(CID []byte, pin int, TOKEN []byte) int
- func MPIN_GET_CLIENT_SECRET(S []byte, IDHTC []byte, CST []byte) int
- func MPIN_GET_SERVER_SECRET(S []byte, SST []byte) int
- func MPIN_HASH_ID(sha int, ID []byte) []byte
- func MPIN_RANDOM_GENERATE(rng *core.RAND, S []byte) int
- func MPIN_SERVER(HID []byte, Y []byte, SST []byte, xID []byte, mSEC []byte) int
- func RFC7748(r *BIG)
- func SIGNATURE(ph bool, D []byte, ctx []byte, M []byte, SIG []byte) int
- func VERIFY(ph bool, Q []byte, ctx []byte, M []byte, SIG []byte) bool
- type BIG
- func BIG_frombytearray(b []byte, n int) *BIG
- func FromBytes(b []byte) *BIG
- func Modadd(a1, b1, m *BIG) *BIG
- func Modmul(a1, b1, m *BIG) *BIG
- func Modneg(a1, m *BIG) *BIG
- func Modsqr(a1, m *BIG) *BIG
- func NewBIG() *BIG
- func NewBIGcopy(x *BIG) *BIG
- func NewBIGdcopy(x *DBIG) *BIG
- func NewBIGint(x int) *BIG
- func NewBIGints(x [NLEN]Chunk) *BIG
- func Random(rng *core.RAND) *BIG
- func Randomnum(q *BIG, rng *core.RAND) *BIG
- func Randtrunc(q *BIG, trunc int, rng *core.RAND) *BIG
- type Chunk
- type DBIG
- type ECP
- func ECP_fromBytes(b []byte) *ECP
- func ECP_generator() *ECP
- func ECP_hap2point(h *BIG) *ECP
- func ECP_map2point(h *FP) *ECP
- func ECP_mapit(h []byte) *ECP
- func ECP_muln(n int, X []*ECP, e []*BIG) *ECP
- func G1mul(P *ECP, e *BIG) *ECP
- func NewECP() *ECP
- func NewECPbig(ix *BIG) *ECP
- func NewECPbigint(ix *BIG, s int) *ECP
- func NewECPbigs(ix *BIG, iy *BIG) *ECP
- func (E *ECP) Add(Q *ECP)
- func (E *ECP) Affine()
- func (E *ECP) Cfp()
- func (E *ECP) Copy(P *ECP)
- func (E *ECP) Equals(Q *ECP) bool
- func (E *ECP) GetS() int
- func (E *ECP) GetX() *BIG
- func (E *ECP) GetY() *BIG
- func (E *ECP) Is_infinity() bool
- func (E *ECP) Mul(e *BIG) *ECP
- func (E *ECP) Mul2(e *BIG, Q *ECP, f *BIG) *ECP
- func (E *ECP) Neg()
- func (E *ECP) Sub(Q *ECP)
- func (E *ECP) ToBytes(b []byte, compress bool)
- func (E *ECP) ToString() string
- type ECP4
- func (E *ECP4) Add(Q *ECP4) int
- func (E *ECP4) Affine()
- func (E *ECP4) Cfp()
- func (E *ECP4) Copy(P *ECP4)
- func (E *ECP4) Equals(Q *ECP4) bool
- func (E *ECP4) GetX() *FP4
- func (E *ECP4) GetY() *FP4
- func (E *ECP4) Is_infinity() bool
- func (E *ECP4) Mul(e *BIG) *ECP4
- func (E *ECP4) Sub(Q *ECP4) int
- func (E *ECP4) ToBytes(b []byte, compress bool)
- func (E *ECP4) ToString() string
- type FP
- type FP2
- func ECP4_frob_constants() [3]*FP2
- func FP2_fromBytes(bf []byte) *FP2
- func NewFP2() *FP2
- func NewFP2big(c *BIG) *FP2
- func NewFP2bigs(c *BIG, d *BIG) *FP2
- func NewFP2copy(x *FP2) *FP2
- func NewFP2fp(c *FP) *FP2
- func NewFP2fps(c *FP, d *FP) *FP2
- func NewFP2int(a int) *FP2
- func NewFP2ints(a int, b int) *FP2
- func NewFP2rand(rng *core.RAND) *FP2
- type FP24
- func Ate(P1 *ECP4, Q1 *ECP) *FP24
- func Ate2(P1 *ECP4, Q1 *ECP, R1 *ECP4, S1 *ECP) *FP24
- func FP24_fromBytes(w []byte) *FP24
- func Fexp(m *FP24) *FP24
- func GTpow(d *FP24, e *BIG) *FP24
- func Initmp() []*FP24
- func Miller(r []*FP24) *FP24
- func NewFP24() *FP24
- func NewFP24copy(x *FP24) *FP24
- func NewFP24fp8(d *FP8) *FP24
- func NewFP24fp8s(d *FP8, e *FP8, f *FP8) *FP24
- func NewFP24int(d int) *FP24
- type FP4
- type FP8
Constants ¶
const AESKEY int = 24
const ALLOW_ALT_COMPRESS bool = false
const ATE_BITS int = 49
const BAD_PARAMS int = -11
const BAD_PIN int = -19
const BASEBITS uint = 56
const BFS int = int(MODBYTES)
const BGS int = int(MODBYTES)
const BIGBITS int = int(MODBYTES * 8)
const BIG_ENDIAN_SIGN bool = false
const BLS12 int = 2
const BLS24 int = 3
const BLS48 int = 4
const BLS_FAIL int = -1
const BLS_OK int = 0
const BN int = 1
const CHUNK int = 64 /* Set word size */
const CURVETYPE int = WEIERSTRASS
const CURVE_A int = 0
const CURVE_B_I int = 19
const CURVE_Cof_I int = 0
const CURVE_PAIRING_TYPE int = BLS24
const DNLEN int = 2 * NLEN
const D_TYPE int = 0
Pairing Twist type
const ECDH_ERROR int = -3
const ECDH_INVALID_PUBLIC_KEY int = -2
const EDDSA_INVALID_PUBLIC_KEY int = -2
const EDWARDS int = 1
const EFS int = int(MODBYTES)
const INVALID int = -4
const EGS int = int(MODBYTES)
const FEXCESS int32 = ((int32(1) << 25) - 1)
const FP_DENSE int = 5
const FP_ONE int = 1
const FP_SPARSE int = 4
const FP_SPARSER int = 3
const FP_SPARSEST int = 2
const FP_ZERO int = 0
Sparsity
const G2_TABLE int = 52
const GENERALISED_MERSENNE int = 3
const HASH_TYPE int = 48
const HBITS uint = (BASEBITS / 2)
const HTC_ISO int = 0
const HTC_ISO_G2 int = 0
const INVALID_POINT int = -14
const MAXPIN int32 = 10000 /* PIN less than this */
const MFS int = int(MODBYTES)
import "fmt"
const MGS int = int(MODBYTES)
const MODBITS uint = 479 /* Number of bits in Modulus */
Modulus details
const MODBYTES uint = 60
BIG length in bytes and number base
const MODTYPE int = NOT_SPECIAL //NOT_SPECIAL
const MONTGOMERY int = 2
const MONTGOMERY_FRIENDLY int = 2
const M_TYPE int = 1
const NEGATIVEX int = 1
const NEGATOWER int = 0
const NEXCESS int = (1 << (uint(CHUNK) - BASEBITS - 1))
const NLEN int = int((1 + ((8*MODBYTES - 1) / BASEBITS)))
BIG lengths and Masks
const NOT int = 0
Pairing Friendly?
const NOT_SPECIAL int = 0
Modulus types
const PBLEN int32 = 14 /* Number of bits in PIN */
const PM1D2 uint = 1 /* Modulus mod 8 */
const POSITIVEX int = 0
Pairing x parameter sign
const POSITOWER int = 1
const PSEUDO_MERSENNE int = 1
const QNRI int = 0 // Fp2 QNR
const RIADZ int = 1 /* hash-to-point Z */
const RIADZG2A int = 4 /* G2 hash-to-point Z */
const RIADZG2B int = 0 /* G2 hash-to-point Z */
const SEXTIC_TWIST int = M_TYPE
const SIGN_OF_X int = POSITIVEX
const TBITS uint = MODBITS % BASEBITS // Number of active bits in top word
const TOWER int = NEGATOWER // Tower type
const USE_GLV bool = true
const USE_GS_G2 bool = true
const USE_GS_GT bool = true
const WEIERSTRASS int = 0
Curve types
const WRONG_ORDER int = -18
Variables ¶
var CRu = [...]Chunk{0xBC27146DD794A9, 0x3A30938AF33A43, 0xB112175223DDC6, 0x125CFBB4236DFB, 0x2358E379CE607, 0xD680C6EB20806E, 0x314C200860FF77, 0x3CBC5A88268E4, 0x555C0078}
var CURVE_Cof = [...]Chunk{0xC1FFBFF9F415AB, 0x5556AAB7FF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
var CURVE_B = [...]Chunk{0x13, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
var CURVE_Bnx = [...]Chunk{0x100020011FF80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
var CURVE_Cof = [...]Chunk{0x100020011FF7F, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
var CURVE_Gx = [...]Chunk{0x6760F5EBE3CCD4, 0xEFE2DAED9F4564, 0x783F08EBA1FCC1, 0xC6F8D95AF88134, 0xDCA8D1AE2D8477, 0x9077586CEFE4BF, 0x8B7FEA5D99BC1D, 0x17CAF9486DE9E1, 0x1AB2BE34}
var CURVE_Gy = [...]Chunk{0xCBA5CAD21E5245, 0x6D6608C55DF6C4, 0xB3ED294F39746B, 0x145824920FF3C8, 0x63AA4FD63E5A64, 0x492A2BF79CE00F, 0x66A7A4529FF79A, 0x6C53E477B861CA, 0x47FCB70C}
var CURVE_HTPC = [...]Chunk{0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
var CURVE_Order = [...]Chunk{0x1A08FFF0000001, 0x1E7033FF551190, 0x6ADE7EE322DDAF, 0x848FC9D0CED13A, 0x50D81729CC224, 0x1F0F05B98BB44A, 0x10010010005A0, 0x0, 0x0}
var CURVE_Pxaa = [...]Chunk{0xE2935374E24678, 0xC34342582408B, 0xF765CCDEFC69E, 0xC33AAD2888D7F9, 0x7FD2458967473A, 0x52908ED55CBAB3, 0x786671EB14AB88, 0xA3EC96077958C8, 0x959DE53}
var CURVE_Pxab = [...]Chunk{0x7F9EBAFFB099B8, 0x3775A012A47038, 0x6B5D1B1FC23856, 0x7F0A26A730F9E3, 0x1C38F85DB2A5CA, 0x76A753E17E6926, 0x2D39D1BE5AD0F9, 0x31733DFC651E4C, 0x3B0DED08}
var CURVE_Pxba = [...]Chunk{0xA1CDE711AD15D3, 0x853178DF6E16ED, 0x64BF43EA3E09A1, 0x2D8CD6DE566B2F, 0xF21C26C74FDB8B, 0x47BCC89E3F6B1E, 0x3FE2103F329F00, 0x4E507AF2AA28C3, 0x3EC27FAD}
var CURVE_Pxbb = [...]Chunk{0x7AB2875EE0F480, 0x4556E43D6C4B8C, 0xFB22DF80E1CB99, 0xF70FD0122F1FFD, 0xD5DB25698EF5EA, 0x4805CE1AF1BA3A, 0x1DA7CE2E465CB7, 0xCA0799F7E65855, 0xA5B38DB}
var CURVE_Pyaa = [...]Chunk{0x86499314781AA0, 0x609DA303B70AB1, 0xA52A6145FC44BB, 0x462E04C42A3124, 0xC383AE19AE68BB, 0xA1B34F6BE4FCAD, 0x198F901AD0BF4, 0x736C094362CED0, 0x5057F35D}
var CURVE_Pyab = [...]Chunk{0xBBEC57EEAE08FA, 0x78774BAA5F96AD, 0x64CAF099A42CA0, 0xC89FBBCCF70478, 0x6B720FEF855245, 0x97F916376F7B3E, 0x60F5587B5DF7E1, 0x61EE89637816BD, 0x2CE2B496}
var CURVE_Pyba = [...]Chunk{0x730276A5F0CC41, 0xF89325530AA1F5, 0xD9CD879AF8A147, 0xEE53E8A9FE2880, 0x420F07D3715390, 0x4C15D519B71F3A, 0x1A39DD3CB5B9B1, 0x3EE631A6BE39F8, 0x18070466}
var CURVE_Pybb = [...]Chunk{0xF1B2E6515C1CAE, 0xD40D355B0988DC, 0xC243FDC38A7772, 0x5D338136B675CA, 0x164E8A1D72FCDF, 0xBBAE5CD0961AC, 0xD6D04691771EB1, 0xD9BDEC8B792840, 0x499D14EA}
var Fra = [...]Chunk{0x5CA74ABBF96F1D, 0x1FF8BD0C6FFBAD, 0x49E9E26237469C, 0x3CECA48407F8E5, 0x69D68FF59267B7, 0x5D199E33127CBD, 0xB97549184F313A, 0x4E77242DA52D8D, 0x4BBC87B9}
var Frb = [...]Chunk{0xE81A1C8E0CA60E, 0xDFEA2B20C0DF4A, 0x25327A5B7F5FA6, 0xF5343A828239A6, 0x76C78F2EADF9CF, 0x5D68B24660B8AB, 0xB50AF61628B387, 0xB555A18CDE6D5E, 0x99F78BE}
var G2_TAB []*FP8
var Modulus = [...]Chunk{0x44C1674A06152B, 0xFFE2E82D30DAF8, 0x6F1C5CBDB6A642, 0x3220DF068A328B, 0xE09E1F24406187, 0xBA825079733568, 0x6E803F2E77E4C1, 0x3CCC5BA839AEC, 0x555C0078}
Base Bits= 56
var R2modp = [...]Chunk{0x6A4A1FE013DF5B, 0xE8E46D4D1BDE65, 0x1F841391F45C67, 0x9148A4516FB28, 0x4398524EDF4C88, 0x41C0E241B6DCE8, 0xE42C208C19411, 0xA7FE6FD73A7B1C, 0xFCCCA76}
var ROI = [...]Chunk{0x44C1674A06152A, 0xFFE2E82D30DAF8, 0x6F1C5CBDB6A642, 0x3220DF068A328B, 0xE09E1F24406187, 0xBA825079733568, 0x6E803F2E77E4C1, 0x3CCC5BA839AEC, 0x555C0078}
var SQRTm3 = [...]Chunk{0x338CC191A91428, 0x747E3EE8B5998F, 0xF307D1E6911549, 0xF2991861BCA96B, 0x23CCFD4AF96A86, 0xF27F3D5CCDCB73, 0xF41800E24A1A2D, 0x3CAC5968136DB, 0x555C0078}
var TWK = [...]Chunk{0xA58920B6EA62F3, 0xCB389C5F3D7CD4, 0xECDF776BCA61B9, 0x12DE6A6D51F59E, 0x9A319AFF154D8B, 0xCEE3E70FBE1BC, 0x62935E18EE4423, 0xECF3B411A07AAB, 0x337A3266}
Functions ¶
func Another_pc ¶
Accumulate another set of line functions for n-pairing, assuming precomputation on G2
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 ¶
IEEE ECDSA Signature, C and D are signature on F using private key S
func ECDH_ECPSVDP_DH ¶
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 ¶
IEEE1363 ECDSA Signature Verification. Signature C and D on F is verified using public key W
func ECDH_IN_RANGE ¶
return true if S is in ranger 0 < S < order , else return false
func ECDH_KEY_PAIR_GENERATE ¶
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 FP_tpo ¶
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 GTcyclotomic ¶
Check that m is in cyclotomic sub-group Check that m!=1, conj(m)*m==1, and m.m^{p^8}=m^{p^4}
func KEY_PAIR_GENERATE ¶
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 ¶
generate key pair, private key S, public key W
func KeySchedule ¶
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 ¶
Implement step 2 on client side of MPin protocol
func MPIN_ENCODE_TO_CURVE ¶
func MPIN_GET_SERVER_SECRET ¶
Extract Server Secret SST=S*Q where Q is fixed generator in G2 and S is master secret
func MPIN_HASH_ID ¶
func MPIN_RANDOM_GENERATE ¶
create random secret S
func MPIN_SERVER ¶
Implement step 2 of MPin protocol on server side
Types ¶
type BIG ¶
type BIG struct {
// contains filtered or unexported fields
}
func BIG_frombytearray ¶
convert from byte array to BIG
func NewBIGcopy ¶
func NewBIGdcopy ¶
func NewBIGints ¶
type DBIG ¶
type DBIG struct {
// contains filtered or unexported fields
}
func NewDBIGcopy ¶
func NewDBIGscopy ¶
type ECP ¶
type ECP struct {
// contains filtered or unexported fields
}
func ECP_generator ¶
func ECP_generator() *ECP
type ECP4 ¶
type ECP4 struct {
// contains filtered or unexported fields
}
func ECP4_generator ¶
func ECP4_generator() *ECP4
func NewECP4fp4 ¶
construct this from x - but set to O if not on curve
func NewECP4fp4s ¶
construct this from (x,y) - but set to O if not on curve
type FP ¶
type FP struct { XES int32 // contains filtered or unexported fields }
func FP_fromBytes ¶
type FP2 ¶
type FP2 struct {
// contains filtered or unexported fields
}
func ECP4_frob_constants ¶
func ECP4_frob_constants() [3]*FP2
func FP2_fromBytes ¶
func NewFP2bigs ¶
func NewFP2copy ¶
func NewFP2ints ¶
func NewFP2rand ¶
type FP24 ¶
type FP24 struct {
// contains filtered or unexported fields
}
func NewFP24copy ¶
func NewFP24int ¶
type FP4 ¶
type FP4 struct {
// contains filtered or unexported fields
}
func FP4_fromBytes ¶
func NewFP4copy ¶
func NewFP4fp2s ¶
func NewFP4rand ¶
type FP8 ¶
type FP8 struct {
// contains filtered or unexported fields
}