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 = 32
const ALLOW_ALT_COMPRESS bool = false
const ATE_BITS int = NOT
const BASEBITS uint = 58
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 = MONTGOMERY
const CURVE_A int = 156326
const CURVE_B_I int = 0
const CURVE_Cof_I int = 4
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) << 16) - 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 = 64
const HBITS uint = (BASEBITS / 2)
const HTC_ISO int = 0
const HTC_ISO_G2 int = 0
const MODBITS uint = 448 /* Number of bits in Modulus */
Modulus details
const MODBYTES uint = 56
BIG length in bytes and number base
const MODTYPE int = GENERALISED_MERSENNE //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 = 0 /* 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_B = [...]Chunk{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
var CURVE_Cof = [...]Chunk{0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
var CURVE_Gx = [...]Chunk{0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
var CURVE_Gy = [...]Chunk{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
var CURVE_HTPC = [...]Chunk{0x3FFFFFFFFFFFFFE, 0x3FFFFFFFFFFFFFF, 0x3FFFFFFFFFFFFFF, 0x3FBFFFFFFFFFFFF, 0x3FFFFFFFFFFFFFF, 0x3FFFFFFFFFFFFFF, 0x3FFFFFFFFFFFFFF, 0x3FFFFFFFFFF}
var CURVE_Order = [...]Chunk{0x378C292AB5844F3, 0x3309CA37163D548, 0x1B49AED63690216, 0x3FDF3288FA7113B, 0x3FFFFFFFFFFFFFF, 0x3FFFFFFFFFFFFFF, 0x3FFFFFFFFFFFFFF, 0xFFFFFFFFFF}
var Modulus = [...]Chunk{0x3FFFFFFFFFFFFFF, 0x3FFFFFFFFFFFFFF, 0x3FFFFFFFFFFFFFF, 0x3FBFFFFFFFFFFFF, 0x3FFFFFFFFFFFFFF, 0x3FFFFFFFFFFFFFF, 0x3FFFFFFFFFFFFFF, 0x3FFFFFFFFFF}
Base Bits= 58
var R2modp = [...]Chunk{0x200000000, 0x0, 0x0, 0x0, 0x3000000, 0x0, 0x0, 0x0}
var ROI = [...]Chunk{0x3FFFFFFFFFFFFFE, 0x3FFFFFFFFFFFFFF, 0x3FFFFFFFFFFFFFF, 0x3FBFFFFFFFFFFFF, 0x3FFFFFFFFFFFFFF, 0x3FFFFFFFFFFFFFF, 0x3FFFFFFFFFFFFFF, 0x3FFFFFFFFFF}
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 }