Documentation ¶
Index ¶
- Constants
- Variables
- 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 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 KEY_PAIR_GENERATE(RNG *core.RAND, D []byte, Q []byte) int
- func KeySchedule(config_id int, mode int, Z []byte, info []byte, psk []byte, pskID []byte) ([]byte, []byte, []byte)
- 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 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 FP
Constants ¶
const AESKEY int = 16
const ALLOW_ALT_COMPRESS bool = false
const ATE_BITS int = NOT
const BASEBITS uint = 56
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 BN int = 1
const CHUNK int = 64 /* Set word size */
const CURVETYPE int = WEIERSTRASS
const CURVE_A int = 0
const CURVE_B_I int = 7
const CURVE_Cof_I int = 1
const CURVE_PAIRING_TYPE int = NOT
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) << 24) - 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 = NOT
const GENERALISED_MERSENNE int = 3
const HASH_TYPE int = 32
const HBITS uint = (BASEBITS / 2)
const HTC_ISO int = 3
const HTC_ISO_G2 int = 0
const MODBITS uint = 256 /* 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 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 = -11 /* hash-to-point Z */
const RIADZG2A int = 0 /* G2 hash-to-point Z */
const RIADZG2B int = 0 /* G2 hash-to-point Z */
const SEXTIC_TWIST int = NOT
const SIGN_OF_X int = NOT
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
Variables ¶
var CURVE_Ad = [...]Chunk{0x5447C01A444533, 0xD363CB6F0E5D40, 0x58F0F5D272E953, 0xDD661ADCA08A55, 0x3F8731AB}
var CURVE_B = [...]Chunk{0x7, 0x0, 0x0, 0x0, 0x0}
var CURVE_Bd = [...]Chunk{0x6EB, 0x0, 0x0, 0x0, 0x0}
var CURVE_Cof = [...]Chunk{0x1, 0x0, 0x0, 0x0, 0x0}
var CURVE_Gx = [...]Chunk{0xF2815B16F81798, 0xFCDB2DCE28D959, 0x95CE870B07029B, 0xF9DCBBAC55A062, 0x79BE667E}
var CURVE_Gy = [...]Chunk{0x47D08FFB10D4B8, 0xB448A68554199C, 0xFC0E1108A8FD17, 0x26A3C4655DA4FB, 0x483ADA77}
var CURVE_HTPC = [...]Chunk{0xC813789E8624AA, 0xCA45C23F508ECD, 0x640A39CD8BBBFD, 0x813FFE30F4D5B4, 0xCCE8E9E8}
var CURVE_Order = [...]Chunk{0xD25E8CD0364141, 0xDCE6AF48A03BBF, 0xFFFFFFFFFEBAAE, 0xFFFFFFFFFFFFFF, 0xFFFFFFFF}
var Modulus = [...]Chunk{0xFFFFFEFFFFFC2F, 0xFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFF, 0xFFFFFFFF}
var PC = [13][5]Chunk{{0x38E38DAAAAA88C, 0x8E38E38E38E38E, 0xE38E38E38E38E3, 0x38E38E38E38E38, 0x8E38E38E}, {0xCBD0B53D9DD262, 0x6144037C40314E, 0xDECA25CAECE450, 0x23F234E6E2A413, 0x534C328D}, {0xFF1044F17C6581, 0xD2FC0BF63B92DF, 0xCEA7FD44C5D595, 0xBC321D5B9F315, 0x7D3D4C8}, {0x38E38DAAAAA8C7, 0x8E38E38E38E38E, 0xE38E38E38E38E3, 0x38E38E38E38E38, 0x8E38E38E}, {0x2A56612A8C6D14, 0x6B641F5E41BBC5, 0xD51B54225406D3, 0x4383DC1DF7C4B2, 0xEDADC6F6}, {0xE6B745781EB49B, 0x409542F8487D9F, 0xCBB7B640DD86CD, 0x3D94918A9CA34C, 0xD3577119}, {0xBDA12F38E38D84, 0x2F684BDA12F684, 0x4BDA12F684BDA1, 0x12F684BDA12F68, 0x2F684BDA}, {0x65E85A9ECEE931, 0x30A201BE2018A7, 0xEF6512E5767228, 0x91F91A73715209, 0x29A61946}, {0xFC90FC201D71A3, 0xB046D686DA6FDF, 0x4B12A0A6D5647A, 0xD5CB7C0FA9D0A5, 0xC75E0C32}, {0x2F684B8E38E23C, 0x4BDA12F684BDA1, 0x12F684BDA12F68, 0x84BDA12F684BDA, 0x4BDA12F6}, {0xBF8192BFD2A76F, 0x21162F0D6299A7, 0x3FA8FE337E0A3D, 0x6545CA2CF3A70C, 0x6484AA71}, {0xB425D2685C2573, 0xC1BFC8E8D978DF, 0x632722C2989467, 0xB8BDB49FD5E9E6, 0x7A06534B}, {0xFFFFFEFFFFF93B, 0xFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFF, 0xFFFFFFFF}}
var R2modp = [...]Chunk{0xA1000000000000, 0x7A2000E90, 0x1, 0x0, 0x0}
var ROI = [...]Chunk{0xFFFFFEFFFFFC2E, 0xFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFF, 0xFFFFFFFF}
var SQRTm3 = [...]Chunk{0x8D27AE1CD5F852, 0x6D15DA14ECD47D, 0xC2A797962CC61F, 0x3507F1DF233770, 0xA2D2BA9}
Functions ¶
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 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 KeySchedule ¶
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 FP ¶
type FP struct { XES int32 // contains filtered or unexported fields }