(global as any)['BigInt'] = null; import * as chai from 'chai'; const expect = chai.expect; import * as pfcurve from '../src'; import {bigInt, Fq12, pairing} from '../src'; const curveBLS12381 = pfcurve.findCurve('fp381bls12') as pfcurve.Curve; const curveBN462 = pfcurve.findCurve('fp462bn') as pfcurve.Curve; describe('both test', function() { it('BLS12-381 GT test vector', () => { // https://github.com/paulmillr/noble-bls12-381/blob/master/test/pairing.test.ts // https://github.com/herumi/mcl/blob/master/test/bls12_test.cpp const gte = Fq12.fromTuple(curveBLS12381, [ bigInt('1250EBD871FC0A92A7B2D83168D0D727272D441BEFA15C503DD8E90CE98DB3E7B6D194F60839C508A84305AACA1789B6', 16), bigInt('089A1C5B46E5110B86750EC6A532348868A84045483C92B7AF5AF689452EAFABF1A8943E50439F1D59882A98EAA0170F', 16), bigInt('1368BB445C7C2D209703F239689CE34C0378A68E72A6B3B216DA0E22A5031B54DDFF57309396B38C881C4C849EC23E87', 16), bigInt('193502B86EDB8857C273FA075A50512937E0794E1E65A7617C90D8BD66065B1FFFE51D7A579973B1315021EC3C19934F', 16), bigInt('01B2F522473D171391125BA84DC4007CFBF2F8DA752F7C74185203FCCA589AC719C34DFFBBAAD8431DAD1C1FB597AAA5', 16), bigInt('018107154F25A764BD3C79937A45B84546DA634B8F6BE14A8061E55CCEBA478B23F7DACAA35C8CA78BEAE9624045B4B6', 16), bigInt('19F26337D205FB469CD6BD15C3D5A04DC88784FBB3D0B2DBDEA54D43B2B73F2CBB12D58386A8703E0F948226E47EE89D', 16), bigInt('06FBA23EB7C5AF0D9F80940CA771B6FFD5857BAAF222EB95A7D2809D61BFE02E1BFD1B68FF02F0B8102AE1C2D5D5AB1A', 16), bigInt('11B8B424CD48BF38FCEF68083B0B0EC5C81A93B330EE1A677D0D15FF7B984E8978EF48881E32FAC91B93B47333E2BA57', 16), bigInt('03350F55A7AEFCD3C31B4FCB6CE5771CC6A0E9786AB5973320C806AD360829107BA810C5A09FFDD9BE2291A0C25A99A2', 16), bigInt('04C581234D086A9902249B64728FFD21A189E87935A954051C7CDBA7B3872629A4FAFC05066245CB9108F0242D0FE3EF', 16), bigInt('0F41E58663BF08CF068672CBD01A7EC73BACA4D72CA93544DEFF686BFD6DF543D48EAA24AFE47E1EFDE449383B676631', 16) ]); const gtc = pairing(curveBLS12381.pointG1, curveBLS12381.pointG2); expect(gtc).eql(gte); }); it('BN462 GT test vector', () => { // https://github.com/herumi/mcl/blob/master/test/bn512_test.cpp const gte = Fq12.fromTuple(curveBN462, [ bigInt('5051447334992541765184733239037987396486542637425952639114700408019910332876947170887133693174336875975833611908027935329824685781768536642'), bigInt('165283297522908429326954732315624069988501923941201290000942026394043721389259255641742915528120582381013044164928804971790994466299800636'), bigInt('1469468081131098112756384074630957615453438604581217215498294260339182317351818642017969516630279074232616028542904764121468115272028273738'), bigInt('1646715861684133363128575715576388733475437662858299306394746509450551586577969006697389920082279826537353958522171436439531937636070522794'), bigInt('5961269748149382865653769644284108364006748322381900411802481214447542217231046375519966438225297471877632001084276256530978914230282150256'), bigInt('3877906910480448652801756633918947416769104038388422332715987379102448758546082525103291004805669214464033963366486975885312003809805667766'), bigInt('3337009882813265853874868057036482260285596326118935161390801563385586395722381768583910587683729252906475155634338696003989995291152412565'), bigInt('1446474200130869253803659557404975559014416629693169384341474437265232913512716273347396242928699086297491886675672127656973569900300624280'), bigInt('4206214791079020058330402359917867616859106842972265920108189260166622215012485232819469508813812176563760687516916351245090020673166115944'), bigInt('2789374983647394376823739751383538506174961077172390729111439535769734097262804967015307527101130857529795293239776736282303200942471872735'), bigInt('6044151914096293523996182439224449769603629491778977589541587790607511156074599041783438243367972849205878925050241276904655701130265792602'), bigInt('4105942500791203180180077669193130753884528410144909717314504864946413518376521092776573084244935736056446709919101400229475112891569533398') ]); const gtc = pairing(curveBN462.pointG1, curveBN462.pointG2); expect(gtc).eql(gte); }); });