amcl

package
v0.0.0-...-ed57906 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2017 License: Apache-2.0 Imports: 2 Imported by: 0

README

AMCL is very simple to build for Go.

This version supports both 32-bit and 64-bit builds.
If your processor and operating system are both 64-bit, a 64-bit build 
will probably be best. Otherwise use a 32-bit build.
64-bit is default, you can switch by renaming ROM32.txt to ROM32.go, 
and renaming ROM64.go to ROM64.txt.

Next - decide the modulus and curve type you want to use. Edit ROM32.go 
or ROM64.go where indicated. You will probably want to use one of the curves whose 
details are already in there.

To install, simply run go install github.com/manudrijvers/amcl/go.

Documentation

Index

Constants

View Source
const AES_S uint = 0
View Source
const BASEBITS uint = 56
View Source
const BIGBITS int = int(MODBYTES * 8)
View Source
const BLS_CURVE int = 1
View Source
const BN_CURVE int = 0
View Source
const CHUNK int = 64 /* Set word size */
View Source
const CURVETYPE int = WEIERSTRASS

BN646 Curve

const CURVETYPE int=WEIERSTRASS const CURVE_PAIRING_TYPE int=BN_CURVE const CURVE_A int= 0

var CURVE_Order=[...]Chunk {0x2406C07E04200D,0x2405103F0108000,0xD418607E0000000,0x301B00000901441,0x400000006C0A206,0xD814422E14402,0x6C051024000000,0xD8000000000000,0x9006C,0x240000,0x240000000000} var CURVE_B = [...]Chunk {0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0} var CURVE_Cof = [...]Chunk {0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0} var CURVE_Gx =[...]Chunk {0x2406C08404E012,0x240510420138000,0xE01920840000000,0x601B00000901441,0x400000006C0A206,0xD814423414402,0x6C051024000000,0xD8000000000000,0x9006C,0x240000,0x240000000000} var CURVE_Gy =[...]Chunk {0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}

var CURVE_Bnx=[...]Chunk {0x1001,0x4000,0x10000000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0} var CURVE_Cru=[...]Chunk {0x1202401B007,0xD812006C000,0x480510240000000,0x200480000000360,0x1B01,0x3602403600,0xD800000000,0x0,0x12,0x0,0x0} var CURVE_Fra=[...]Chunk {0x76EAD944929A14,0xB7E0A0BE10CDF74,0x4FB8A8A2B93166B,0xECDFC4B0F037D9,0xC27307962815598,0xCF5EF558D2135D8,0x8CE651FD85AF9C3,0x80AF6D02A45219F,0x69B8147979A41A4,0x9577C152A374C5B,0x9FF28B3A478} var CURVE_Frb=[...]Chunk {0xFAD1BE73F7245FF,0x6C246F83F06A08B,0x906077E146CE994,0x514D03B4F9FDC68,0x7D8CF86A43F4C6E,0x31791EE96200E29,0x79D9FF04BA5063C,0x8CD092FD5BADE60,0x9647EB8686EBEC7,0x6A883EAD5ECB3A4,0x1A00D74C5B87} var CURVE_Pxa=[...]Chunk {0x4233F273CCC5E10,0x6408117FB1B1FFA,0xA7978AC166486AA,0xDA6417BDCFDC1D0,0xDCE981D68FA7F5C,0x4169ED790F45048,0xBA06CCE894F26BE,0xB0C98247FD18141,0x30CE35212F353A6,0xFF9A1B9162B0B9E,0xFD835F078BF} var CURVE_Pxb=[...]Chunk {0x837F879267F4BC0,0x443F1581FA770ED,0x8FBA0763CB82027,0xA8F7E5DE4945F11,0x780AAE5D219F786,0xF3BB745205342E9,0xCC0A34FF057013C,0xA6DFAF3E689709E,0xD69FBD8D12B6B79,0x6A1715D9469215D,0x1764FA509C41} var CURVE_Pya=[...]Chunk {0xC570D1DCC3FB414,0xD0ABFE7F36161E4,0xABA2F61496C849A,0x4E4A05030CD4F3F,0x70F7CECD5CEF83,0x9D4711CBF491613,0xDF8011EA770418E,0x56548E514EC94EC,0xC9E853DFF35EE42,0x5481ABBAAD13633,0x78D8A63783F} var CURVE_Pyb=[...]Chunk {0xAFE3E3DB33908AD,0x7CD4290A506594C,0xFA043D85973EC3F,0xFAC7A642BB5E628,0x71A36A52DA82EE2,0x12C2231EDAE0C76,0x994DF2771091B48,0xCFFF7637B76831C,0xD463BD03DA14916,0x1074F23C580C40,0x12188D99546B} var CURVE_W=[2][NLEN]Chunk {{0x6008003,0x30020000,0xC0080060000000,0x300000000000000,0x0,0x600000,0x0,0x0,0x0,0x0,0x0},{0x2001,0x8000,0x20000000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}} var CURVE_SB=[2][2][NLEN]Chunk {{{0x600A004,0x30028000,0xC00A0060000000,0x300000000000000,0x0,0x600000,0x0,0x0,0x0,0x0,0x0},{0x2001,0x8000,0x20000000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}},{{0x2001,0x8000,0x20000000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},{0x2406C07803A00A,0x2405103C00E8000,0xC817E0780000000,0x1B00000901441,0x400000006C0A206,0xD814422814402,0x6C051024000000,0xD8000000000000,0x9006C,0x240000,0x240000000000}}} var CURVE_WB=[4][NLEN]Chunk {{0x2001000,0x10004000,0x40010020000000,0x100000000000000,0x0,0x200000,0x0,0x0,0x0,0x0,0x0},{0xC01C015005,0x900E0054000,0x3803901C0000000,0xE00300000000240,0x1200,0x2401C02400,0x9000000000,0x0,0xC,0x0,0x0},{0x600E00B003,0x4807002C000,0x1C01D00E0000000,0x700180000000120,0x900,0x1200E01200,0x4800000000,0x0,0x6,0x0,0x0},{0x2003001,0x1000C000,0x40030020000000,0x100000000000000,0x0,0x200000,0x0,0x0,0x0,0x0,0x0}} var CURVE_BB=[4][4][NLEN]Chunk {{{0x2406C07E04100D,0x2405103F0104000,0xD418507E0000000,0x301B00000901441,0x400000006C0A206,0xD814422E14402,0x6C051024000000,0xD8000000000000,0x9006C,0x240000,0x240000000000},{0x2406C07E04100C,0x2405103F0104000,0xD418507E0000000,0x301B00000901441,0x400000006C0A206,0xD814422E14402,0x6C051024000000,0xD8000000000000,0x9006C,0x240000,0x240000000000},{0x2406C07E04100C,0x2405103F0104000,0xD418507E0000000,0x301B00000901441,0x400000006C0A206,0xD814422E14402,0x6C051024000000,0xD8000000000000,0x9006C,0x240000,0x240000000000},{0x2002,0x8000,0x20000000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}},{{0x2001,0x8000,0x20000000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},{0x2406C07E04100C,0x2405103F0104000,0xD418507E0000000,0x301B00000901441,0x400000006C0A206,0xD814422E14402,0x6C051024000000,0xD8000000000000,0x9006C,0x240000,0x240000000000},{0x2406C07E04100D,0x2405103F0104000,0xD418507E0000000,0x301B00000901441,0x400000006C0A206,0xD814422E14402,0x6C051024000000,0xD8000000000000,0x9006C,0x240000,0x240000000000},{0x2406C07E04100C,0x2405103F0104000,0xD418507E0000000,0x301B00000901441,0x400000006C0A206,0xD814422E14402,0x6C051024000000,0xD8000000000000,0x9006C,0x240000,0x240000000000}},{{0x2002,0x8000,0x20000000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},{0x2001,0x8000,0x20000000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},{0x2001,0x8000,0x20000000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},{0x2001,0x8000,0x20000000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}},{{0x1002,0x4000,0x10000000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},{0x4002,0x10000,0x40000000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},{0x2406C07E04000A,0x2405103F0100000,0xD418407E0000000,0x301B00000901441,0x400000006C0A206,0xD814422E14402,0x6C051024000000,0xD8000000000000,0x9006C,0x240000,0x240000000000},{0x1002,0x4000,0x10000000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}}}

const USE_GLV bool=true const USE_GS_G2 bool=true const USE_GS_GT bool=true const GT_STRONG bool=false

BNCX Curve

const CURVETYPE int=WEIERSTRASS const CURVE_PAIRING_TYPE int=BN_CURVE const CURVE_A int= 0 var CURVE_B = [...]Chunk {0x2,0x0,0x0,0x0,0x0} var CURVE_Cof = [...]Chunk {0x1,0x0,0x0,0x0,0x0}

var CURVE_Order=[...]Chunk {0x11C0A636EB1F6D,0xD6EE0CC906CEBE,0x647A6366D2C43F,0x8702A0DB0BDDF,0x24000000} var CURVE_Bnx=[...]Chunk {0x3C012B1,0x40,0x0,0x0,0x0} var CURVE_Cru=[...]Chunk {0xE0931794235C97,0xDF6471EF875631,0xCA83F1440BD,0x480000,0x0} var CURVE_Fra=[...]Chunk {0xD9083355C80EA3,0x7326F173F8215B,0x8AACA718986867,0xA63A0164AFE18B,0x1359082F} var CURVE_Frb=[...]Chunk {0x8D1BBC06534710,0x63C7269546C062,0xD9CDBC4E3ABBD8,0x623628A900DC53,0x10A6F7D0} 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_Gx =[...]Chunk {0x6623EF5C1B55B2,0xD6EE18093EE1BE,0x647A6366D3243F,0x8702A0DB0BDDF,0x24000000} var CURVE_Gy =[...]Chunk {0x1,0x0,0x0,0x0,0x0} var CURVE_W=[2][5]Chunk{{0x546349162FEB83,0xB40381200,0x6000,0x0,0x0},{0x7802561,0x80,0x0,0x0,0x0}} 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_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 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}}}

const USE_GLV bool=true const USE_GS_G2 bool=true const USE_GS_GT bool=true const GT_STRONG bool=true

BN254 Curve

View Source
const CURVE_A int = 0
View Source
const CURVE_PAIRING_TYPE int = BN_CURVE
View Source
const DNLEN int = 2 * NLEN
View Source
const ECDH_EAS int = 16
View Source
const ECDH_EBS int = 16
View Source
const ECDH_EFS int = int(MODBYTES)
View Source
const ECDH_EGS int = int(MODBYTES)
View Source
const ECDH_ERROR int = -3
View Source
const ECDH_HASH_TYPE int = ECDH_SHA512
View Source
const ECDH_INVALID int = -4
View Source
const ECDH_INVALID_PUBLIC_KEY int = -2
View Source
const ECDH_SHA256 int = 32
View Source
const ECDH_SHA384 int = 48
View Source
const ECDH_SHA512 int = 64
View Source
const EDWARDS int = 1
View Source
const FFLEN int = 4

RSA/DH modulus length as multiple of BIGBITS

View Source
const FF_BITS int = (BIGBITS * FFLEN) /* Finite Field Size in bits - must be 256.2^n */

Finite field support - for RSA, DH etc.

View Source
const FULL bool = true
View Source
const GCM_ACCEPTING_CIPHER int = 1
View Source
const GCM_ACCEPTING_HEADER int = 0
View Source
const GCM_DECRYPTING int = 1
View Source
const GCM_ENCRYPTING int = 0
View Source
const GCM_FINISHED int = 3
View Source
const GCM_NOT_ACCEPTING_MORE int = 2
View Source
const GENERALISED_MERSENNE int = 3
View Source
const GT_STRONG bool = false
View Source
const HBITS uint = (BASEBITS / 2)
View Source
const HFLEN int = (FFLEN / 2) /* Useful for half-size RSA private key operations */
View Source
const MOD8 uint = 3 /* Modulus mod 8 */
View Source
const MODBITS uint = 254 /* Number of bits in Modulus */

BN254 Curve

View Source
const MODBYTES uint = (1 + (MODBITS-1)/8)
View Source
const MODTYPE int = NOT_SPECIAL

BN254 Curve

View Source
const MONTGOMERY int = 2
View Source
const MONTGOMERY_FRIENDLY int = 2
View Source
const MPIN_BAD_PARAMS int = -11
View Source
const MPIN_BAD_PIN int = -19
View Source
const MPIN_EFS int = int(MODBYTES)
View Source
const MPIN_EGS int = int(MODBYTES)
View Source
const MPIN_HASH_TYPE int = MPIN_SHA256
View Source
const MPIN_INVALID_POINT int = -14
View Source
const MPIN_MAXPIN int32 = 10000 /* PIN less than this */
View Source
const MPIN_PAS int = 16
View Source
const MPIN_PBLEN int32 = 14 /* Number of bits in PIN */
View Source
const MPIN_SHA256 int = 32
View Source
const MPIN_SHA384 int = 48
View Source
const MPIN_SHA512 int = 64
View Source
const MPIN_TRAP int = 200 /* 200 for 4 digit PIN, 2000 for 6-digit PIN  - approx 2*sqrt(MAXPIN) */
View Source
const MPIN_TS int = 10 /* 10 for 4 digit PIN, 14 for 6-digit PIN - 2^TS/TS approx = sqrt(MAXPIN) */
View Source
const MPIN_WRONG_ORDER int = -18
View Source
const NEXCESS int = (1 << (uint(CHUNK) - BASEBITS - 1))
View Source
const NLEN int = int((1 + ((MODBITS - 1) / BASEBITS)))

Don't Modify from here...

View Source
const NOT_SPECIAL int = 0
View Source
const PERMITS bool = true
View Source
const PINERROR bool = true
View Source
const PSEUDO_MERSENNE int = 1
View Source
const P_MB uint = (P_MBITS % BASEBITS)
View Source
const P_MBITS uint = MODBYTES * 8
View Source
const P_TBITS uint = (P_MBITS % BASEBITS)
View Source
const RSA_HASH_TYPE int = RSA_SHA256
View Source
const RSA_RFS int = int(MODBYTES) * FFLEN
View Source
const RSA_SHA256 int = 32
View Source
const RSA_SHA384 int = 48
View Source
const RSA_SHA512 int = 64
View Source
const SINGLE_PASS bool = false
View Source
const TBITS uint = MODBITS % BASEBITS // Number of active bits in top word
View Source
const USE_GLV bool = true
View Source
const USE_GS_G2 bool = true
View Source
const USE_GS_GT bool = true
View Source
const WEIERSTRASS int = 0

Variables

View Source
var CURVE_B = [...]Chunk{0x2, 0x0, 0x0, 0x0, 0x0}
View Source
var CURVE_BB = [4][4][5]Chunk{{{0x8000000000000D, 0x80000000001060, 0x8000000007FF9F, 0x40000001BA344D, 0x25236482}, {0x8000000000000C, 0x80000000001060, 0x8000000007FF9F, 0x40000001BA344D, 0x25236482}, {0x8000000000000C, 0x80000000001060, 0x8000000007FF9F, 0x40000001BA344D, 0x25236482}, {0x2, 0x81, 0x0, 0x0, 0x0}}, {{0x1, 0x81, 0x0, 0x0, 0x0}, {0x8000000000000C, 0x80000000001060, 0x8000000007FF9F, 0x40000001BA344D, 0x25236482}, {0x8000000000000D, 0x80000000001060, 0x8000000007FF9F, 0x40000001BA344D, 0x25236482}, {0x8000000000000C, 0x80000000001060, 0x8000000007FF9F, 0x40000001BA344D, 0x25236482}}, {{0x2, 0x81, 0x0, 0x0, 0x0}, {0x1, 0x81, 0x0, 0x0, 0x0}, {0x1, 0x81, 0x0, 0x0, 0x0}, {0x1, 0x81, 0x0, 0x0, 0x0}}, {{0x80000000000002, 0x40, 0x0, 0x0, 0x0}, {0x2, 0x102, 0x0, 0x0, 0x0}, {0xA, 0x80000000001020, 0x8000000007FF9F, 0x40000001BA344D, 0x25236482}, {0x80000000000002, 0x40, 0x0, 0x0, 0x0}}}
View Source
var CURVE_Bnx = [...]Chunk{0x80000000000001, 0x40, 0x0, 0x0, 0x0}
View Source
var CURVE_Cof = [...]Chunk{0x1, 0x0, 0x0, 0x0, 0x0}
View Source
var CURVE_Cru = [...]Chunk{0x80000000000007, 0x6CD, 0x40000000024909, 0x49B362, 0x0}
View Source
var CURVE_Fra = [...]Chunk{0x7DE6C06F2A6DE9, 0x74924D3F77C2E1, 0x50A846953F8509, 0x212E7C8CB6499B, 0x1B377619}
View Source
var CURVE_Frb = [...]Chunk{0x82193F90D5922A, 0x8B6DB2C08850C5, 0x2F57B96AC8DC17, 0x1ED1837503EAB2, 0x9EBEE69}
View Source
var CURVE_Gx = [...]Chunk{0x12, 0x13A7, 0x80000000086121, 0x40000001BA344D, 0x25236482}
View Source
var CURVE_Gy = [...]Chunk{0x1, 0x0, 0x0, 0x0, 0x0}
View Source
var CURVE_Order = [...]Chunk{0xD, 0x800000000010A1, 0x8000000007FF9F, 0x40000001BA344D, 0x25236482}
View Source
var CURVE_Pxa = [...]Chunk{0xEE4224C803FB2B, 0x8BBB4898BF0D91, 0x7E8C61EDB6A464, 0x519EB62FEB8D8C, 0x61A10BB}
View Source
var CURVE_Pxb = [...]Chunk{0x8C34C1E7D54CF3, 0x746BAE3784B70D, 0x8C5982AA5B1F4D, 0xBA737833310AA7, 0x516AAF9}
View Source
var CURVE_Pya = [...]Chunk{0xF0E07891CD2B9A, 0xAE6BDBE09BD19, 0x96698C822329BD, 0x6BAF93439A90E0, 0x21897A0}
View Source
var CURVE_Pyb = [...]Chunk{0x2D1AEC6B3ACE9B, 0x6FFD739C9578A, 0x56F5F38D37B090, 0x7C8B15268F6D44, 0xEBB2B0E}
View Source
var CURVE_SB = [2][2][5]Chunk{{{0x4, 0x80000000000285, 0x6181, 0x0, 0x0}, {0x1, 0x81, 0x0, 0x0, 0x0}}, {{0x1, 0x81, 0x0, 0x0, 0x0}, {0xA, 0xE9D, 0x80000000079E1E, 0x40000001BA344D, 0x25236482}}}
View Source
var CURVE_W = [2][5]Chunk{{0x3, 0x80000000000204, 0x6181, 0x0, 0x0}, {0x1, 0x81, 0x0, 0x0, 0x0}}
View Source
var CURVE_WB = [4][5]Chunk{{0x80000000000000, 0x80000000000040, 0x2080, 0x0, 0x0}, {0x80000000000005, 0x54A, 0x8000000001C707, 0x312241, 0x0}, {0x80000000000003, 0x800000000002C5, 0xC000000000E383, 0x189120, 0x0}, {0x80000000000001, 0x800000000000C1, 0x2080, 0x0, 0x0}}
View Source
var Modulus = [...]Chunk{0x13, 0x13A7, 0x80000000086121, 0x40000001BA344D, 0x25236482}
View Source
var SHA256ID = [...]byte{0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20}

SHAXXX identifier strings

View Source
var SHA384ID = [...]byte{0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05, 0x00, 0x04, 0x30}
View Source
var SHA512ID = [...]byte{0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05, 0x00, 0x04, 0x40}

Functions

func AES_CBC_IV0_DECRYPT

func AES_CBC_IV0_DECRYPT(K []byte, C []byte) []byte

returns plaintext if all consistent, else returns null string

func AES_CBC_IV0_ENCRYPT

func AES_CBC_IV0_ENCRYPT(K []byte, M []byte) []byte

AES encryption/decryption. Encrypt byte array M using key K and returns ciphertext

func ECDH_KEY_PAIR_GENERATE

func ECDH_KEY_PAIR_GENERATE(RNG *RAND, S []byte, W []byte) int

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 ECDH_PUBLIC_KEY_VALIDATE

func ECDH_PUBLIC_KEY_VALIDATE(full bool, W []byte) int

validate public key. Set full=true for fuller check

func ECIES_DECRYPT

func 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 ECIES_ENCRYPT

func ECIES_ENCRYPT(sha int, P1 []byte, P2 []byte, RNG *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 ECPSP_DSA

func ECPSP_DSA(sha int, RNG *RAND, S []byte, F []byte, C []byte, D []byte) int

IEEE ECDSA Signature, C and D are signature on F using private key S

func ECPSVDP_DH

func ECPSVDP_DH(S []byte, WD []byte, Z []byte) int

IEEE-1363 Diffie-Hellman online calculation Z=S.WD

func ECPVP_DSA

func ECPVP_DSA(sha int, W []byte, F []byte, C []byte, D []byte) int

IEEE1363 ECDSA Signature Verification. Signature C and D on F is verified using public key W

func HMAC

func HMAC(sha int, M []byte, K []byte, tag []byte) int

Calculate HMAC of m using key k. HMAC is tag of length olen (which is length of tag)

func KDF1

func KDF1(sha int, Z []byte, olen int) []byte

Key Derivation Functions Input octet Z Output key of length olen

func KDF2

func KDF2(sha int, Z []byte, P []byte, olen int) []byte

func MPIN_CLIENT

func MPIN_CLIENT(sha int, date int, CLIENT_ID []byte, RNG *RAND, X []byte, pin int, TOKEN []byte, SEC []byte, xID []byte, xCID []byte, PERMIT []byte, TimeValue int, Y []byte) int

One pass MPIN Client

func MPIN_CLIENT_1

func MPIN_CLIENT_1(sha int, date int, CLIENT_ID []byte, rng *RAND, X []byte, pin int, TOKEN []byte, SEC []byte, xID []byte, xCID []byte, PERMIT []byte) int

Implement step 1 on client side of MPin protocol

func MPIN_CLIENT_2

func MPIN_CLIENT_2(X []byte, Y []byte, SEC []byte) int

Implement step 2 on client side of MPin protocol

func MPIN_CLIENT_KEY

func MPIN_CLIENT_KEY(sha int, G1 []byte, G2 []byte, pin int, R []byte, X []byte, H []byte, wCID []byte, CK []byte) int

calculate common key on client side wCID = w.(A+AT)

func MPIN_DECODING

func MPIN_DECODING(D []byte) int

func MPIN_ENCODING

func MPIN_ENCODING(rng *RAND, E []byte) int

these next two functions implement elligator squared - http://eprint.iacr.org/2014/043 Elliptic curve point E in format (0x04,x,y} is converted to form {0x0-,u,v} Note that u and v are indistinguisible from random strings

func MPIN_EXTRACT_PIN

func MPIN_EXTRACT_PIN(sha int, CID []byte, pin int, TOKEN []byte) int

Extract PIN from TOKEN for identity CID

func MPIN_GET_CLIENT_PERMIT

func MPIN_GET_CLIENT_PERMIT(sha, date int, S []byte, CID []byte, CTT []byte) int

Time Permit CTT=S*(date|H(CID)) where S is master secret

func MPIN_GET_CLIENT_SECRET

func MPIN_GET_CLIENT_SECRET(S []byte, CID []byte, CST []byte) int

Client secret CST=S*H(CID) where CID is client ID and S is master secret CID is hashed externally

func MPIN_GET_G1_MULTIPLE

func MPIN_GET_G1_MULTIPLE(rng *RAND, typ int, X []byte, G []byte, W []byte) int

W=x*H(G); if RNG == NULL then X is passed in if RNG != NULL the X is passed out if type=0 W=x*G where G is point on the curve, else W=x*M(G), where M(G) is mapping of octet G to point on the curve

func MPIN_GET_SERVER_SECRET

func MPIN_GET_SERVER_SECRET(S []byte, SST []byte) int

Extract Server Secret SST=S*Q where Q is fixed generator in G2 and S is master secret

func MPIN_GET_TIME

func MPIN_GET_TIME() int

return time since epoch

func MPIN_GET_Y

func MPIN_GET_Y(sha int, TimeValue int, xCID []byte, Y []byte)

Generate Y = H(epoch, xCID/xID)

func MPIN_HASH_ALL

func MPIN_HASH_ALL(sha int, HID []byte, xID []byte, xCID []byte, SEC []byte, Y []byte, R []byte, W []byte) []byte

func MPIN_HASH_ID

func MPIN_HASH_ID(sha int, ID []byte) []byte

func MPIN_KANGAROO

func MPIN_KANGAROO(E []byte, F []byte) int

Pollards kangaroos used to return PIN error

func MPIN_PRECOMPUTE

func MPIN_PRECOMPUTE(TOKEN []byte, CID []byte, G1 []byte, G2 []byte) int

func MPIN_RANDOM_GENERATE

func MPIN_RANDOM_GENERATE(rng *RAND, S []byte) int

create random secret S

func MPIN_RECOMBINE_G1

func MPIN_RECOMBINE_G1(R1 []byte, R2 []byte, R []byte) int

R=R1+R2 in group G1

func MPIN_RECOMBINE_G2

func MPIN_RECOMBINE_G2(W1 []byte, W2 []byte, W []byte) int

W=W1+W2 in group G2

func MPIN_SERVER

func MPIN_SERVER(sha int, date int, HID []byte, HTID []byte, Y []byte, SST []byte, xID []byte, xCID []byte, SEC []byte, E []byte, F []byte, CID []byte, TimeValue int) int

One pass MPIN Server

func MPIN_SERVER_1

func MPIN_SERVER_1(sha int, date int, CID []byte, HID []byte, HTID []byte)

Outputs H(CID) and H(T|H(CID)) for time permits. If no time permits set HID=HTID

func MPIN_SERVER_2

func MPIN_SERVER_2(date int, HID []byte, HTID []byte, Y []byte, SST []byte, xID []byte, xCID []byte, mSEC []byte, E []byte, F []byte) int

Implement step 2 of MPin protocol on server side

func MPIN_SERVER_KEY

func MPIN_SERVER_KEY(sha int, Z []byte, SST []byte, W []byte, H []byte, HID []byte, xID []byte, xCID []byte, SK []byte) int

func MPIN_today

func MPIN_today() int

return time in slots since epoch

func New_rsa_private_key

func New_rsa_private_key(n int) *rsa_private_key

func New_rsa_public_key

func New_rsa_public_key(m int) *rsa_public_key

func PBKDF2

func PBKDF2(sha int, Pass []byte, Salt []byte, rep int, olen int) []byte

Password based Key Derivation Function Input password p, salt s, and repeat count Output key of length olen

func PKCS15

func PKCS15(sha int, m []byte, w []byte) bool

func RSA_DECRYPT

func RSA_DECRYPT(PRIV *rsa_private_key, G []byte, F []byte)

RSA decryption with the private key

func RSA_ENCRYPT

func RSA_ENCRYPT(PUB *rsa_public_key, F []byte, G []byte)

RSA encryption with the public key

func RSA_KEY_PAIR

func RSA_KEY_PAIR(rng *RAND, e int, PRIV *rsa_private_key, PUB *rsa_public_key)

func RSA_MGF1

func RSA_MGF1(sha int, Z []byte, olen int, K []byte)

func RSA_OAEP_DECODE

func RSA_OAEP_DECODE(sha int, p []byte, f []byte) []byte

OAEP Message Decoding for Decryption

func RSA_OAEP_ENCODE

func RSA_OAEP_ENCODE(sha int, m []byte, rng *RAND, p []byte) []byte

OAEP Message Encoding for Encryption

func RSA_PRIVATE_KEY_KILL

func RSA_PRIVATE_KEY_KILL(PRIV *rsa_private_key)

destroy the Private Key structure

Types

type AES

type AES struct {
	Nk int
	Nr int
	// contains filtered or unexported fields
}

func NewAES

func NewAES() *AES

func (*AES) Decrypt

func (A *AES) Decrypt(buff []byte) uint32

Decrypt using selected mode of operation

func (*AES) Encrypt

func (A *AES) Encrypt(buff []byte) uint32

Encrypt using selected mode of operation

func (*AES) End

func (A *AES) End()

Clean up and delete left-overs

func (*AES) Getreg

func (A *AES) Getreg() [16]byte

func (*AES) Init

func (A *AES) Init(m int, nk int, key []byte, iv []byte) bool

func (*AES) Reset

func (A *AES) Reset(m int, iv []byte)

reset cipher

type BIG

type BIG struct {
	// contains filtered or unexported fields
}

func FromBytes

func FromBytes(b []byte) *BIG

func Modadd

func Modadd(a, b, m *BIG) *BIG

func Modmul

func Modmul(a, b, m *BIG) *BIG

func Modneg

func Modneg(a, m *BIG) *BIG

func Modsub

func Modsub(a, b, m *BIG) *BIG

func NewBIG

func NewBIG() *BIG

func NewBIGcopy

func NewBIGcopy(x *BIG) *BIG

func NewBIGdcopy

func NewBIGdcopy(x *DBIG) *BIG

func NewBIGint

func NewBIGint(x int) *BIG

func NewBIGints

func NewBIGints(x [NLEN]Chunk) *BIG

func Randomnum

func Randomnum(q *BIG, rng *RAND) *BIG

func (*BIG) Dec

func (r *BIG) Dec(x int)

func (*BIG) Equals

func (r *BIG) Equals(m *BIG) bool

func (*BIG) Inc

func (r *BIG) Inc(x int)

func (*BIG) Invmodp

func (r *BIG) Invmodp(p *BIG)

func (*BIG) Mod

func (r *BIG) Mod(m *BIG)

func (*BIG) Powmod

func (r *BIG) Powmod(e *BIG, m *BIG) *BIG

func (*BIG) Shr

func (r *BIG) Shr(k uint)

func (*BIG) Sub

func (r *BIG) Sub(x *BIG)

func (*BIG) ToBytes

func (r *BIG) ToBytes(b []byte)

func (*BIG) ToString

func (r *BIG) ToString() string

type Chunk

type Chunk int64
const BMASK Chunk = ((Chunk(1) << BASEBITS) - 1)
const FEXCESS Chunk = (Chunk(1) << (BASEBITS*uint(NLEN) - MODBITS))
const HMASK Chunk = ((Chunk(1) << HBITS) - 1)
const MConst Chunk = 0x435E50D79435E5
const OMASK Chunk = ((Chunk(-1)) << (MODBITS % BASEBITS))
const P_FEXCESS Chunk = (Chunk(1) << (BASEBITS*uint(NLEN) - P_MBITS))
const P_OMASK Chunk = (Chunk(-1) << (P_MBITS % BASEBITS))
const TMASK Chunk = (Chunk(1) << TBITS) - 1

func EXCESS

func EXCESS(a *BIG) Chunk

calculate Field Excess

func FF_EXCESS

func FF_EXCESS(a *BIG) Chunk

type DBIG

type DBIG struct {
	// contains filtered or unexported fields
}

func NewDBIG

func NewDBIG() *DBIG

func NewDBIGcopy

func NewDBIGcopy(x *DBIG) *DBIG

func NewDBIGscopy

func NewDBIGscopy(x *BIG) *DBIG

type ECP

type ECP struct {
	INF bool
	// contains filtered or unexported fields
}

func ECP_fromBytes

func ECP_fromBytes(b []byte) *ECP

convert from byte array to point

func G1mul

func G1mul(P *ECP, e *BIG) *ECP

Multiply P by e in group G1

func NewECP

func NewECP() *ECP

Constructors

func NewECPbig

func NewECPbig(ix *BIG) *ECP

set from x - calculate y from curve equation

func NewECPbigint

func NewECPbigint(ix *BIG, s int) *ECP

set (x,y) from BIG and a bit

func NewECPbigs

func NewECPbigs(ix *BIG, iy *BIG) *ECP

set (x,y) from two BIGs

func (*ECP) Add

func (E *ECP) Add(Q *ECP)

func (*ECP) Copy

func (E *ECP) Copy(P *ECP)

func (*ECP) Equals

func (E *ECP) Equals(Q *ECP) bool

func (*ECP) GetX

func (E *ECP) GetX() *BIG

func (*ECP) GetY

func (E *ECP) GetY() *BIG

func (*ECP) Is_infinity

func (E *ECP) Is_infinity() bool

func (*ECP) Mul

func (E *ECP) Mul(e *BIG) *ECP

func (*ECP) Mul2

func (E *ECP) Mul2(e *BIG, Q *ECP, f *BIG) *ECP

func (*ECP) Neg

func (E *ECP) Neg()

func (*ECP) Sub

func (E *ECP) Sub(Q *ECP)

func (*ECP) ToBytes

func (E *ECP) ToBytes(b []byte)

func (*ECP) ToString

func (E *ECP) ToString() string

type ECP2

type ECP2 struct {
	INF bool
	// contains filtered or unexported fields
}

func ECP2_fromBytes

func ECP2_fromBytes(b []byte) *ECP2

convert from byte array to point

func G2mul

func G2mul(P *ECP2, e *BIG) *ECP2

Multiply P by e in group G2

func NewECP2

func NewECP2() *ECP2

func NewECP2fp2

func NewECP2fp2(ix *FP2) *ECP2

construct this from x - but set to O if not on curve

func NewECP2fp2s

func NewECP2fp2s(ix *FP2, iy *FP2) *ECP2

construct this from (x,y) - but set to O if not on curve

func (*ECP2) Add

func (E *ECP2) Add(Q *ECP2) int

func (*ECP2) Copy

func (E *ECP2) Copy(P *ECP2)

func (*ECP2) Equals

func (E *ECP2) Equals(Q *ECP2) bool

func (*ECP2) GetX

func (E *ECP2) GetX() *FP2

func (*ECP2) GetY

func (E *ECP2) GetY() *FP2

func (*ECP2) Is_infinity

func (E *ECP2) Is_infinity() bool

func (*ECP2) Mul

func (E *ECP2) Mul(e *BIG) *ECP2

func (*ECP2) Neg

func (E *ECP2) Neg()

func (*ECP2) Sub

func (E *ECP2) Sub(Q *ECP2) int

func (*ECP2) ToBytes

func (E *ECP2) ToBytes(b []byte)

func (*ECP2) ToString

func (E *ECP2) ToString() string

type FF

type FF struct {
	// contains filtered or unexported fields
}

func NewFFint

func NewFFint(n int) *FF

Constructors

type FP

type FP struct {
	// contains filtered or unexported fields
}

func NewFPbig

func NewFPbig(a *BIG) *FP

func NewFPcopy

func NewFPcopy(a *FP) *FP

func NewFPint

func NewFPint(a int) *FP

Constructors

func RHS

func RHS(x *FP) *FP

Calculate RHS of curve equation

func (*FP) Add

func (F *FP) Add(b *FP)

func (*FP) Equals

func (F *FP) Equals(a *FP) bool

func (*FP) Inverse

func (F *FP) Inverse()

func (*FP) Mul

func (F *FP) Mul(b *FP)

func (*FP) Neg

func (F *FP) Neg()

func (*FP) One

func (F *FP) One()

func (*FP) Pow

func (F *FP) Pow(e *BIG) *FP

func (*FP) Redc

func (F *FP) Redc() *BIG

func (*FP) Sqrt

func (F *FP) Sqrt() *FP

func (*FP) Sub

func (F *FP) Sub(b *FP)

func (*FP) ToString

func (F *FP) ToString() string

func (*FP) Zero

func (F *FP) Zero()

type FP12

type FP12 struct {
	// contains filtered or unexported fields
}

func Ate

func Ate(P *ECP2, Q *ECP) *FP12

func Ate2

func Ate2(P *ECP2, Q *ECP, R *ECP2, S *ECP) *FP12

func FP12_fromBytes

func FP12_fromBytes(w []byte) *FP12

convert from byte array to FP12

func Fexp

func Fexp(m *FP12) *FP12

func GTpow

func GTpow(d *FP12, e *BIG) *FP12

f=f^e Note that this method requires a lot of RAM! Better to use compressed XTR method, see FP4.java

func NewFP12copy

func NewFP12copy(x *FP12) *FP12

func NewFP12fp4

func NewFP12fp4(d *FP4) *FP12

Constructors

func NewFP12fp4s

func NewFP12fp4s(d *FP4, e *FP4, f *FP4) *FP12

func NewFP12int

func NewFP12int(d int) *FP12

func Pow4

func Pow4(q []*FP12, u []*BIG) *FP12

func (*FP12) Copy

func (F *FP12) Copy(x *FP12)

func (*FP12) Equals

func (F *FP12) Equals(x *FP12) bool

func (*FP12) Geta

func (F *FP12) Geta() *FP4

func (*FP12) Getb

func (F *FP12) Getb() *FP4

func (*FP12) Getc

func (F *FP12) Getc() *FP4

func (*FP12) Inverse

func (F *FP12) Inverse()

func (*FP12) Isunity

func (F *FP12) Isunity() bool

func (*FP12) Mul

func (F *FP12) Mul(y *FP12)

func (*FP12) One

func (F *FP12) One()

func (*FP12) Pinpow

func (F *FP12) Pinpow(e int, bts int)

func (*FP12) Pow

func (F *FP12) Pow(e *BIG) *FP12

func (*FP12) ToBytes

func (F *FP12) ToBytes(w []byte)

func (*FP12) ToString

func (F *FP12) ToString() string

type FP2

type FP2 struct {
	// contains filtered or unexported fields
}

func NewFP2big

func NewFP2big(c *BIG) *FP2

func NewFP2bigs

func NewFP2bigs(c *BIG, d *BIG) *FP2

func NewFP2copy

func NewFP2copy(x *FP2) *FP2

func NewFP2fp

func NewFP2fp(c *FP) *FP2

func NewFP2fps

func NewFP2fps(c *FP, d *FP) *FP2

func NewFP2int

func NewFP2int(a int) *FP2

Constructors

func RHS2

func RHS2(x *FP2) *FP2

Calculate RHS of twisted curve equation x^3+B/i

func (*FP2) Add

func (F *FP2) Add(x *FP2)

func (*FP2) Copy

func (F *FP2) Copy(x *FP2)

func (*FP2) Equals

func (F *FP2) Equals(x *FP2) bool

func (*FP2) GetA

func (F *FP2) GetA() *BIG

func (*FP2) GetB

func (F *FP2) GetB() *BIG

func (*FP2) Inverse

func (F *FP2) Inverse()

func (*FP2) Isunity

func (F *FP2) Isunity() bool

func (*FP2) Mul

func (F *FP2) Mul(y *FP2)

func (*FP2) Neg

func (F *FP2) Neg()

func (*FP2) One

func (F *FP2) One()

func (*FP2) Sub

func (F *FP2) Sub(x *FP2)

func (*FP2) ToString

func (F *FP2) ToString() string

func (*FP2) Zero

func (F *FP2) Zero()

type FP4

type FP4 struct {
	// contains filtered or unexported fields
}

func NewFP4copy

func NewFP4copy(x *FP4) *FP4

func NewFP4fp2

func NewFP4fp2(c *FP2) *FP4

func NewFP4fp2s

func NewFP4fp2s(c *FP2, d *FP2) *FP4

func NewFP4int

func NewFP4int(a int) *FP4

Constructors

type GCM

type GCM struct {
	Y_0 [16]byte
	// contains filtered or unexported fields
}

func (*GCM) Add_cipher

func (G *GCM) Add_cipher(cipher []byte, len int) []byte

Add Ciphertext - decrypts to plaintext

func (*GCM) Add_header

func (G *GCM) Add_header(header []byte, len int) bool

Add Header data - included but not encrypted

func (*GCM) Add_plain

func (G *GCM) Add_plain(plain []byte, len int) []byte

Add Plaintext - included and encrypted

func (*GCM) Finish

func (G *GCM) Finish(extract bool) [16]byte

Finish and extract Tag

func (*GCM) Init

func (G *GCM) Init(nk int, key []byte, niv int, iv []byte)

Initialize GCM mode

type HASH256

type HASH256 struct {
	// contains filtered or unexported fields
}

func NewHASH256

func NewHASH256() *HASH256

func (*HASH256) Hash

func (H *HASH256) Hash() []byte

Generate 32-byte Hash

func (*HASH256) Init

func (H *HASH256) Init()

Initialise Hash function

func (*HASH256) Process

func (H *HASH256) Process(byt byte)

process a single byte

func (*HASH256) Process_array

func (H *HASH256) Process_array(b []byte)

process an array of bytes

func (*HASH256) Process_num

func (H *HASH256) Process_num(n int32)

process a 32-bit integer

type HASH384

type HASH384 struct {
	// contains filtered or unexported fields
}

func NewHASH384

func NewHASH384() *HASH384

func (*HASH384) Hash

func (H *HASH384) Hash() []byte

Generate 32-byte Hash

func (*HASH384) Init

func (H *HASH384) Init()

Initialise Hash function

func (*HASH384) Process

func (H *HASH384) Process(byt byte)

process a single byte

func (*HASH384) Process_array

func (H *HASH384) Process_array(b []byte)

process an array of bytes

func (*HASH384) Process_num

func (H *HASH384) Process_num(n int32)

process a 32-bit integer

type HASH512

type HASH512 struct {
	// contains filtered or unexported fields
}

func NewHASH512

func NewHASH512() *HASH512

func (*HASH512) Hash

func (H *HASH512) Hash() []byte

Generate 32-byte Hash

func (*HASH512) Init

func (H *HASH512) Init()

Initialise Hash function

func (*HASH512) Process

func (H *HASH512) Process(byt byte)

process a single byte

func (*HASH512) Process_array

func (H *HASH512) Process_array(b []byte)

process an array of bytes

func (*HASH512) Process_num

func (H *HASH512) Process_num(n int32)

process a 32-bit integer

type RAND

type RAND struct {
	// contains filtered or unexported fields
}

func NewRAND

func NewRAND() *RAND

func (*RAND) Clean

func (R *RAND) Clean()

Terminate and clean up

func (*RAND) GetByte

func (R *RAND) GetByte() byte

get random byte

func (*RAND) Seed

func (R *RAND) Seed(rawlen int, raw []byte)

Initialize RNG with some real entropy from some external source

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL