ontology-ts-sdk
Version:
Comprehensive TypeScript library for the Ontology blockchain.
1 lines • 187 kB
JavaScript
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=41)}([function(e,t){e.exports=require("babel-runtime/helpers/createClass")},function(e,t){e.exports=require("babel-runtime/helpers/classCallCheck")},function(e,t){e.exports=require("babel-runtime/core-js/json/stringify")},function(e,t){e.exports=require("babel-runtime/regenerator")},function(e,t){e.exports=require("babel-runtime/core-js/get-iterator")},function(e,t){e.exports=require("babel-runtime/helpers/asyncToGenerator")},function(e,t){e.exports=require("axios")},function(e,t){e.exports=require("crypto-js")},function(e,t){e.exports=require("bignumber.js")},function(e,t){e.exports=require("babel-runtime/core-js/object/get-prototype-of")},function(e,t){e.exports=require("babel-runtime/helpers/possibleConstructorReturn")},function(e,t){e.exports=require("babel-runtime/helpers/inherits")},function(e,t){e.exports=require("babel-runtime/core-js/map")},function(e,t){e.exports=require("elliptic")},function(e,t){e.exports=require("bip39")},function(e,t){e.exports=require("sm.js")},function(e,t){e.exports=require("base64-url")},function(e,t){e.exports=require("long")},function(e,t){e.exports=require("crypto")},function(e,t){e.exports=require("babel-runtime/helpers/extends")},function(e,t){e.exports=require("base-58")},function(e,t){e.exports=require("babel-runtime/helpers/get")},function(e,t){e.exports=require("babel-runtime/core-js/promise")},function(e,t){e.exports=require("js-sha3")},function(e,t){e.exports=require("secure-random")},function(e,t){e.exports=require("babel-runtime/core-js/object/keys")},function(e,t){e.exports=require("babel-runtime/core-js/object/assign")},function(e,t){e.exports=require("babel-runtime/helpers/typeof")},function(e,t){e.exports=require("babel-runtime/helpers/defineProperty")},function(e,t){e.exports=require("@ont-community/hdkey-secp256r1")},function(e,t){e.exports=require("wif")},function(e,t){e.exports=require("pkcs7")},function(e,t){e.exports=require("babel-runtime/core-js/array/from")},function(e,t){e.exports=require("babel-runtime/core-js/number/is-safe-integer")},function(e,t){e.exports=require("scrypt-async")},function(e,t){e.exports=require("milagro-crypto-js")},function(e,t){e.exports=require("babel-runtime/helpers/toConsumableArray")},function(e,t){e.exports=require("@ont-community/html5-websocket")},function(e,t){e.exports=require("websocket-as-promised")},function(e,t){e.exports=require("babel-runtime/helpers/objectWithoutProperties")},function(e,t){e.exports=require("uuid")},function(e,t,r){"use strict";r.r(t);var n={};r.r(n),r.d(n,"ADDR_VERSION",function(){return I}),r.d(n,"DEFAULT_SCRYPT",function(){return B}),r.d(n,"OEP_HEADER",function(){return C}),r.d(n,"OEP_FLAG",function(){return N}),r.d(n,"WEBVIEW_SCHEME",function(){return D}),r.d(n,"DEFAULT_ALGORITHM",function(){return O}),r.d(n,"DEFAULT_SM2_ID",function(){return H}),r.d(n,"TEST_NODE",function(){return _}),r.d(n,"MAIN_NODE",function(){return z}),r.d(n,"HTTP_REST_PORT",function(){return K}),r.d(n,"HTTP_WS_PORT",function(){return U}),r.d(n,"HTTP_JSON_PORT",function(){return M}),r.d(n,"REST_API",function(){return L}),r.d(n,"ONT_NETWORK",function(){return V}),r.d(n,"TEST_ONT_URL",function(){return G}),r.d(n,"MAIN_ONT_URL",function(){return W}),r.d(n,"TOKEN_TYPE",function(){return J}),r.d(n,"DEFAULT_GAS_LIMIT",function(){return F}),r.d(n,"NATIVE_INVOKE_NAME",function(){return q}),r.d(n,"TX_MAX_SIG_SIZE",function(){return j}),r.d(n,"ONT_BIP44_PATH",function(){return Y}),r.d(n,"UNBOUND_GENERATION_AMOUNT",function(){return Q}),r.d(n,"UNBOUND_TIME_INTERVAL",function(){return X}),r.d(n,"ONT_TOTAL_SUPPLY",function(){return Z}),r.d(n,"GENESIS_BLOCK_TIMESTAMP",function(){return $});var a={};r.r(a),r.d(a,"hexstring2ab",function(){return pe}),r.d(a,"ab2hexstring",function(){return me}),r.d(a,"ab2str",function(){return ge}),r.d(a,"str2ab",function(){return we}),r.d(a,"str2hexstr",function(){return Ae}),r.d(a,"hexstr2str",function(){return Se}),r.d(a,"hex2VarBytes",function(){return ke}),r.d(a,"str2VarBytes",function(){return xe}),r.d(a,"bool2VarByte",function(){return be}),r.d(a,"hexXor",function(){return Re}),r.d(a,"num2hexstring",function(){return Ee}),r.d(a,"num2VarInt",function(){return Te}),r.d(a,"reverseHex",function(){return Pe}),r.d(a,"bigIntFromBytes",function(){return Ie}),r.d(a,"bigIntToBytes",function(){return Be}),r.d(a,"StringReader",function(){return Ce}),r.d(a,"EventEmitter",function(){return Ne}),r.d(a,"sendBackResult2Native",function(){return De}),r.d(a,"axiosPost",function(){return Oe}),r.d(a,"now",function(){return He}),r.d(a,"sha256",function(){return _e}),r.d(a,"ripemd160",function(){return ze}),r.d(a,"hash160",function(){return Ke}),r.d(a,"generateRandomArray",function(){return Ue}),r.d(a,"randomBytes",function(){return Me}),r.d(a,"generateMnemonic",function(){return Le}),r.d(a,"parseMnemonic",function(){return Ve}),r.d(a,"varifyPositiveInt",function(){return Ge}),r.d(a,"isBase64",function(){return We}),r.d(a,"isHexString",function(){return Je}),r.d(a,"unboundDeadline",function(){return Fe}),r.d(a,"calcUnboundOng",function(){return qe});var i={};r.r(i),r.d(i,"encryptWithCtr",function(){return Dt}),r.d(i,"decryptWithCtr",function(){return Ot}),r.d(i,"checkCtrDecrypted",function(){return Ht}),r.d(i,"encryptWithEcb",function(){return _t}),r.d(i,"decryptWithEcb",function(){return zt}),r.d(i,"checkEcbDecrypted",function(){return Kt}),r.d(i,"encryptWithGcm",function(){return Ut}),r.d(i,"decryptWithGcm",function(){return Mt});var u={};r.r(u),r.d(u,"Address",function(){return kt}),r.d(u,"KeyType",function(){return Qe}),r.d(u,"CurveLabel",function(){return nt}),r.d(u,"SignatureScheme",function(){return Ye}),r.d(u,"KeyParameters",function(){return it}),r.d(u,"PrivateKey",function(){return Wt}),r.d(u,"registerKeyDeserializer",function(){return qt}),r.d(u,"PublicKey",function(){return ot}),r.d(u,"PublicKeyStatus",function(){return st}),r.d(u,"Signature",function(){return Vt}),r.d(u,"Issuer",function(){return Zt}),r.d(u,"User",function(){return $t}),r.d(u,"Ecies",function(){return ur});var o={};r.r(o),r.d(o,"pushBool",function(){return Dr}),r.d(o,"pushInt",function(){return Or}),r.d(o,"pushBigNum",function(){return Hr}),r.d(o,"getStructBytes",function(){return _r}),r.d(o,"getMapBytes",function(){return zr}),r.d(o,"pushMap",function(){return Kr}),r.d(o,"pushParam",function(){return Ur}),r.d(o,"serializeAbiFunction",function(){return Mr}),r.d(o,"convertArray",function(){return Lr}),r.d(o,"convertMap",function(){return Vr}),r.d(o,"deserializeItem",function(){return Gr}),r.d(o,"createCodeParamsScript",function(){return Jr}),r.d(o,"buildSmartContractParam",function(){return Fr}),r.d(o,"buildWasmContractParam",function(){return qr}),r.d(o,"writeUint16",function(){return jr}),r.d(o,"writeUint32",function(){return Yr}),r.d(o,"writeUint64",function(){return Qr}),r.d(o,"writeVarBytes",function(){return Xr}),r.d(o,"writeString",function(){return Zr}),r.d(o,"writeAddress",function(){return $r}),r.d(o,"writeH256",function(){return en}),r.d(o,"writeI128",function(){return tn}),r.d(o,"writeBool",function(){return rn}),r.d(o,"writeVarUint",function(){return nn});var s={};r.r(s),r.d(s,"ONT_CONTRACT",function(){return vn}),r.d(s,"ONG_CONTRACT",function(){return yn}),r.d(s,"getTokenContract",function(){return pn}),r.d(s,"verifyAmount",function(){return mn}),r.d(s,"makeTransferTx",function(){return gn}),r.d(s,"makeTransferStateTx",function(){return wn}),r.d(s,"makeTransferToMany",function(){return An}),r.d(s,"makeWithdrawOngTx",function(){return Sn}),r.d(s,"makeQueryAllowanceTx",function(){return kn}),r.d(s,"makeQueryBalanceTx",function(){return xn}),r.d(s,"deserializeTransferTx",function(){return bn});var c={};r.r(c),r.d(c,"ONTID_CONTRACT",function(){return jn}),r.d(c,"buildRegIDWithPublicKeyTx",function(){return Qn}),r.d(c,"buildRegisterOntidTx",function(){return Xn}),r.d(c,"buildRegIdWithMultiControllerTx",function(){return Zn}),r.d(c,"buildMakeRevokeIdTx",function(){return $n}),r.d(c,"buildRevokeIdByMultiController",function(){return ea}),r.d(c,"buildRemoveControllerTx",function(){return ta}),r.d(c,"buildRegIdWithAttributesTx",function(){return ra}),r.d(c,"buildAddAttributeTx",function(){return na}),r.d(c,"buildRemoveAttributeTx",function(){return aa}),r.d(c,"buildGetAttributesTx",function(){return ia}),r.d(c,"buildAddAttributesByMultiControllerTx",function(){return ua}),r.d(c,"buildAddAttributesByIndexTx",function(){return oa}),r.d(c,"buildRemoveAttributesByMultiControllerTx",function(){return sa}),r.d(c,"buildRemoveAttributesByIndexTx",function(){return ca}),r.d(c,"buildGetDDOTx",function(){return la}),r.d(c,"buildAddPubKeyTx",function(){return fa}),r.d(c,"buildAddKeyByMultiControllerTx",function(){return ha}),r.d(c,"buildAddKeyByIndexTx",function(){return da}),r.d(c,"buildRemoveKeyByIndexTx",function(){return va}),r.d(c,"buildSetRecoveryTx",function(){return ya}),r.d(c,"buildUpdateRecoveryTx",function(){return pa}),r.d(c,"buildAddKeyByRecoveryTx",function(){return ma}),r.d(c,"buildRemoveKeyByRecoveryTx",function(){return ga}),r.d(c,"buildRemoveKeyByMultiControllerTx",function(){return wa}),r.d(c,"buildRemovePubKeyTx",function(){return Aa}),r.d(c,"buildGetPublicKeysTx",function(){return Sa}),r.d(c,"buildGetPublicKeyStateTx",function(){return ka}),r.d(c,"buildAddNewAuthKeyTx",function(){return xa}),r.d(c,"buildRemoveAuthKeyTx",function(){return ba}),r.d(c,"buildAddNewAuthKeyByRecoveryTx",function(){return Ra}),r.d(c,"buildRemoveAuthKeyByRecoveryTx",function(){return Ea}),r.d(c,"buildAddNewAuthKeyByControllerTx",function(){return Ta}),r.d(c,"buildRemoveAuthKeyByControllerTx",function(){return Pa}),r.d(c,"buildAddServiceTx",function(){return Ia}),r.d(c,"buildUpdateServiceTx",function(){return Ba}),r.d(c,"buildRemoveServiceTx",function(){return Ca}),r.d(c,"buildAddContextTx",function(){return Na}),r.d(c,"buildRemoveContextTx",function(){return Da}),r.d(c,"buildVerifySignatureTx",function(){return Oa}),r.d(c,"buildVerifyMultiControllerTx",function(){return Ha}),r.d(c,"buildGetServiceTx",function(){return _a}),r.d(c,"buildGetControllerTx",function(){return za}),r.d(c,"buildGetDocumentTx",function(){return Ka}),r.d(c,"getDocumentJson",function(){return Ua});var l={};r.r(l),r.d(l,"Default_params",function(){return Ma}),r.d(l,"signTransaction",function(){return La}),r.d(l,"signTransactionAsync",function(){return Va}),r.d(l,"addSign",function(){return Ga}),r.d(l,"signTx",function(){return Ja}),r.d(l,"makeInvokeTransaction",function(){return Fa}),r.d(l,"buildWasmVmInvokeCode",function(){return qa}),r.d(l,"makeWasmVmInvokeTransaction",function(){return ja}),r.d(l,"makeDeployCodeTransaction",function(){return Ya}),r.d(l,"buildTxParam",function(){return Qa}),r.d(l,"buildRpcParam",function(){return Xa}),r.d(l,"buildRestfulParam",function(){return Za}),r.d(l,"sendRawTxRestfulUrl",function(){return $a}),r.d(l,"transferStringParameter",function(){return ei}),r.d(l,"transformMapParameter",function(){return ti}),r.d(l,"transformArrayParameter",function(){return ri}),r.d(l,"transformParameter",function(){return ni}),r.d(l,"buildParamsByJson",function(){return ai}),r.d(l,"makeTransactionsByJson",function(){return ii}),r.d(l,"buildNativeTxFromJson",function(){return ui});var f={};r.r(f),r.d(f,"verifyLeafHashInclusion",function(){return fu}),r.d(f,"calculateRootHashFromAuditPath",function(){return hu}),r.d(f,"hashChildren",function(){return du}),r.d(f,"getProofNodes",function(){return vu}),r.d(f,"constructMerkleProof",function(){return yu}),r.d(f,"verifyClaimProof",function(){return pu});var h={};r.r(h),r.d(h,"InvocationTransaction",function(){return gu}),r.d(h,"NeoRpc",function(){return wu}),r.d(h,"Program",function(){return Au}),r.d(h,"SmartContract",function(){return Su}),r.d(h,"TransactionInput",function(){return ku}),r.d(h,"TransactionOutput",function(){return xu}),r.d(h,"TransactionNeo",function(){return mu});var d={};r.r(d),r.d(d,"Oep8State",function(){return Ru}),r.d(d,"TransferFrom",function(){return Eu}),r.d(d,"Oep8TxBuilder",function(){return Vu});var v={};r.r(v),r.d(v,"formatBigNumParameter",function(){return to}),r.d(v,"Oep4State",function(){return ro}),r.d(v,"Oep4TxBuilder",function(){return no});var y={};r.r(y),r.d(y,"makeRegisterCandidateTx",function(){return co}),r.d(y,"makeUnregisterCandidateTx",function(){return lo}),r.d(y,"makeApproveCandidateTx",function(){return fo}),r.d(y,"makeRejectCandidateTx",function(){return ho}),r.d(y,"makeVoteForPeerTx",function(){return vo}),r.d(y,"makeUnvoteForPeerTx",function(){return yo}),r.d(y,"makeWithdrawTx",function(){return po}),r.d(y,"makeQuitNodeTx",function(){return mo}),r.d(y,"makeChangeAuthorizationTx",function(){return go}),r.d(y,"makeSetPeerCostTx",function(){return wo}),r.d(y,"makeWithdrawFeeTx",function(){return Ao}),r.d(y,"makeAuthorizeForPeerTx",function(){return So}),r.d(y,"makeUnauthorizeForPeerTx",function(){return ko}),r.d(y,"makeAddInitPosTx",function(){return xo}),r.d(y,"makeReduceInitPosTx",function(){return bo}),r.d(y,"makeWithdrawPeerUnboundOngTx",function(){return Ro}),r.d(y,"getAttributes",function(){return Eo}),r.d(y,"getSplitFeeAddress",function(){return To}),r.d(y,"getAuthorizeInfo",function(){return Po}),r.d(y,"getGovernanceView",function(){return Io}),r.d(y,"getPeerPoolMap",function(){return Bo}),r.d(y,"getGlobalParam",function(){return Co}),r.d(y,"getTotalStake",function(){return No}),r.d(y,"getPeerUnboundOng",function(){return Do}),r.d(y,"getConfiguration",function(){return Oo}),r.d(y,"GovernanceView",function(){return Ho}),r.d(y,"PeerPoolItem",function(){return _o}),r.d(y,"PeerAttributes",function(){return zo}),r.d(y,"SplitFeeAddress",function(){return Ko}),r.d(y,"AuthorizeInfo",function(){return Uo}),r.d(y,"GlobalParam",function(){return Mo}),r.d(y,"TotalStake",function(){return Lo}),r.d(y,"Configuration",function(){return Vo});var p={};r.r(p),r.d(p,"Transfers",function(){return Go}),r.d(p,"TokenTransfer",function(){return Wo}),r.d(p,"State",function(){return Jo}),r.d(p,"Contract",function(){return Fo}),r.d(p,"TransferFrom",function(){return qo});var m={};r.r(m),r.d(m,"Oep5Param",function(){return jo}),r.d(m,"Oep5TxBuilder",function(){return ss});var g,w,A=r(1),S=r.n(A),k=r(0),x=r.n(k),b=r(19),R=r.n(b),E=r(2),T=r.n(E),P=r(14),I="17",B={cost:4096,blockSize:8,parallel:8,size:64},C="0142",N="e0",D="Ont",O={algorithm:"ECDSA",parameters:{curve:"P-256"}},H="1234567812345678",_="polaris1.ont.io",z="dappnode1.ont.io",K="20334",U="20335",M="20336",L={getBalance:"/api/v1/balance",sendRawTx:"/api/v1/transaction",getMerkleProof:"/api/v1/merkleproof"},V={MAIN:"MainNet",TEST:"TestNet"},G={SOCKET_URL:"ws://"+_+":"+U,RPC_URL:"http://"+_+":"+M,REST_URL:"http://"+_+":"+K,sendRawTxByRestful:"http://"+_+":"+K+L.sendRawTx},W={SOCKET_URL:"ws://"+z+":"+U,RPC_URL:"http://"+z+":"+M+"/",REST_URL:"http://"+z+":"+K+"/",sendRawTxByRestful:"http://"+_+":"+K+L.sendRawTx},J={ONT:"ONT",ONG:"ONG"},F=3e4,q="Ontology.Native.Invoke",j=16,Y="m/44'/1024'/0'/0/0",Q=[5,4,3,3,2,2,2,1,1,1,1,1,1,1,1,1,1,1],X=31536e3,Z=1e9,$=1530316800,ee=r(4),te=r.n(ee),re=r(20),ne=r(7);!function(e){e[e.SUCCESS=0]="SUCCESS",e[e.SESSION_EXPIRED=41001]="SESSION_EXPIRED",e[e.SERVICE_CEILING=41002]="SERVICE_CEILING",e[e.ILLEGAL_DATAFORMAT=41003]="ILLEGAL_DATAFORMAT",e[e.INVALID_VERSION=41004]="INVALID_VERSION",e[e.INVALID_METHOD=42001]="INVALID_METHOD",e[e.INVALID_PARAMS=42002]="INVALID_PARAMS",e[e.INVALID_TRANSACTION=43001]="INVALID_TRANSACTION",e[e.INVALID_ASSET=43002]="INVALID_ASSET",e[e.INVALID_BLOCK=43003]="INVALID_BLOCK",e[e.UNKNOWN_TRANSACTION=44001]="UNKNOWN_TRANSACTION",e[e.UNKNOWN_ASSET=44002]="UNKNOWN_ASSET",e[e.UNKNOWN_BLOCK=44003]="UNKNOWN_BLOCK",e[e.UNKNWN_CONTRACT=44004]="UNKNWN_CONTRACT",e[e.INTERNAL_ERROR=45001]="INTERNAL_ERROR",e[e.SMARTCODE_ERROR=47001]="SMARTCODE_ERROR",e[e.UNKNOWN_ONTID=51e3]="UNKNOWN_ONTID",e[e.NETWORK_ERROR=52e3]="NETWORK_ERROR",e[e.Decrypto_ERROR=53e3]="Decrypto_ERROR",e[e.INVALID_ADDR=53001]="INVALID_ADDR",e[e.PreExec_ERROR=54e3]="PreExec_ERROR"}(g||(g={})),function(e){e[e.PUSH0=0]="PUSH0",e[e.PUSHF=0]="PUSHF",e[e.PUSHBYTES1=1]="PUSHBYTES1",e[e.PUSHBYTES75=75]="PUSHBYTES75",e[e.PUSHDATA1=76]="PUSHDATA1",e[e.PUSHDATA2=77]="PUSHDATA2",e[e.PUSHDATA4=78]="PUSHDATA4",e[e.PUSHM1=79]="PUSHM1",e[e.PUSH1=81]="PUSH1",e[e.PUSHT=81]="PUSHT",e[e.PUSH2=82]="PUSH2",e[e.PUSH3=83]="PUSH3",e[e.PUSH4=84]="PUSH4",e[e.PUSH5=85]="PUSH5",e[e.PUSH6=86]="PUSH6",e[e.PUSH7=87]="PUSH7",e[e.PUSH8=88]="PUSH8",e[e.PUSH9=89]="PUSH9",e[e.PUSH10=90]="PUSH10",e[e.PUSH11=91]="PUSH11",e[e.PUSH12=92]="PUSH12",e[e.PUSH13=93]="PUSH13",e[e.PUSH14=94]="PUSH14",e[e.PUSH15=95]="PUSH15",e[e.PUSH16=96]="PUSH16",e[e.NOP=97]="NOP",e[e.JMP=98]="JMP",e[e.JMPIF=99]="JMPIF",e[e.JMPIFNOT=100]="JMPIFNOT",e[e.CALL=101]="CALL",e[e.RET=102]="RET",e[e.APPCALL=103]="APPCALL",e[e.SYSCALL=104]="SYSCALL",e[e.TAILCALL=105]="TAILCALL",e[e.DUPFROMALTSTACK=106]="DUPFROMALTSTACK",e[e.TOALTSTACK=107]="TOALTSTACK",e[e.FROMALTSTACK=108]="FROMALTSTACK",e[e.XDROP=109]="XDROP",e[e.XSWAP=114]="XSWAP",e[e.XTUCK=115]="XTUCK",e[e.DEPTH=116]="DEPTH",e[e.DROP=117]="DROP",e[e.DUP=118]="DUP",e[e.NIP=119]="NIP",e[e.OVER=120]="OVER",e[e.PICK=121]="PICK",e[e.ROLL=122]="ROLL",e[e.ROT=123]="ROT",e[e.SWAP=124]="SWAP",e[e.TUCK=125]="TUCK",e[e.CAT=126]="CAT",e[e.SUBSTR=127]="SUBSTR",e[e.LEFT=128]="LEFT",e[e.RIGHT=129]="RIGHT",e[e.SIZE=130]="SIZE",e[e.INVERT=131]="INVERT",e[e.AND=132]="AND",e[e.OR=133]="OR",e[e.XOR=134]="XOR",e[e.EQUAL=135]="EQUAL",e[e.INC=139]="INC",e[e.DEC=140]="DEC",e[e.NEGATE=143]="NEGATE",e[e.ABS=144]="ABS",e[e.NOT=145]="NOT",e[e.NZ=146]="NZ",e[e.ADD=147]="ADD",e[e.SUB=148]="SUB",e[e.MUL=149]="MUL",e[e.DIV=150]="DIV",e[e.MOD=151]="MOD",e[e.SHL=152]="SHL",e[e.SHR=153]="SHR",e[e.BOOLAND=154]="BOOLAND",e[e.BOOLOR=155]="BOOLOR",e[e.NUMEQUAL=156]="NUMEQUAL",e[e.NUMNOTEQUAL=158]="NUMNOTEQUAL",e[e.LT=159]="LT",e[e.GT=160]="GT",e[e.LTE=161]="LTE",e[e.GTE=162]="GTE",e[e.MIN=163]="MIN",e[e.MAX=164]="MAX",e[e.WITHIN=165]="WITHIN",e[e.SHA1=167]="SHA1",e[e.SHA256=168]="SHA256",e[e.HASH160=169]="HASH160",e[e.HASH256=170]="HASH256",e[e.CHECKSIG=172]="CHECKSIG",e[e.CHECKMULTISIG=174]="CHECKMULTISIG",e[e.ARRAYSIZE=192]="ARRAYSIZE",e[e.PACK=193]="PACK",e[e.UNPACK=194]="UNPACK",e[e.PICKITEM=195]="PICKITEM",e[e.SETITEM=196]="SETITEM",e[e.NEWARRAY=197]="NEWARRAY",e[e.NEWSTRUCT=198]="NEWSTRUCT",e[e.NEWMAP=199]="NEWMAP",e[e.APPEND=200]="APPEND",e[e.REVERSE=201]="REVERSE",e[e.REMOVE=202]="REMOVE",e[e.HASKEY=203]="HASKEY",e[e.KEYS=204]="KEYS",e[e.VALUES=205]="VALUES",e[e.THROW=240]="THROW",e[e.THROWIFNOT=241]="THROWIFNOT"}(w||(w={}));var ae=w,ie=r(13),ue=r(15),oe=r(8),se=r(17),ce=r(32),le=r.n(ce),fe=r(33),he=r.n(fe),de=r(6),ve=r.n(de),ye=r(24);function pe(e){for(var t=[];e.length>=2;)t.push(parseInt(e.substring(0,2),16)),e=e.substring(2,e.length);return t}function me(e){for(var t="",r=new Uint8Array(e),n=0;n<r.byteLength;n++){var a=r[n].toString(16);t+=a=0===a.length?"00":1===a.length?"0"+a:a}return t}function ge(e){var t,r=void 0,n=void 0,a=void 0,i=void 0,u=void 0;r="";var o=new Uint8Array(e);for(t=o.length,n=0;n<t;)switch((a=o[n++])>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:r+=String.fromCharCode(a);break;case 12:case 13:i=o[n++],r+=String.fromCharCode((31&a)<<6|63&i);break;case 14:i=o[n++],u=o[n++],r+=String.fromCharCode((15&a)<<12|(63&i)<<6|(63&u)<<0)}return r}function we(e){for(var t=[],r=0;r<e.length;r++){var n=e.charCodeAt(r);n<128?t.push(n):n<2048?t.push(192|n>>6,128|63&n):n<55296||n>=57344?t.push(224|n>>12,128|n>>6&63,128|63&n):(r++,n=65536+((1023&n)<<10|1023&e.charCodeAt(r)),t.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n))}return Uint8Array.from(t)}function Ae(e){return me(we(e))}function Se(e){return ge(pe(e))}function ke(e){var t="";return t+=Te(e.length/2),t+=e}function xe(e){var t="",r=Ae(e);return t+=Te(r.length/2),t+=r}function be(e){return e?"01":"00"}function Re(e,t){if(e.length!==t.length)throw new Error("strings are disparate lengths");if(e.length%2!=0)throw new Error("strings must be hex");for(var r=new ArrayBuffer(e.length/2),n=new Uint8Array(r),a=0;a<e.length;a+=2)n[a/2]=parseInt(e.substr(a,2),16)^parseInt(t.substr(a,2),16);return me(r)}var Ee=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e<0)throw new RangeError("num must be >=0");if(t%1!=0)throw new Error("size must be a whole integer");if(!he()(e))throw new RangeError("num ("+e+") must be a safe integer");t*=2;var n=e.toString(16);return n=n.length%t==0?n:("0".repeat(t)+n).substring(n.length),r&&(n=Pe(n)),n},Te=function(e){return e<253?Ee(e):e<=65535?"fd"+Ee(e,2,!0):e<=4294967295?"fe"+Ee(e,4,!0):"ff"+Ee(e,8,!0)},Pe=function(e){if(e.length%2!=0)throw new Error("Incorrect Length: "+e);for(var t="",r=e.length-2;r>=0;r-=2)t+=e.substr(r,2);return t};function Ie(e){var t=Buffer.from(e,"hex"),r=le()(t.subarray(0));return r[r.length-1]>>7==1&&(r=r.concat(Array(8-r.length).fill(255))),se.fromBytesLE(r)}function Be(e){for(var t=e.toBytesLE(),r=e.neg().toBytesLE(),n=void 0,a=n=e.isNegative()?255:0,i=0,u=t.length-1;u>=0;u--)if(t[u]!==n){a=e.isNegative()?r[u]:t[u],i=u+1;break}return t=t.slice(0,i),a>>7==1&&t.push(e.isNegative()?255:0),new Buffer(t).toString("hex")}var Ce=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";if(S()(this,e),t.length%2!=0)throw new Error("Param's length is not even.");this.str=t,this.pos=0,this.size=this.str.length/2}return x()(e,[{key:"isEmpty",value:function(){return this.pos>=this.str.length}},{key:"read",value:function(e){if(this.isEmpty())throw new Error("StringReader reached the end.");var t=this.str.substr(this.pos,2*e);return this.pos+=2*e,t}},{key:"unreadBytes",value:function(e){if(this.pos-2*e<0)throw new Error("Can not unread too many bytes.");this.pos-=2*e}},{key:"readNullTerminated",value:function(){var e=this.str.indexOf("00",this.pos);if(-1===e)throw new Error("No ending NULL found");var t=this.str.substring(this.pos,e);return this.pos=e+2,t}},{key:"readNextByte",value:function(){return this.read(1)}},{key:"readNextBytes",value:function(){var e=this.readNextLen();return 0===e?"":this.read(e)}},{key:"readNextLen",value:function(){var e=parseInt(this.read(1),16);return 253===e?e=parseInt(Pe(this.read(2)),16):254===e?e=parseInt(Pe(this.read(4)),16):255===e&&(e=parseInt(Pe(this.read(8)),16)),e}},{key:"readVarUint",value:function(){return this.readNextLen()}},{key:"readUint8",value:function(){return parseInt(Pe(this.read(1)),16)}},{key:"readUint16",value:function(){return parseInt(Pe(this.read(2)),16)}},{key:"readUint32",value:function(){return parseInt(Pe(this.read(4)),16)}},{key:"readUint64",value:function(){return parseInt(Pe(this.read(8)),16)}},{key:"readUint128",value:function(){return parseInt(Pe(this.read(16)),16)}},{key:"readInt",value:function(){return parseInt(Pe(this.read(4)),16)}},{key:"readLong",value:function(){return parseInt(Pe(this.read(8)),16)}},{key:"readBoolean",value:function(){return 0!==parseInt(this.read(1),16)}},{key:"readH256",value:function(){return this.read(32)}}]),e}(),Ne=function(){function e(){S()(this,e),this.handlers={}}return x()(e,[{key:"on",value:function(e,t){void 0===this.handlers[e]&&(this.handlers[e]=[]),this.handlers[e].push(t)}},{key:"trigger",value:function(e,t){if(this.handlers[e]instanceof Array)for(var r=this.handlers[e],n=0,a=r.length;n<a;n++)r[n](t)}},{key:"off",value:function(e){delete this.handlers[e]}}]),e}(),De=function(e,t){window&&window.prompt&&window.prompt(D+"://"+t+"?params="+e)},Oe=function(e,t){return ve.a.post(e,t).then(function(e){return console.log("axios res:"+e),e}).catch(function(e){return console.log("axios res:"+T()(e)),e})};function He(){return Math.floor(Date.now()/1e3)}function _e(e){var t=ne.enc.Hex.parse(e);return ne.SHA256(t).toString()}function ze(e){var t=ne.enc.Hex.parse(e);return ne.RIPEMD160(t).toString()}function Ke(e){return ze(_e(e))}function Ue(e){return ye(e)}function Me(e){return me(Ue(e))}function Le(){var e=me(Ue(arguments.length>0&&void 0!==arguments[0]?arguments[0]:16));return P.entropyToMnemonic(e)}function Ve(e){return P.mnemonicToEntropy(e)}function Ge(e){if(!/^[1-9]\d*$/.test(e.toString()))throw g.INVALID_PARAMS}function We(e){return Buffer.from(e,"base64").toString("base64")===e}function Je(e){return/^[0-9a-fA-F]+$/.test(e)&&e.length%2==0}function Fe(){var e=Date.UTC(2018,5,30,0,0,0);return Date.UTC(2020,6,7,0,0,0)-e}function qe(e,t,r){var n=0;if(t>=r)return 0;var a=Fe();if(t<a){var i=Math.floor(t/X),u=t%X;r>=a&&(r=a);for(var o=Math.floor(r/X),s=r%X;i<o;)n+=(X-u)*Q[i],i++,u=0;n+=(s-u)*Q[i]}return n*e}var je=function(){function e(t){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(S()(this,e),!new oe.BigNumber(t).isInteger())throw new Error(String(g.INVALID_PARAMS));this.value=t,this.ledgerCompatible=r}return x()(e,null,[{key:"fromHexstr",value:function(t){return new e(Ie(t).toString())}}]),x()(e,[{key:"toHexstr",value:function(){var e=Be(se.fromValue(this.value));return this.ledgerCompatible&&(e.length%2!=0||e.length<16)&&(e+="0".repeat(16-e.length)),e}}]),e}(),Ye=function(){function e(t,r,n){S()(this,e),this.label=t,this.hex=r,this.labelJWS=n,e.values.push(this)}return x()(e,null,[{key:"fromHex",value:function(t){var r=e.values.find(function(e){return e.hex===t});if(void 0===r)throw new Error("Enum value not found");return r}},{key:"fromLabel",value:function(t){var r=e.values.find(function(e){return e.label===t});if(void 0===r)throw new Error("Enum value not found");return r}},{key:"fromLabelJWS",value:function(t){var r=e.values.find(function(e){return e.labelJWS===t||t.indexOf(e.labelJWS)>-1});if(void 0===r)throw new Error("Enum value not found");return r}}]),e}();Ye.values=[],Ye.ECDSAwithSHA224=new Ye("SHA224withECDSA",0,"ES224"),Ye.ECDSAwithSHA256=new Ye("SHA256withECDSA",1,"ES256"),Ye.ECDSAwithSHA384=new Ye("SHA384withECDSA",2,"ES384"),Ye.ECDSAwithSHA512=new Ye("SHA512withECDSA",3,"ES512"),Ye.ECDSAwithSHA3_224=new Ye("SHA3-224withECDSA",4,"ES3-224"),Ye.ECDSAwithSHA3_256=new Ye("SHA3-256withECDSA",5,"ES3-256"),Ye.ECDSAwithSHA3_384=new Ye("SHA3-384withECDSA",6,"ES3-384"),Ye.ECDSAwithSHA3_512=new Ye("SHA3-512withECDSA",7,"ES3-512"),Ye.ECDSAwithRIPEMD160=new Ye("RIPEMD160withECDSA",8,"ER160"),Ye.SM2withSM3=new Ye("SM3withSM2",9,"SM"),Ye.EDDSAwithSHA512=new Ye("SHA512withEdDSA",10,"EDS512");var Qe=function(){function e(t,r,n){S()(this,e),this.label=t,this.hex=r,this.defaultSchema=n,e.values.push(this)}return x()(e,null,[{key:"fromHex",value:function(t){var r=e.values.find(function(e){return e.hex===t});if(void 0===r)throw new Error("Enum value not found");return r}},{key:"fromLabel",value:function(t){var r=e.values.find(function(e){return e.label===t});if(void 0===r)throw new Error("Enum value not found");return r}}]),e}();Qe.values=[],Qe.ECDSA=new Qe("ECDSA",18,Ye.ECDSAwithSHA256),Qe.SM2=new Qe("SM2",19,Ye.SM2withSM3),Qe.EDDSA=new Qe("EDDSA",20,Ye.EDDSAwithSHA512);var Xe=r(9),Ze=r.n(Xe),$e=r(10),et=r.n($e),tt=r(11),rt=r.n(tt),nt=function(){function e(t,r,n){S()(this,e),this.label=t,this.hex=r,this.preset=n,e.values.push(this)}return x()(e,null,[{key:"fromHex",value:function(t){var r=e.values.find(function(e){return e.hex===t});if(void 0===r)throw new Error("Enum value not found");return r}},{key:"fromLabel",value:function(t){var r=e.values.find(function(e){return e.label===t});if(void 0===r)throw new Error("Enum value not found");return r}}]),e}();nt.values=[],nt.SECP224R1=new nt("P-224",1,"p224"),nt.SECP256R1=new nt("P-256",2,"p256"),nt.SECP384R1=new nt("P-384",3,"p384"),nt.SECP521R1=new nt("P-521",4,"p521"),nt.SM2P256V1=new nt("sm2p256v1",20,"sm2p256v1"),nt.ED25519=new nt("ed25519",25,"ed25519");var at=r(23),it=function(){function e(t){S()(this,e),this.curve=t}return x()(e,null,[{key:"deserializeJson",value:function(t){return new e(nt.fromLabel(t.curve))}}]),x()(e,[{key:"serializeJson",value:function(){return{curve:this.curve.label}}}]),e}(),ut=function(){function e(t,r,n){S()(this,e),this.key=t,void 0===r&&(r=Qe.fromLabel(O.algorithm)),void 0===n&&(n=it.deserializeJson(O.parameters)),this.algorithm=r,this.parameters=n}return x()(e,[{key:"computeHash",value:function(e,t){switch(t){case Ye.ECDSAwithSHA224:return ne.SHA224(ne.enc.Hex.parse(e)).toString();case Ye.ECDSAwithSHA256:return ne.SHA256(ne.enc.Hex.parse(e)).toString();case Ye.ECDSAwithSHA384:return ne.SHA384(ne.enc.Hex.parse(e)).toString();case Ye.ECDSAwithSHA512:case Ye.EDDSAwithSHA512:return ne.SHA512(ne.enc.Hex.parse(e)).toString();case Ye.ECDSAwithSHA3_224:return Object(at.sha3_224)(pe(e));case Ye.ECDSAwithSHA3_256:return Object(at.sha3_256)(pe(e));case Ye.ECDSAwithSHA3_384:return Object(at.sha3_384)(pe(e));case Ye.ECDSAwithSHA3_512:return Object(at.sha3_512)(pe(e));case Ye.ECDSAwithRIPEMD160:return ne.RIPEMD160(ne.enc.Hex.parse(e)).toString();case Ye.SM2withSM3:return(new ue.sm3).sum(pe(e),"hex");default:throw new Error("Unsupported hash algorithm.")}}},{key:"isSchemaSupported",value:function(e){switch(e){case Ye.ECDSAwithSHA224:case Ye.ECDSAwithSHA256:case Ye.ECDSAwithSHA384:case Ye.ECDSAwithSHA512:case Ye.ECDSAwithSHA3_224:case Ye.ECDSAwithSHA3_256:case Ye.ECDSAwithSHA3_384:case Ye.ECDSAwithSHA3_512:case Ye.ECDSAwithRIPEMD160:return this.algorithm===Qe.ECDSA;case Ye.EDDSAwithSHA512:return this.algorithm===Qe.EDDSA;case Ye.SM2withSM3:return this.algorithm===Qe.SM2;default:throw new Error("Unsupported signature schema.")}}},{key:"serializeJson",value:function(){return{algorithm:this.algorithm.label,parameters:this.parameters.serializeJson(),key:this.key}}}]),e}(),ot=function(e){function t(){return S()(this,t),et()(this,(t.__proto__||Ze()(t)).apply(this,arguments))}return rt()(t,e),x()(t,[{key:"verify",value:function(e,t){if(!this.isSchemaSupported(t.algorithm))throw new Error("Signature schema does not match key type.");"string"!=typeof e&&(e=e.getSignContent());var r=void 0;return r=t.algorithm===Ye.SM2withSM3?e:this.computeHash(e,t.algorithm),this.verifySignature(r,t.value,t.algorithm)}},{key:"serializeHex",value:function(){var e="";switch(this.algorithm){case Qe.ECDSA:e+=this.key;break;case Qe.EDDSA:case Qe.SM2:e+=Ee(this.algorithm.hex),e+=Ee(this.parameters.curve.hex),e+=this.key}return e}},{key:"verifySignature",value:function(e,t,r){switch(r){case Ye.ECDSAwithSHA224:case Ye.ECDSAwithSHA256:case Ye.ECDSAwithSHA384:case Ye.ECDSAwithSHA512:case Ye.ECDSAwithSHA3_224:case Ye.ECDSAwithSHA3_256:case Ye.ECDSAwithSHA3_384:case Ye.ECDSAwithSHA3_512:case Ye.ECDSAwithRIPEMD160:return this.verifyEcDSASignature(e,t);case Ye.EDDSAwithSHA512:return this.verifyEdDSASignature(e,t);case Ye.SM2withSM3:return this.verifySM2Signature(e,t);default:throw new Error("Unsupported signature schema.")}}},{key:"verifyEcDSASignature",value:function(e,t){var r=t.substr(0,64),n=t.substr(64,64);return new ie.ec(this.parameters.curve.preset).verify(e,{r:r,s:n},this.key,"hex")}},{key:"verifyEdDSASignature",value:function(e,t){var r=t.substr(0,64),n=t.substr(64,64);return new ie.eddsa(this.parameters.curve.preset).verify(e,{r:r,s:n},this.key,"hex")}},{key:"verifySM2Signature",value:function(e,t){var r=new Ce(t),n=Se(r.readNullTerminated());if(n!==H&&""!==n)throw new Error("Unsupported SM2 id used.");var a=r.read(32),i=r.read(32);return ue.sm2.SM2KeyPair(this.key).verify(pe(e),a,i)}}],[{key:"deserializeHex",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:33;if(33===r){var n=Qe.ECDSA,a=nt.SECP256R1;return new t(e.read(33),n,new it(a))}var i=parseInt(e.read(1),16),u=parseInt(e.read(1),16);return new t(e.read(r-2),Qe.fromHex(i),new it(nt.fromHex(u)))}}]),t}(ut),st=function(){function e(t){S()(this,e),this.label=t,e.values.push(this)}return x()(e,null,[{key:"fromHexLabel",value:function(t){var r=Se(t),n=e.values.find(function(e){return e.label===r});if(void 0===n)throw new Error("Enum value not found");return n}}]),e}();function ct(e,t){if(e.algorithm!==t.algorithm)return e.algorithm.hex-t.algorithm.hex;switch(e.algorithm){case Qe.ECDSA:var r=new ie.ec(e.parameters.curve.preset),n=r.keyFromPublic(e.key,"hex",!0),a=r.keyFromPublic(t.key,"hex",!0),i=n.getPublic(),u=a.getPublic();return i.getX()!==u.getX()?i.getX()-u.getX():i.getY()-u.getY();case Qe.SM2:var o=new ue.sm2.SM2KeyPair,s=new ue.sm2.SM2KeyPair;return o._pubFromString(e.key),s._pubFromString(t.key),o.getX().toString()!==s.getX().toString()?Number(o.getX().toString())-Number(s.getX().toString()):Number(o.getY().toString())-Number(s.getY().toString());case Qe.EDDSA:return Number(e.key)-Number(t.key);default:return 0}}function lt(e){return Ee(e)}function ft(e){return-1===e?Ee(ae.PUSHM1):0===e?Ee(ae.PUSH0):e>0&&e<=16?Ee(ae.PUSH1-1+e):Ee(e,8,!0)}function ht(e){return 0===e?lt(ae.PUSH0):e<=16?Ee(e-1+ae.PUSH1):dt(new je(e.toString()).toHexstr())}function dt(e){var t="";if(0===e.length)throw new Error("pushBytes error, hexstr is empty.");var r=e.length/2;if(r<=ae.PUSHBYTES75+1-ae.PUSHBYTES1)t+=Ee(r+ae.PUSHBYTES1-1);else if(r<256)t+=Ee(ae.PUSHDATA1),t+=Ee(r);else if(r<65536)t+=Ee(ae.PUSHDATA2),t+=Ee(r,2,!0);else{if(!(r<4294967296))throw g.INVALID_PARAMS;t+=Ee(ae.PUSHDATA4),t+=Ee(r,4,!0)}return t+=e}function vt(e){var t="";return t+=function(e){return dt(e.serializeHex())}(e),t+=lt(ae.CHECKSIG)}function yt(e,t){var r=e.length;if(!(1<=t&&t<=r&&r<=1024))throw new Error("Wrong multi-sig param");e.sort(ct);var n="";n+=ht(t);var a=!0,i=!1,u=void 0;try{for(var o,s=te()(e);!(a=(o=s.next()).done);a=!0){n+=dt(o.value.serializeHex())}}catch(e){i=!0,u=e}finally{try{!a&&s.return&&s.return()}finally{if(i)throw u}}return n+=ht(r),n+=lt(ae.CHECKMULTISIG)}function pt(e){var t="";e.sort();var r=!0,n=!1,a=void 0;try{for(var i,u=te()(e);!(r=(i=u.next()).done);r=!0){t+=dt(i.value)}}catch(e){n=!0,a=e}finally{try{!r&&u.return&&u.return()}finally{if(n)throw a}}return t}function mt(e){return parseInt(e.read(1),16)}function gt(e){var t=mt(e),r=void 0;if(t===ae.PUSHDATA4)r=e.readUint32();else if(t===ae.PUSHDATA2)r=e.readUint16();else if(t===ae.PUSHDATA1)r=e.readUint8();else{if(!(t<=ae.PUSHBYTES75&&t>=ae.PUSHBYTES1))throw new Error("unexpected opcode: "+t);r=t-ae.PUSHBYTES1+1}return e.read(r)}function wt(e){var t=e.readNextBytes();return ot.deserializeHex(new Ce(t))}st.values=[],st.IN_USE=new st("in use"),st.REVOKED=new st("revoked");var At=function e(){S()(this,e)};var St=function(e){var t="",r=e.length/2;return r<=ae.PUSHBYTES75?t+=Ee(r):r<256?(t+=Ee(ae.PUSHDATA1),t+=Ee(r)):r<65536?(t+=Ee(ae.PUSHDATA2),t+=Ee(r,2,!0)):(t+=Ee(ae.PUSHDATA4),t+=Ee(r,4,!0)),t+=e},kt=function(){function e(t){if(S()(this,e),40!==t.length&&34!==t.length)throw g.INVALID_PARAMS;this.value=t}return x()(e,null,[{key:"deserialize",value:function(t){return new e(t.read(20))}},{key:"fromPubKey",value:function(t){return new e(Ke(vt(t)))}},{key:"fromOntid",value:function(t){return new e(t.substr(8))}},{key:"fromVmCode",value:function(t){return new e(Ke(t))}},{key:"fromMultiPubKeys",value:function(t,r){var n=r.length;if(t<=0||t>n||n>24)throw g.INVALID_PARAMS;r.sort(ct);var a="";a+=ft(t);var i=!0,u=!1,o=void 0;try{for(var s,c=te()(r);!(i=(s=c.next()).done);i=!0){var l=s.value;a+=St(l.serializeHex())}}catch(e){u=!0,o=e}finally{try{!i&&c.return&&c.return()}finally{if(u)throw o}}return a+=ft(n),new e(Ke(a+=Ee(ae.CHECKMULTISIG)))}},{key:"generateOntid",value:function(t){return"did:ont:"+e.fromPubKey(t).toBase58()}}]),x()(e,[{key:"toBase58",value:function(){return 34===this.value.length?this.value:xt(this.value)}},{key:"toHexString",value:function(){var e=void 0;return e=40===this.value.length?this.value:bt(this.value),Pe(e)}},{key:"serialize",value:function(){return 40===this.value.length?this.value:bt(this.value)}},{key:"getB58Checksum",value:function(){var e=this.toBase58();return _e(ne.SHA256(e).toString()).slice(0,8)}}]),e}();function xt(e){var t=I+e,r=t+_e(_e(t)).slice(0,8);return re.encode(new Buffer(r,"hex"))}function bt(e){var t=me(re.decode(e)).substr(2,40);if(e!==xt(t))throw new Error("[addressToU160] decode encoded verify failed");return t}var Rt=r(3),Et=r.n(Rt),Tt=r(5),Pt=r.n(Tt),It=r(30),Bt=r(18),Ct=r(34);function Nt(e,t,r){var n=[];return Ct(e.normalize("NFC"),pe(t),{N:r.cost,r:r.blockSize,p:r.parallel,dkLen:r.size},function(e){n=e}),new Buffer(n)}function Dt(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:B,a=ot.deserializeHex(new Ce(t)),i=Nt(r,kt.fromPubKey(a).getB58Checksum(),n).toString("hex"),u=i.slice(0,32),o=i.slice(64),s=ne.enc.Hex.parse(u),c=ne.AES.encrypt(ne.enc.Hex.parse(e),ne.enc.Hex.parse(o),{mode:ne.mode.CTR,padding:ne.pad.NoPadding,iv:s}).ciphertext.toString();return new Buffer(c,"hex").toString("base64")}function Ot(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:B,a=Buffer.from(e,"base64").toString("hex"),i="";if("string"==typeof r&&8===r.length)i=r;else{if(!(r instanceof kt))throw g.INVALID_PARAMS;i=r.getB58Checksum()}var u=Nt(t,i,n).toString("hex"),o=u.slice(0,32),s=u.slice(64),c=ne.enc.Hex.parse(o),l={ciphertext:ne.enc.Hex.parse(a),salt:"",iv:""};return ne.AES.decrypt(l,ne.enc.Hex.parse(s),{mode:ne.mode.CTR,padding:ne.pad.NoPadding,iv:c}).toString()}function Ht(e,t){var r="";if("string"==typeof e&&8===e.length)r=e;else{if(!(e instanceof kt))throw g.INVALID_PARAMS;r=e.getB58Checksum()}var n=ot.deserializeHex(new Ce(t));if(kt.fromPubKey(n).getB58Checksum()!==r)throw console.log("keyphrase error."),g.Decrypto_ERROR}function _t(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:B,a=ot.deserializeHex(new Ce(t)),i=kt.fromPubKey(a).getB58Checksum(),u=Nt(r,i,n).toString("hex"),o=u.slice(0,64),s=u.slice(64),c=Re(e,o),l=ne.AES.encrypt(ne.enc.Hex.parse(c),ne.enc.Hex.parse(s),{mode:ne.mode.ECB,padding:ne.pad.NoPadding}),f=C+N+i+l.ciphertext.toString();return re.encode(Buffer.from(f,"hex"))}function zt(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:B,n=me(re.decode(e)),a=n.substr(6,8),i=n.substr(-64),u=Nt(t,a,r).toString("hex"),o=u.slice(0,64),s=u.slice(64),c={ciphertext:ne.enc.Hex.parse(i),salt:"",iv:""};return Re(ne.AES.decrypt(c,ne.enc.Hex.parse(s),{mode:ne.mode.ECB,padding:ne.pad.NoPadding}).toString(),o)}function Kt(e,t,r){var n=me(re.decode(e)).substr(6,8),a=ot.deserializeHex(new Ce(r));if(kt.fromPubKey(a).getB58Checksum()!==n)throw console.log("keyphrase error."),g.Decrypto_ERROR}function Ut(e,t,r,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:B;if(!Je(e))throw new Error(g.INVALID_PARAMS+", Invalid private key");var i=Nt(n,r,a),u=i.slice(0,12),o=i.slice(32),s=u,c=new Buffer(t.toBase58()),l=Object(Bt.createCipheriv)("aes-256-gcm",o,s);l.setAAD(c);var f=Buffer.from(e,"hex"),h=l.update(f),d=l.final(),v=l.getAuthTag();return h=Buffer.concat([h,d]),Buffer.concat([h,v]).toString("base64")}function Mt(e,t,r,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:B;if(32!==r.length)throw g.INVALID_PARAMS;var i=Buffer.from(e,"base64"),u=i.slice(0,i.length-16),o=i.slice(i.length-16),s=Nt(n,r,a),c=s.slice(0,12),l=s.slice(32),f=c,h=new Buffer(t.toBase58()),d=Object(Bt.createDecipheriv)("aes-256-gcm",l,f);d.setAAD(h),d.setAuthTag(o);var v=d.update(u).toString("hex");try{v+=d.final().toString("hex")}catch(e){throw g.Decrypto_ERROR}return v}var Lt=r(16),Vt=function(){function e(t,r,n){S()(this,e),this.algorithm=t,this.value=r,this.publicKeyId=n}return x()(e,null,[{key:"deserializeJWT",value:function(t,r,n){var a=Lt.decode(t,"hex");return a.startsWith("01")&&(a=a.substring(2)),new e(r,a,n)}},{key:"deserializePgp",value:function(t){var r=new Buffer(t.Value,"base64").toString("hex"),n=e.deserializeHex(r).value;return new e(Ye.fromLabel(t.Algorithm),n)}},{key:"deserializeHex",value:function(t){if(t.length<4)throw new Error("Invalid params.");var r=new Ce(t),n=parseInt(r.read(1),16);return new e(Ye.fromHex(n),t.substr(2))}}]),x()(e,[{key:"serializeHex",value:function(){var e="";return e+=Ee(this.algorithm.hex),e+=this.value}},{key:"serializePgp",value:function(e){return{PublicKeyId:e,Format:"pgp",Value:new Buffer(this.serializeHex(),"hex").toString("base64"),Algorithm:this.algorithm.label}}},{key:"serializeJWT",value:function(){return new Buffer(this.serializeHex(),"hex").toString("base64")}}]),e}(),Gt=r(29),Wt=function(e){function t(){return S()(this,t),et()(this,(t.__proto__||Ze()(t)).apply(this,arguments))}return rt()(t,e),x()(t,[{key:"sign",value:function(e,t,r){if(void 0===t&&(t=this.algorithm.defaultSchema),!this.isSchemaSupported(t))throw new Error("Signature schema does not match key type.");"string"!=typeof e&&(e=e.getSignContent());var n=void 0;n=t===Ye.SM2withSM3?e:this.computeHash(e,t);var a=this.computeSignature(n,t);return new Vt(t,a,r)}},{key:"signAsync",value:function(){var e=Pt()(Et.a.mark(function e(t,r,n){return Et.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.sign(t,r,n));case 1:case"end":return e.stop()}},e,this)}));return function(t,r,n){return e.apply(this,arguments)}}()},{key:"getPublicKey",value:function(){switch(this.algorithm){case Qe.ECDSA:return this.getEcDSAPublicKey();case Qe.EDDSA:return this.getEdDSAPublicKey();case Qe.SM2:return this.getSM2PublicKey();default:throw new Error("Unsupported signature schema.")}}},{key:"decrypt",value:function(e,r,n,a){24===n.length&&We(n)&&(n=Buffer.from(n,"base64").toString("hex"));var i=new t(Mt(this.key,r,n,e,a),this.algorithm,this.parameters),u=i.getPublicKey();if(kt.fromPubKey(u).toBase58()!==r.toBase58())throw g.Decrypto_ERROR;return i}},{key:"encrypt",value:function(e,r,n,a){var i=this.getPublicKey();if(kt.fromPubKey(i).toBase58()!==r.toBase58())throw g.INVALID_ADDR;return new t(Ut(this.key,r,n,e,a),this.algorithm,this.parameters)}},{key:"getEcDSAPublicKey",value:function(){var e=new ie.ec(this.parameters.curve.preset).keyFromPrivate(this.key,"hex").getPublic(!0,"hex");return new ot(e,this.algorithm,this.parameters)}},{key:"getEdDSAPublicKey",value:function(){var e=new ie.eddsa(this.parameters.curve.preset).keyFromSecret(this.key,"hex").getPublic(!0,"hex");return new ot(e,this.algorithm,this.parameters)}},{key:"getSM2PublicKey",value:function(){var e=ue.sm2.SM2KeyPair(null,this.key).pubToString("compress");return new ot(e,this.algorithm,this.parameters)}},{key:"computeSignature",value:function(e,t){switch(t){case Ye.ECDSAwithSHA224:case Ye.ECDSAwithSHA256:case Ye.ECDSAwithSHA384:case Ye.ECDSAwithSHA512:case Ye.ECDSAwithSHA3_224:case Ye.ECDSAwithSHA3_256:case Ye.ECDSAwithSHA3_384:case Ye.ECDSAwithSHA3_512:case Ye.ECDSAwithRIPEMD160:return this.computeEcDSASignature(e);case Ye.EDDSAwithSHA512:return this.computeEdDSASignature(e);case Ye.SM2withSM3:return this.computeSM2Signature(e);default:throw new Error("Unsupported signature schema.")}}},{key:"computeEcDSASignature",value:function(e){var t=new ie.ec(this.parameters.curve.preset).sign(e,this.key,{canonical:!0});return Buffer.concat([t.r.toArrayLike(Buffer,"be",32),t.s.toArrayLike(Buffer,"be",32)]).toString("hex")}},{key:"computeEdDSASignature",value:function(e){return new ie.eddsa(this.parameters.curve.preset).sign(e,this.key).toHex().toLowerCase()}},{key:"computeSM2Signature",value:function(e){var t=ue.sm2.SM2KeyPair(null,this.key).sign(pe(e));return Ae(H+"\0")+t.r+t.s}},{key:"serializeWIF",value:function(){return It.encode(128,Buffer.from(this.key,"hex"),!0)}}],[{key:"random",value:function(e,r){return void 0===e&&(e=Qe.fromLabel(O.algorithm)),void 0===r&&(r=it.deserializeJson(O.parameters)),new t(me(ye(32)),e,r)}},{key:"deserializeWIF",value:function(e){return new t(me(It.decode(e,128).privateKey))}},{key:"generateFromMnemonic",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Y;if(e.split(" ").length<12)throw g.INVALID_PARAMS;var n=P.mnemonicToSeedHex(e),a=Gt.fromMasterSeed(Buffer.from(n,"hex")).derive(r);return new t(Buffer.from(a.privateKey).toString("hex"))}}]),t}(ut),Jt=[],Ft=new(function(){function e(){S()(this,e)}return x()(e,[{key:"getType",value:function(){return""}},{key:"deserialize",value:function(e){if(null!=e.key)return new Wt(e.key,Qe.fromLabel(e.algorithm),it.deserializeJson(e.parameters));throw new Error("Unsupported Key type.")}}]),e}());function qt(e){Jt.push(e)}function jt(e){if(null==e.external)return Ft.deserialize(e);var t=!0,r=!1,n=void 0;try{for(var a,i=te()(Jt);!(t=(a=i.next()).done);t=!0){var u=a.value;if(u.getType()===e.external.type)return u.deserialize(e)}}catch(e){r=!0,n=e}finally{try{!t&&i.return&&i.return()}finally{if(r)throw n}}throw new Error("Unsupported Key type.")}var Yt,Qt,Xt=r(35),Zt=function(){function e(t){S()(this,e),this.param=new er(t),this.sk=new rr(this.param)}return x()(e,[{key:"GenerateSk",value:function(){return this.sk.Rand(),this.sk}},{key:"GenerateKeyPair",value:function(){this.sk=rr.GenerateSk(this.param),this.pk=this.sk.GenerateIssuerPublicKey()}},{key:"SetAttributeSet",value:function(e){this.AttributeName=e,this.pk.GenerateAttr(e)}},{key:"Sign",value:function(e,t){var r=this.param.getRandBN(),n=this.param.getRandBN(),a=new this.param.ECP;a.copy(this.param.g1),a.add(this.param.PAIR.G1mul(this.pk.h0,n)),a.add(e);for(var i=0;i<this.pk.attr.length;i++)a.add(this.param.PAIR.G1mul(this.pk.h[i],t[i]));var u=new this.param.ECP,o=new this.param.BIG;o.copy(r),o.add(this.sk.value),o.invmodp(this.param.order),u=this.param.PAIR.G1mul(a,o);var s=new ar(this.param);return s.Set(u,a,r,n,t),s}},{key:"GetPk",value:function(){return nr.COPY(this.pk)}},{key:"GenerateNonce",value:function(){return this.param.getRandBN()}},{key:"VerifyCredentialRequest",value:function(e){return this.pk.VerifyCredentialRequest(e)}}]),e}(),$t=function(){function e(t){S()(this,e),this.param=new er(t)}return x()(e,[{key:"GenerateSk",value:function(){return this.sk=rr.GenerateSk(this.param),this.sk}},{key:"SetIpk",value:function(e){this.ipk=nr.COPY(e)}},{key:"GenerateCrendentialRequest",value:function(e){if(void 0!==this.ipk){var t=this.ipk,r=this.param.PAIR.G1mul(t.h_sk,this.sk.value),n=this.param.getRandBN(),a=this.param.PAIR.G1mul(t.h_sk,n),i=this.param.hashToBN(a,t.h_sk,r,e),u=this.param.BIG.modmul(i,this.sk.value,this.param.order);u.add(n),u.mod(this.param.order);var o={C:i,S:u},s=this.param.genAttrBN(t.attr);return this.Nym=r,this.attrs=s,{Nym:r,pi:o,nonce:e,attrs:s}}console.log("Please set ipk first.")}},{key:"VerifyBBSplus",value:function(e){var t=new this.param.ECP2;t.copy(this.ipk.w),t.add(this.param.PAIR.G2mul(this.param.g2,e.sig.e)),t.affine();var r=new this.param.ECP;r.copy(e.sig.A),r.affine();var n=this.param.PAIR.ate(t,r);n=this.param.PAIR.fexp(n);var a=new this.param.ECP;a.copy(this.param.g1),a.add(this.param.PAIR.G1mul(this.ipk.h0,e.sig.s)),a.add(this.Nym);for(var i=0;i<e.attrs.length;i++)a.add(this.param.PAIR.G1mul(this.ipk.h[i],e.attrs[i]));a.affine();var u=this.param.PAIR.ate(this.param.g2,a);return u=this.param.PAIR.fexp(u),n.equals(u)}},{key:"SetCredential",value:function(e){return this.Cred=new ar(this.param),this.Cred.Copy(e),!0}},{key:"Prove",value:function(e){var t=this.ipk,r=this.Cred,n=this.param.getRandBN(),a=this.param.PAIR.G1mul(r.sig.A,n),i=new this.param.BIG(0);i.copy(n),i.invmodp(this.param.order);var u=new this.param.BIG(0);u.copy(r.sig.e),u=this.param.BIG.modneg(u,this.param.order);var o=this.param.PAIR.G1mul(a,u);o.add(this.param.PAIR.G1mul(r.sig.B,n));var s=this.param.getRandBN(),c=new this.param.BIG(0);c.copy(s),c=this.param.BIG.modneg(c,this.param.order);var l=this.param.PAIR.G1mul(r.sig.B,n);l.add(this.param.PAIR.G1mul(t.h0,c));var f=this.param.BIG.modmul(s,i,this.param.order);(f=this.param.BIG.modneg(f,this.param.order)).add(r.sig.s),f.mod(this.param.order);for(var h=[],d=0;d<e.length;d++)0===e[d]?h[d]=this.param.getRandBN():h[d]=!1;var v=this.param.getRandBN(),y=this.param.getRandBN(),p=this.param.getRandBN(),m=this.param.getRandBN(),g=this.param.getRandBN(),w=this.param.PAIR.G1mul(t.h_sk,g),A=this.param.PAIR.G1mul(a,v);A.add(this.param.PAIR.G1mul(t.h0,y));var S=this.param.PAIR.G1mul(l,p);S.add(this.param.PAIR.G1mul(t.h0,m)),S.add(this.param.PAIR.G1mul(w,new this.param.BIG(-1)));for(var k=0;k<h.length;k++)!1!==h[k]&&S.add(this.param.PAIR.G1mul(t.h[k],h[k]));var x=this.param.hashToBN(a,o,l,this.Nym,A,S,this.param.g1,t.h0,t.h,t.w),b=this.param.getRandBN(),R=this.param.hashToBN(b,x,e,this.attrs),E=new this.param.BIG(0);E.copy(g),E.add(this.param.BIG.modmul(R,this.sk.value,this.param.order)),E.mod(this.param.order);for(var T=[],P=0;P<e.length;P++)0===e[P]?(T[P]=new this.param.BIG(0),T[P].copy(h[P]),T[P].sub(this.param.BIG.modmul(R,this.attrs[P],this.param.order)),T[P].mod(this.param.order)):T[P]=!1;var I=new this.param.BIG(0);I.copy(v),I.sub(this.param.BIG.modmul(R,r.sig.e,this.param.order)),I.mod(this.param.order);var B=new this.param.BIG(0);B.copy(y),B.add(this.param.BIG.modmul(R,s,this.param.order)),B.mod(this.param.order);var C=new this.param.BIG(0);C.copy(p),C.add(this.param.BIG.modmul(R,i,this.param.order)),C.mod(this.param.order);var N=new this.param.BIG(0);N.copy(m),N.sub(this.param.BIG.modmul(R,f,this.param.order)),N.mod(this.param.order);var D={c:R,s_sk:E,s_a:T,s_e:I,s_r2:B,s_r3:C,s_s_:N,nonce:b};return{A_:a,_A:o,B_:l,Nym:this.Nym,pi:D}}},{key:"Verify",value:function(e,t,r){var n=this.ipk,a=new this.param.ECP(0);if(e.A_.equals(a))return console.log("A' == O return true, verify failed."),!1;var i=new this.param.ECP;i.copy(e.A_);var u=new this.param.ECP2;u.copy(n.w);var o=new this.param.ECP;o.copy(e._A);var s=new this.param.ECP2;s