Documentation ¶
Index ¶
- Constants
- Variables
- func Another(r []*FP48, P1 *ECP8, Q1 *ECP)
- func Another_pc(r []*FP48, T []*FP16, 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 *ECP8) bool
- func GTcyclotomic(m *FP48) bool
- func GTmember(m *FP48) bool
- func Init() 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)
- type 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 ECP8
- func (E *ECP8) Add(Q *ECP8) int
- func (E *ECP8) Affine()
- func (E *ECP8) Cfp()
- func (E *ECP8) Copy(P *ECP8)
- func (E *ECP8) Equals(Q *ECP8) bool
- func (E *ECP8) GetX() *FP8
- func (E *ECP8) GetY() *FP8
- func (E *ECP8) Is_infinity() bool
- func (E *ECP8) Mul(e *BIG) *ECP8
- func (E *ECP8) Sub(Q *ECP8) int
- func (E *ECP8) ToBytes(b []byte, compress bool)
- func (E *ECP8) ToString() string
- type FP
- type FP16
- type FP2
- func ECP8_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 FP4
- type FP48
- func Ate(P1 *ECP8, Q1 *ECP) *FP48
- func Ate2(P1 *ECP8, Q1 *ECP, R1 *ECP8, S1 *ECP) *FP48
- func FP48_fromBytes(w []byte) *FP48
- func Fexp(m *FP48) *FP48
- func GTpow(d *FP48, e *BIG) *FP48
- func Initmp() []*FP48
- func Miller(r []*FP48) *FP48
- func NewFP48() *FP48
- func NewFP48copy(x *FP48) *FP48
- func NewFP48fp16(d *FP16) *FP48
- func NewFP48fp16s(d *FP16, e *FP16, f *FP16) *FP48
- func NewFP48int(d int) *FP48
- type FP8
Constants ¶
const AESKEY int = 16
const ALLOW_ALT_COMPRESS bool = false
const ATE_BITS int = 17
const BAD_PARAMS int = -11
const BAD_PIN int = -19
const BASEBITS uint = 60
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 = 10
const CURVE_Cof_I int = 62958
*** rom curve parameters ***** Ate Bits= 17 G2 Table size= 20
const CURVE_PAIRING_TYPE int = BLS48
const DNLEN int = 2 * NLEN
const D_TYPE int = 0
Pairing Twist type
const EDWARDS int = 1
const EFS int = int(MODBYTES)
const INVALID int = -4
const EGS int = int(MODBYTES)
const ERROR int = -3
const FEXCESS int32 = ((int32(1) << 14) - 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 = 20
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 INVALID_PUBLIC_KEY int = -2
const MAXPIN int32 = 10000 /* PIN less than this */
const MFS int = int(MODBYTES)
const MGS int = int(MODBYTES)
const MODBITS uint = 286 /* Number of bits in Modulus */
Modulus details
const MODBYTES uint = 36
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 = 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{0x5A6539603773F7B, 0x24CEA2CA30AEE39, 0x1F28B5A98667A6F, 0xD810619F5566B10, 0x297243C332B8}
var CURVE_B = [...]Chunk{0xA, 0x0, 0x0, 0x0, 0x0}
var CURVE_Bnx = [...]Chunk{0xF5EF, 0x0, 0x0, 0x0, 0x0}
var CURVE_Cof = [...]Chunk{0xF5EE, 0x0, 0x0, 0x0, 0x0}
var CURVE_Gx = [...]Chunk{0xC897EA3095D59E0, 0xDD97475CEFBA15D, 0x544741A4E84D19, 0xDB88FB476C0F04C, 0x6972433D120}
var CURVE_Gy = [...]Chunk{0xEEF69F970ABEB43, 0x237CE6B580E3E2E, 0x3308DEE53B0AC1F, 0x6E2D78897F979AA, 0x2038E40A1E65}
var CURVE_HTPC = [...]Chunk{0x1, 0x0, 0x0, 0x0, 0x0}
var CURVE_Order = [...]Chunk{0xFC411B2FD612C81, 0x98F28822F29701F, 0xB262A94FBE4FE22, 0x9EB01535FC9EDE6, 0x86BC}
var CURVE_Pxaaa = [...]Chunk{0x8416349856106B5, 0xCC3B1CECC4CC0FE, 0xA952DACAFD9F51A, 0x71D2A27B04CAEB7, 0x22ACFD40531C}
var CURVE_Pxaab = [...]Chunk{0xDECD1BD896D1A55, 0x427718553891DA9, 0xC8A32592FEF56B9, 0x85A58D250C873E4, 0x18DBB9996B5C}
var CURVE_Pxaba = [...]Chunk{0x8811A3A67D7A35E, 0x9FAF4E8CC58A603, 0xC19A506B52AF41C, 0x7C317AE2BDE1D4D, 0xA8292D5DE0A}
var CURVE_Pxabb = [...]Chunk{0x28E8520C2F023E8, 0xF191B5CF33D2D0A, 0xE725CF5DFB62D89, 0x94CD8BBB1F92E81, 0x202BE0D55FAC}
var CURVE_Pxbaa = [...]Chunk{0x8B98D5B8F14CB9B, 0x1A17D62FE2554D8, 0xC71EF6D551B96A2, 0xF76284B52259647, 0x17527369A1E3}
var CURVE_Pxbab = [...]Chunk{0xBF6B286CB60DD54, 0xB8532B9371A2443, 0x638D54D7E6BE9C0, 0x59F346C42D3760D, 0x1101EA485E9D}
var CURVE_Pxbba = [...]Chunk{0x20A5B0AB9D776DA, 0xA657276121135FA, 0xDE41458BE4ADABA, 0xE41FCEF60E4AAD4, 0xF606FCE261F}
var CURVE_Pxbbb = [...]Chunk{0xF3FE23828B50A8E, 0x77554EF2609CEB5, 0x72CE1923A1EC9A5, 0x19566C5168C0002, 0x1F0B30E6920D}
var CURVE_Pyaaa = [...]Chunk{0x26CD5FD67E988BE, 0x1FE5EF8E978BCEE, 0x39B2544F14E8B3, 0xCD557C7F38694FF, 0x21F0F8CDA962}
var CURVE_Pyaab = [...]Chunk{0x778566D0DF11B92, 0x83331801EBC5E08, 0xB840129F0DB40CB, 0xD7A943A25E15861, 0xE01C1FEC6FE}
var CURVE_Pyaba = [...]Chunk{0x47CFA67ABFDD06A, 0x4BCDAB08CFE5925, 0x55AE0A98D2EB8E6, 0xBEA2D9EBB35EFF2, 0x12C0FFB8C3D6}
var CURVE_Pyabb = [...]Chunk{0xB3DDFD3788A47F4, 0x195F9A36106B328, 0x4B28538511F157D, 0xFF3A1DDBDD352B3, 0x156831E55BDF}
var CURVE_Pybaa = [...]Chunk{0xB6EDB7345E39E77, 0x4C8190FF9538C4C, 0xF647CDEF2511932, 0x84EB4F5EF4193ED, 0x738E40AA018}
var CURVE_Pybab = [...]Chunk{0x3282814364975C6, 0xBE24AD9CA88C0B0, 0x1969B0DAE613723, 0x24391C50369BE1A, 0x13658766896E}
var CURVE_Pybba = [...]Chunk{0xBD339ABC1BF2D7C, 0xB713EF1B3AA2440, 0x6145A099D3837F1, 0xC9C5EE34A88F81B, 0x1FB0A8375143}
var CURVE_Pybbb = [...]Chunk{0xAA9A0D1E51130A6, 0xEB9E708362553DA, 0xEDA47676A7C687E, 0x9E9A1777B2D6330, 0x193F378DC6AC}
var Fra = [...]Chunk{0xEA8695F3FC90183, 0xC556BED1BD3E936, 0xD903EF0268F09A7, 0x114E8AEC2FE0043, 0xD9417EC522C}
var Frb = [...]Chunk{0xFCC9959E0D332D8, 0x30EB0580D0F69A2, 0xEFC3F2A99B90003, 0xC66195305165A42, 0x1BDEAD459A4F}
var G2_TAB []*FP16
var Modulus = [...]Chunk{0xE7502B9209C345B, 0xF641C4528E352D9, 0xC8C7E1AC04809AA, 0xD7B0201C8145A86, 0x2972C531EC7B}
Base bits= 60
var R2modp = [...]Chunk{0x61F9539D245AF2C, 0xA1991A6E51410D8, 0x1603A99FC661885, 0xC8A2CE485CD7822, 0xD54A6F0B25E}
var ROI = [...]Chunk{0xE7502B9209C345A, 0xF641C4528E352D9, 0xC8C7E1AC04809AA, 0xD7B0201C8145A86, 0x2972C531EC7B}
var SQRTm3 = [...]Chunk{0xCD7A472E6524A9C, 0x535B8141D328998, 0x758989A7084EB33, 0xD870A3222987B99, 0x2971C25478F5}
var TWK = [...]Chunk{0xA7D9735C3D05DCC, 0x1997054542A70B9, 0xBCCBD14CBAA2C6A, 0x33519F37367221F, 0x1D20EDEF448A}
Functions ¶
func Another_pc ¶
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^16}=m^{p^8}
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 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 ECP8 ¶
type ECP8 struct {
// contains filtered or unexported fields
}
func ECP8_generator ¶
func ECP8_generator() *ECP8
func ECP8_hap2point ¶
func ECP8_map2point ¶
Deterministic mapping of Fp to point on curve
func NewECP8fp8 ¶
construct this from x - but set to O if not on curve
func NewECP8fp8s ¶
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 FP16 ¶
type FP16 struct {
// contains filtered or unexported fields
}
func FP16_fromBytes ¶
func NewFP16copy ¶
func NewFP16fp8 ¶
func NewFP16fp8s ¶
type FP2 ¶
type FP2 struct {
// contains filtered or unexported fields
}
func ECP8_frob_constants ¶
func ECP8_frob_constants() [3]*FP2
func FP2_fromBytes ¶
func NewFP2bigs ¶
func NewFP2copy ¶
func NewFP2ints ¶
func NewFP2rand ¶
type FP4 ¶
type FP4 struct {
// contains filtered or unexported fields
}
func FP4_fromBytes ¶
func NewFP4copy ¶
func NewFP4fp2s ¶
func NewFP4rand ¶
type FP48 ¶
type FP48 struct {
// contains filtered or unexported fields
}
func NewFP48copy ¶
func NewFP48int ¶
type FP8 ¶
type FP8 struct {
// contains filtered or unexported fields
}