Documentation ¶
Index ¶
- Constants
- Variables
- func Another(r []*FP12, P1 *ECP2, Q1 *ECP)
- func Another_pc(r []*FP12, T []*FP4, 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 *ECP2) bool
- func GTcyclotomic(m *FP12) bool
- func GTmember(m *FP12) 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 ECP2
- func (E *ECP2) Add(Q *ECP2) int
- func (E *ECP2) Affine()
- func (E *ECP2) Cfp()
- func (E *ECP2) Copy(P *ECP2)
- func (E *ECP2) Equals(Q *ECP2) bool
- func (E *ECP2) GetX() *FP2
- func (E *ECP2) GetY() *FP2
- func (E *ECP2) Is_infinity() bool
- func (E *ECP2) Mul(e *BIG) *ECP2
- func (E *ECP2) Sub(Q *ECP2) int
- func (E *ECP2) ToBytes(b []byte, compress bool)
- func (E *ECP2) ToString() string
- type FP
- type FP12
- func Ate(P1 *ECP2, Q1 *ECP) *FP12
- func Ate2(P1 *ECP2, Q1 *ECP, R1 *ECP2, S1 *ECP) *FP12
- func FP12_fromBytes(w []byte) *FP12
- func Fexp(m *FP12) *FP12
- func GTpow(d *FP12, e *BIG) *FP12
- func Initmp() []*FP12
- func Miller(r []*FP12) *FP12
- func NewFP12() *FP12
- func NewFP12copy(x *FP12) *FP12
- func NewFP12fp4(d *FP4) *FP12
- func NewFP12fp4s(d *FP4, e *FP4, f *FP4) *FP12
- func NewFP12int(d int) *FP12
- type 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
- func RHS2(x *FP2) *FP2
- type FP4
Constants ¶
const AESKEY int = 16
const ALLOW_ALT_COMPRESS bool = false
const ATE_BITS int = 66
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 = 2
const CURVE_Cof_I int = 1
const CURVE_PAIRING_TYPE int = BN
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) << 26) - 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 = 76
const GENERALISED_MERSENNE int = 3
const HASH_TYPE int = 32
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 = 254 /* Number of bits in Modulus */
Modulus details
const MODBYTES uint = 32
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 = -1 /* G2 hash-to-point Z */
const RIADZG2B int = 0 /* G2 hash-to-point Z */
const SEXTIC_TWIST int = D_TYPE
const SIGN_OF_X int = NEGATIVEX
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{0xE0931794235C97, 0xDF6471EF875631, 0xCA83F1440BD, 0x480000, 0x0}
var CURVE_B = [...]Chunk{0x2, 0x0, 0x0, 0x0, 0x0}
var CURVE_BB = [4][4][5]Chunk{{{0x11C0A6332B0CBD, 0xD6EE0CC906CE7E, 0x647A6366D2C43F, 0x8702A0DB0BDDF, 0x24000000}, {0x11C0A6332B0CBC, 0xD6EE0CC906CE7E, 0x647A6366D2C43F, 0x8702A0DB0BDDF, 0x24000000}, {0x11C0A6332B0CBC, 0xD6EE0CC906CE7E, 0x647A6366D2C43F, 0x8702A0DB0BDDF, 0x24000000}, {0x7802562, 0x80, 0x0, 0x0, 0x0}}, {{0x7802561, 0x80, 0x0, 0x0, 0x0}, {0x11C0A6332B0CBC, 0xD6EE0CC906CE7E, 0x647A6366D2C43F, 0x8702A0DB0BDDF, 0x24000000}, {0x11C0A6332B0CBD, 0xD6EE0CC906CE7E, 0x647A6366D2C43F, 0x8702A0DB0BDDF, 0x24000000}, {0x11C0A6332B0CBC, 0xD6EE0CC906CE7E, 0x647A6366D2C43F, 0x8702A0DB0BDDF, 0x24000000}}, {{0x7802562, 0x80, 0x0, 0x0, 0x0}, {0x7802561, 0x80, 0x0, 0x0, 0x0}, {0x7802561, 0x80, 0x0, 0x0, 0x0}, {0x7802561, 0x80, 0x0, 0x0, 0x0}}, {{0x3C012B2, 0x40, 0x0, 0x0, 0x0}, {0xF004AC2, 0x100, 0x0, 0x0, 0x0}, {0x11C0A62F6AFA0A, 0xD6EE0CC906CE3E, 0x647A6366D2C43F, 0x8702A0DB0BDDF, 0x24000000}, {0x3C012B2, 0x40, 0x0, 0x0, 0x0}}}
var CURVE_Bnx = [...]Chunk{0x3C012B1, 0x40, 0x0, 0x0, 0x0}
var CURVE_Cof = [...]Chunk{0x1, 0x0, 0x0, 0x0, 0x0}
var CURVE_Gx = [...]Chunk{0x6623EF5C1B55B2, 0xD6EE18093EE1BE, 0x647A6366D3243F, 0x8702A0DB0BDDF, 0x24000000}
var CURVE_Gy = [...]Chunk{0x1, 0x0, 0x0, 0x0, 0x0}
var CURVE_HTPC = [...]Chunk{0x1, 0x0, 0x0, 0x0, 0x0}
var CURVE_Order = [...]Chunk{0x11C0A636EB1F6D, 0xD6EE0CC906CEBE, 0x647A6366D2C43F, 0x8702A0DB0BDDF, 0x24000000}
var CURVE_Pxa = [...]Chunk{0x851CEEE4D2EC74, 0x85BFA03E2726C0, 0xF5C34BBB907C, 0x7053B256358B25, 0x19682D2C}
var CURVE_Pxb = [...]Chunk{0xA58E8B2E29CFE1, 0x97B0C209C30F47, 0x37A8E99743F81B, 0x3E19F64AA011C9, 0x1466B9EC}
var CURVE_Pya = [...]Chunk{0xFBFCEBCF0BE09F, 0xB33D847EC1B30C, 0x157DAEE2096361, 0x72332B8DD81E22, 0xA79EDD9}
var CURVE_Pyb = [...]Chunk{0x904B228898EE9D, 0x4EA569D2EDEBED, 0x512D8D3461C286, 0xECC4C09035C6E4, 0x6160C39}
var CURVE_SB = [2][2][5]Chunk{{{0x5463491DB010E4, 0xB40381280, 0x6000, 0x0, 0x0}, {0x7802561, 0x80, 0x0, 0x0, 0x0}}, {{0x7802561, 0x80, 0x0, 0x0, 0x0}, {0xBD5D5D20BB33EA, 0xD6EE0188CEBCBD, 0x647A6366D2643F, 0x8702A0DB0BDDF, 0x24000000}}}
var CURVE_W = [2][5]Chunk{{0x546349162FEB83, 0xB40381200, 0x6000, 0x0, 0x0}, {0x7802561, 0x80, 0x0, 0x0, 0x0}}
var CURVE_WB = [4][5]Chunk{{0x1C2118567A84B0, 0x3C012B040, 0x2000, 0x0, 0x0}, {0xCDF995BE220475, 0x94EDA8CA7F9A36, 0x8702A0DC07E, 0x300000, 0x0}, {0x66FCCAE0F10B93, 0x4A76D4653FCD3B, 0x4381506E03F, 0x180000, 0x0}, {0x1C21185DFAAA11, 0x3C012B0C0, 0x2000, 0x0, 0x0}}
var Fra = [...]Chunk{0xD9083355C80EA3, 0x7326F173F8215B, 0x8AACA718986867, 0xA63A0164AFE18B, 0x1359082F}
var Frb = [...]Chunk{0x8D1BBC06534710, 0x63C7269546C062, 0xD9CDBC4E3ABBD8, 0x623628A900DC53, 0x10A6F7D0}
var G2_TAB []*FP4
var Modulus = [...]Chunk{0x6623EF5C1B55B3, 0xD6EE18093EE1BE, 0x647A6366D3243F, 0x8702A0DB0BDDF, 0x24000000}
Base Bits= 56
var R2modp = [...]Chunk{0x466A0618A0800A, 0x2B3A22543056A3, 0x148515B09C6600, 0xEC9EA5606BDF50, 0x1C992E66}
var ROI = [...]Chunk{0x6623EF5C1B55B2, 0xD6EE18093EE1BE, 0x647A6366D3243F, 0x8702A0DB0BDDF, 0x24000000}
var SQRTm3 = [...]Chunk{0xA4FDC033D49C84, 0x1825342A30355A, 0x646112E8AAA2C4, 0x8702A0D20BDDF, 0x24000000}
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^4}=m^{p^2}
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 ECP2 ¶
type ECP2 struct {
// contains filtered or unexported fields
}
func ECP2_generator ¶
func ECP2_generator() *ECP2
func NewECP2fp2 ¶
construct this from x - but set to O if not on curve
func NewECP2fp2s ¶
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 FP12 ¶
type FP12 struct {
// contains filtered or unexported fields
}
func GTpow ¶
f=f^e Note that this method requires a lot of RAM! Better to use compressed XTR method, see FP4.java
func NewFP12copy ¶
func NewFP12int ¶
type FP2 ¶
type FP2 struct {
// contains filtered or unexported fields
}
func FP2_fromBytes ¶
func NewFP2bigs ¶
func NewFP2copy ¶
func NewFP2ints ¶
func NewFP2rand ¶
type FP4 ¶
type FP4 struct {
// contains filtered or unexported fields
}