From dcfa85268ef271c23f9dbf1303c6deab4dc436d6 Mon Sep 17 00:00:00 2001 From: foamzou Date: Fri, 19 Aug 2022 19:36:50 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat(source):=20support=20=E5=85=A8?= =?UTF-8?q?=E6=B0=91k=E6=AD=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +- README_en.md | 5 ++- args/checkAndParse_test.go | 6 +-- args/option.go | 2 +- consts/source.go | 2 + processor/factory.go | 2 + processor/qmkg/qmkg.go | 86 +++++++++++++++++++++++++++++++++++++ processor/qmkg/qmkg_test.go | 49 +++++++++++++++++++++ 8 files changed, 150 insertions(+), 6 deletions(-) create mode 100644 processor/qmkg/qmkg.go create mode 100644 processor/qmkg/qmkg_test.go diff --git a/README.md b/README.md index aacb1a6..d2cbeea 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ Search Options: --searchArtist= 歌手名 --searchAlbum= 专辑名 --searchType= 暂时只支持: song, 默认: song - --sources= 在指定的网站中搜索,使用英文逗号隔开. 目前支持: bilibili,douyin,kugou,kuwo,migu,netease,qq,youtube. 默认在全部网站中搜索 + --sources= 在指定的网站中搜索,使用英文逗号隔开. 目前支持: bilibili,douyin,kugou,kuwo,migu,netease,qq,youtube,qmkg. 默认在全部网站中搜索 --excludeSource= 排除指定的网站,使用英文逗号隔开 Help Options: @@ -92,7 +92,9 @@ Site | Source Name | Audio | Video | Search [咪咕音乐](https://music.migu.cn/) |migu | ✅ | ⌛ | ✅ [酷狗](https://www.kugou.com/) |kugou | ✅ | ⌛ | ✅ [酷我](https://www.kuwo.cn/) | kuwo |✅ | ⌛ | ✅ +[全民K歌](https://kg.qq.com/) | qmkg |✅ | ⌛ | ⌛ ## 致谢 +- DouYin XB: https://www.jianshu.com/p/4db4f4d6a536 - Netease Encrypt Method: https://github.com/872409/music-get diff --git a/README_en.md b/README_en.md index 28f5016..439fcad 100644 --- a/README_en.md +++ b/README_en.md @@ -69,7 +69,7 @@ Search Options: --searchArtist= artist name --searchAlbum= album name --searchType= Support: song, Default: song - --sources= Search in the specific source, separate with comma. Support: bilibili,douyin,kugou,kuwo,migu,netease,qq,youtube. Default search in all + --sources= Search in the specific source, separate with comma. Support: bilibili,douyin,kugou,kuwo,migu,netease,qq,youtube,qmkg. Default search in all --excludeSource= Search not in the specific source, separate with comma Help Options: @@ -93,6 +93,9 @@ Site | Source Name | Audio | Video | Search [migu music](https://music.migu.cn/) |migu | ✅ | ⌛ | ✅ [kugou](https://www.kugou.com/) |kugou | ✅ | ⌛ | ✅ [kuwo](https://www.kuwo.cn/) | kuwo |✅ | ⌛ | ✅ +[qmkg](https://kg.qq.com/) | qmkg |✅ | ⌛ | ⌛ + ## Thanks +- DouYin XB: https://www.jianshu.com/p/4db4f4d6a536 - Netease Encrypt Method: https://github.com/872409/music-get \ No newline at end of file diff --git a/args/checkAndParse_test.go b/args/checkAndParse_test.go index 1e138fd..e6078d0 100644 --- a/args/checkAndParse_test.go +++ b/args/checkAndParse_test.go @@ -39,7 +39,7 @@ func Test_parseSearchSource(t *testing.T) { name: "all field not specified, should use default: all", args: args{opt: &Options{Search: Search{Sources: "", ExcludeSources: ""}}}, wantSources: []string{ - "bilibili", "douyin", "kugou", "kuwo", "migu", "netease", "qq", "youtube", + "bilibili", "douyin", "kugou", "kuwo", "migu", "netease", "qq", "youtube", "qmkg", }, }, { @@ -67,14 +67,14 @@ func Test_parseSearchSource(t *testing.T) { name: "excludeSources specified but not sources", args: args{opt: &Options{Search: Search{Sources: "", ExcludeSources: "kuwo,qq"}}}, wantSources: []string{ - "bilibili", "douyin", "kugou", "migu", "netease", "youtube", + "bilibili", "douyin", "kugou", "migu", "netease", "youtube", "qmkg", }, }, { name: "excludeSources with space specified but not sources", args: args{opt: &Options{Search: Search{Sources: "", ExcludeSources: "kuwo , qq"}}}, wantSources: []string{ - "bilibili", "douyin", "kugou", "migu", "netease", "youtube", + "bilibili", "douyin", "kugou", "migu", "netease", "youtube", "qmkg", }, }, { diff --git a/args/option.go b/args/option.go index 38f7596..4916d8a 100644 --- a/args/option.go +++ b/args/option.go @@ -21,7 +21,7 @@ type Search struct { Artist string `long:"searchArtist" description:"artist name" required:"false"` Album string `long:"searchAlbum" description:"album name" required:"false"` Type string `long:"searchType" description:"Support: song, Default: song" required:"false"` - Sources string `long:"sources" description:"Search in the specific source, separate with comma. Support: bilibili,douyin,kugou,kuwo,migu,netease,qq,youtube. Default: All" required:"false"` + Sources string `long:"sources" description:"Search in the specific source, separate with comma. Support: bilibili,douyin,kugou,kuwo,migu,netease,qq,youtube,qmkg. Default: All" required:"false"` ExcludeSources string `long:"excludeSource" description:"Search not in the specific source, separate with comma" required:"false"` SourcesWillBeSearch []string diff --git a/consts/source.go b/consts/source.go index ea10361..e2a0880 100644 --- a/consts/source.go +++ b/consts/source.go @@ -9,6 +9,7 @@ const ( SourceNameNetease = "netease" SourceNameQq = "qq" SourceNameYoutube = "youtube" + SourceNameQMKG = "qmkg" ) func GetAllSourceName() []string { @@ -21,5 +22,6 @@ func GetAllSourceName() []string { SourceNameNetease, SourceNameQq, SourceNameYoutube, + SourceNameQMKG, } } diff --git a/processor/factory.go b/processor/factory.go index 87e85c6..cdd65ff 100644 --- a/processor/factory.go +++ b/processor/factory.go @@ -11,6 +11,7 @@ import ( "github.com/foamzou/audio-get/processor/kuwo" "github.com/foamzou/audio-get/processor/migu" "github.com/foamzou/audio-get/processor/netease" + "github.com/foamzou/audio-get/processor/qmkg" "github.com/foamzou/audio-get/processor/qqmusic" "github.com/foamzou/audio-get/processor/youtube" ) @@ -59,6 +60,7 @@ func (p *Processor) getProcessorMap() map[string]meta.IProcessor { consts.SourceNameMigu: &migu.Core{Opts: p.Opts}, consts.SourceNameKugou: &kugou.Core{Opts: p.Opts}, consts.SourceNameKuwo: &kuwo.Core{Opts: p.Opts}, + consts.SourceNameQMKG: &qmkg.Core{Opts: p.Opts}, consts.SourceNameQq: &qqmusic.Core{Opts: p.Opts}, } diff --git a/processor/qmkg/qmkg.go b/processor/qmkg/qmkg.go new file mode 100644 index 0000000..f537652 --- /dev/null +++ b/processor/qmkg/qmkg.go @@ -0,0 +1,86 @@ +package qmkg + +import ( + "fmt" + "strings" + + "github.com/foamzou/audio-get/args" + "github.com/foamzou/audio-get/consts" + "github.com/foamzou/audio-get/meta" + "github.com/foamzou/audio-get/utils" +) + +type Core struct { + Opts *args.Options +} + +func (c *Core) SearchSong() (searchItems []*meta.SearchSongItem, err error) { + return +} + +func (c *Core) IsMusicPlatform() bool { + return false +} + +func (c *Core) Domains() []string { + return []string{ + "kg.qq.com", + "kg2.qq.com", + "kg3.qq.com", + "kg4.qq.com", + "kg5.qq.com", + "kg6.qq.com", + "kg7.qq.com", + "kg8.qq.com", + "kg9.qq.com", + } +} + +func (c *Core) GetSourceName() string { + return consts.SourceNameQMKG +} + +func (c *Core) FetchMetaAndResourceInfo() (mediaMeta *meta.MediaMeta, err error) { + + html, err := utils.HttpGet(c.Opts.Url, map[string]string{ + "user-agent": consts.UAAndroid, + "referer": c.Opts.Url, + }) + if err != nil { + return + } + + title, err := utils.RegexSingleMatch(html, "([\\s\\S]+?)") + if err != nil { + return + } + title = strings.TrimSpace(title) + artistName := strings.Split(title, "-")[0] + songName := strings.Split(strings.ReplaceAll(title, artistName+"-", ""), "-全民")[0] + duration := utils.RegexSingleMatchIntIgnoreError(html, "\"segment_end\":([\\d]+),", 0) + coverUrl := utils.RegexSingleMatchIgnoreError(html, "\"cover\":\"(.+?)\",", "") + playUrl, err := utils.RegexSingleMatch(html, "\"playurl\":\"(.+?)\",") + if err != nil { + return + } + if playUrl == "" { + err = fmt.Errorf("playUrl is empty") + return + } + + mediaMeta = &meta.MediaMeta{ + Title: songName, + Duration: duration / 1000, + Album: "全民K歌", + Artist: artistName, + Audios: []meta.Audio{{Url: playUrl}}, + CoverUrl: coverUrl, + ResourceType: consts.ResourceTypeAudio, + Headers: map[string]string{ + "user-agent": consts.UAAndroid, + "referer": c.Opts.Url, + }, + } + + return +} diff --git a/processor/qmkg/qmkg_test.go b/processor/qmkg/qmkg_test.go new file mode 100644 index 0000000..1887e7c --- /dev/null +++ b/processor/qmkg/qmkg_test.go @@ -0,0 +1,49 @@ +package qmkg + +import ( + "testing" + + "github.com/foamzou/audio-get/args" + "github.com/foamzou/audio-get/meta" + "github.com/foamzou/audio-get/test_helper" +) + +func TestCore_FetchMetaAndResourceInfo(t *testing.T) { + type fields struct { + Opts *args.Options + } + tests := []struct { + name string + fields fields + wantMediaMeta *meta.MediaMeta + wantErr bool + }{ + { + name: "test share url", + fields: fields{Opts: &args.Options{Url: "https://kg3.qq.com/node/a6MPpvAot8/play_v2?s=bcY2OWbCGDcTPbjz&shareuid=679f9582262e328e&topsource=a0_pn201001006_z11_u52873355_l1_t1660396943__&pageId=details_of_creations"}}, + wantMediaMeta: &meta.MediaMeta{ + Title: "我以为", + Duration: 308, + CoverUrl: "jpg", + Artist: "锋哥", + Album: "全民K歌", + Audios: []meta.Audio{{ + Url: ".m4a", + }}, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + c := &Core{ + Opts: tt.fields.Opts, + } + gotMediaMeta, err := c.FetchMetaAndResourceInfo() + if (err != nil) != tt.wantErr { + t.Errorf("FetchMetaAndResourceInfo() error = %v, wantErr %v", err, tt.wantErr) + return + } + test_helper.TestMediaMeta(t, gotMediaMeta, tt.wantMediaMeta) + }) + } +} From fe038046129995a802bc9c293aa0384c859ffc13 Mon Sep 17 00:00:00 2001 From: foamzou Date: Fri, 19 Aug 2022 19:38:22 +0800 Subject: [PATCH 2/4] fix(test): test case of some source --- processor/bilibili/search_test.go | 4 ++-- processor/kugou/kugou_test.go | 24 ++++++++++++------------ processor/kugou/search_test.go | 8 ++++---- processor/migu/migu_test.go | 10 +++++----- processor/qqmusic/qqmusic_test.go | 24 ++++++++++++------------ 5 files changed, 35 insertions(+), 35 deletions(-) diff --git a/processor/bilibili/search_test.go b/processor/bilibili/search_test.go index dedd211..5765de8 100644 --- a/processor/bilibili/search_test.go +++ b/processor/bilibili/search_test.go @@ -23,8 +23,8 @@ func TestCore_SearchSong(t *testing.T) { name: "Test search video", fields: fields{Opts: &args.Options{Search: args.Search{Keyword: "珊瑚海 周杰伦", Type: "song"}}}, wantSongItem: &meta.SearchSongItem{ - Name: "珊瑚海-周杰伦", - Artist: "cb林师傅", + Name: "【1080P修复】周杰伦 梁心颐 - 珊瑚海MV 修复版", + Artist: "zyl2012", Url: "bilibili", Source: consts.SourceNameBilibili, }, diff --git a/processor/kugou/kugou_test.go b/processor/kugou/kugou_test.go index 77bfe5c..4968149 100644 --- a/processor/kugou/kugou_test.go +++ b/processor/kugou/kugou_test.go @@ -20,25 +20,25 @@ func TestCore_FetchMetaAndResourceInfo(t *testing.T) { }{ { name: "Test song", - fields: fields{Opts: &args.Options{Url: "https://www.kugou.com/mixsong/456b2ae3.html"}}, + fields: fields{Opts: &args.Options{Url: "https://www.kugou.com/mixsong/w0g6d24.html"}}, wantMediaMeta: &meta.MediaMeta{ - Title: "雨下的瞬間", - Description: "李梦尹 - 雨下的瞬間", - Duration: 272, - Artist: "李梦尹", - Album: "雨下的瞬間", + Title: "南山忆", + Description: "许嵩 - 南山忆", + Duration: 199, + Artist: "许嵩", + Album: "许嵩早期单曲集", Audios: []meta.Audio{{Url: ".mp3"}}, }, }, { name: "Test song", - fields: fields{Opts: &args.Options{Url: "https://www.kugou.com/song/#hash=E5D69492BACF314B28519884B6D339BD&album_id=36463673"}}, + fields: fields{Opts: &args.Options{Url: "https://www.kugou.com/song/#hash=014E975909CB0DE854AC4ACA2B94F154&album_id=1968878"}}, wantMediaMeta: &meta.MediaMeta{ - Title: "雨下的瞬間", - Description: "李梦尹 - 雨下的瞬間", - Duration: 272, - Artist: "李梦尹", - Album: "雨下的瞬間", + Title: "南山忆", + Description: "许嵩 - 南山忆", + Duration: 199, + Artist: "许嵩", + Album: "许嵩早期单曲集", Audios: []meta.Audio{{Url: ".mp3"}}, }, }, diff --git a/processor/kugou/search_test.go b/processor/kugou/search_test.go index d13834e..3d3cab4 100644 --- a/processor/kugou/search_test.go +++ b/processor/kugou/search_test.go @@ -21,11 +21,11 @@ func TestCore_SearchSong(t *testing.T) { }{ { name: "Test search song", - fields: fields{Opts: &args.Options{Search: args.Search{Keyword: "雨下的瞬間 李梦尹", Type: "song"}}}, + fields: fields{Opts: &args.Options{Search: args.Search{Keyword: "灰色头像 许嵩", Type: "song"}}}, wantSongItem: &meta.SearchSongItem{ - Name: "雨下的瞬間", - Artist: "李梦尹", - Album: "雨下的瞬間", + Name: "灰色头像", + Artist: "许嵩", + Album: "寻雾启示", Url: "kugou.com", Source: consts.SourceNameKugou, }, diff --git a/processor/migu/migu_test.go b/processor/migu/migu_test.go index 3d32336..9611cc2 100644 --- a/processor/migu/migu_test.go +++ b/processor/migu/migu_test.go @@ -20,13 +20,13 @@ func TestCore_FetchMetaAndResourceInfo(t *testing.T) { }{ { name: "Test song", - fields: fields{Opts: &args.Options{Url: "https://music.migu.cn/v3/music/song/60054701938"}}, + fields: fields{Opts: &args.Options{Url: "https://music.migu.cn/v3/music/song/60054701952"}}, wantMediaMeta: &meta.MediaMeta{ - Title: "搁浅", - Description: "搁浅", - Duration: 240, + Title: "枫", + Description: "枫", + Duration: 277, Artist: "周杰伦", - Album: "七里香", + Album: "十一月的萧邦", Audios: []meta.Audio{{Url: ".mp3"}}, }, }, diff --git a/processor/qqmusic/qqmusic_test.go b/processor/qqmusic/qqmusic_test.go index 892c827..f3a82b5 100644 --- a/processor/qqmusic/qqmusic_test.go +++ b/processor/qqmusic/qqmusic_test.go @@ -20,25 +20,25 @@ func TestCore_FetchMetaAndResourceInfo(t *testing.T) { }{ { name: "Test on PC", - fields: fields{Opts: &args.Options{Url: "https://y.qq.com/n/ryqq/songDetail/003OIguR4bcxAf"}}, + fields: fields{Opts: &args.Options{Url: "https://y.qq.com/n/ryqq/songDetail/000Afq8O0JRzXv"}}, wantMediaMeta: &meta.MediaMeta{ - Title: "失物招领", - Description: "《以年为单位的恋爱》电影情感主题曲", - Duration: 246, - Artist: "蔡健雅", - Album: "失物招领", + Title: "南山忆", + Description: "《剑仙》网游主题曲", + Duration: 201, + Artist: "许嵩", + Album: "许嵩早期单曲集", Audios: []meta.Audio{{Url: ".m4a"}}, }, }, { name: "Test on mobile", - fields: fields{Opts: &args.Options{Url: "https://i.y.qq.com/v8/playsong.html?ADTAG=ryqq.songDetail&songmid=003OIguR4bcxAf&songid=0&songtype=0#webchat_redirect"}}, + fields: fields{Opts: &args.Options{Url: "https://i.y.qq.com/v8/playsong.html?ADTAG=ryqq.songDetail&songmid=000Afq8O0JRzXv&songid=0&songtype=0#webchat_redirect"}}, wantMediaMeta: &meta.MediaMeta{ - Title: "失物招领", - Description: "《以年为单位的恋爱》电影情感主题曲", - Duration: 246, - Artist: "蔡健雅", - Album: "失物招领", + Title: "南山忆", + Description: "《剑仙》网游主题曲", + Duration: 201, + Artist: "许嵩", + Album: "许嵩早期单曲集", Audios: []meta.Audio{{Url: ".m4a"}}, }, }, From 1c6323d5c248792904692f5f78562643090a4dc7 Mon Sep 17 00:00:00 2001 From: foamzou Date: Fri, 19 Aug 2022 19:39:26 +0800 Subject: [PATCH 3/4] fix(douyin): add xb params to solve douyin search --- go.mod | 1 + go.sum | 26 + processor/douyin/douyin_test.go | 1 - processor/douyin/gen-xb-js/ascii-base64.js.go | 712 ++++++++++++++++++ processor/douyin/gen-xb-js/crypto-min.js.go | 3 + processor/douyin/gen-xb-js/dy.js.go | 179 +++++ processor/douyin/search.go | 21 +- processor/douyin/search_test.go | 3 +- processor/douyin/xb-deprecate.go | 261 +++++++ processor/douyin/xb-deprecate_test.go | 281 +++++++ processor/douyin/xb.go | 38 + processor/douyin/xb_test.go | 30 + utils/http.go | 19 +- 13 files changed, 1565 insertions(+), 10 deletions(-) create mode 100644 processor/douyin/gen-xb-js/ascii-base64.js.go create mode 100644 processor/douyin/gen-xb-js/crypto-min.js.go create mode 100644 processor/douyin/gen-xb-js/dy.js.go create mode 100644 processor/douyin/xb-deprecate.go create mode 100644 processor/douyin/xb-deprecate_test.go create mode 100644 processor/douyin/xb.go create mode 100644 processor/douyin/xb_test.go diff --git a/go.mod b/go.mod index 9194edf..4d075a3 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,7 @@ require ( github.com/ApesPlan/prefixtree-OpenCC v0.0.1 // indirect github.com/ApesPlan/prefixtree-core v0.0.0-20200724072454-be92dad4a8df // indirect github.com/dexyk/stringosim v0.0.0-20170922105913-9d0b3e91a842 + github.com/dop251/goja v0.0.0-20220815083517-0c74f9139fd6 github.com/go-resty/resty/v2 v2.7.0 github.com/jessevdk/go-flags v1.5.0 ) diff --git a/go.sum b/go.sum index fa9f20e..f90d7e1 100644 --- a/go.sum +++ b/go.sum @@ -4,12 +4,30 @@ github.com/ApesPlan/prefixtree-OpenCC v0.0.1 h1:IUkCLgeeR4KthhTVyvebFhTtAL/2AFWa github.com/ApesPlan/prefixtree-OpenCC v0.0.1/go.mod h1:SiIhatLsC76OcNp+8FWyte/UJVSlQOfSyGP/A67Thz0= github.com/ApesPlan/prefixtree-core v0.0.0-20200724072454-be92dad4a8df h1:DQezQoeXUVrwqRyzb7HTpY/do7sPWRVVzVYaeDBDEPw= github.com/ApesPlan/prefixtree-core v0.0.0-20200724072454-be92dad4a8df/go.mod h1:VRdzaC6I1RuPNF2EQl/dnXx19SXmZsnfc/Qv4cBNMUU= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/dexyk/stringosim v0.0.0-20170922105913-9d0b3e91a842 h1:FWXGhOthNyZKdK0YVyDrkg5dCXOfKvexcRG37U1v6AQ= github.com/dexyk/stringosim v0.0.0-20170922105913-9d0b3e91a842/go.mod h1:PfVoEMbmPGFArz22/wIefW9CzuQhdnE+C9ikEzJvb9Q= +github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= +github.com/dlclark/regexp2 v1.7.0 h1:7lJfhqlPssTb1WQx4yvTHN0uElPEv52sbaECrAQxjAo= +github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= +github.com/dop251/goja v0.0.0-20211022113120-dc8c55024d06/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= +github.com/dop251/goja v0.0.0-20220815083517-0c74f9139fd6 h1:xHdUVG+c8SWJnct16Z3QJOVlaYo3OwoJyamo6kR6OL0= +github.com/dop251/goja v0.0.0-20220815083517-0c74f9139fd6/go.mod h1:yRkwfj0CBpOGre+TwBsqPV0IH0Pk73e4PXJOeNDboGs= +github.com/dop251/goja_nodejs v0.0.0-20210225215109-d91c329300e7/go.mod h1:hn7BA7c8pLvoGndExHudxTDKZ84Pyvv+90pbBjbTz0Y= +github.com/dop251/goja_nodejs v0.0.0-20211022123610-8dd9abb0616d/go.mod h1:DngW8aVqWbuLRMHItjPUyqdj+HWPvnQe8V8y1nDpIbM= github.com/go-resty/resty/v2 v2.7.0 h1:me+K9p3uhSmXtrBZ4k9jcEAfJmuC8IivWHwaLZwPrFY= github.com/go-resty/resty/v2 v2.7.0/go.mod h1:9PWDzw47qPphMRFfhsyk0NnSgvluHcljSMVIq3w7q0I= +github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU= +github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc= github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= golang.org/x/net v0.0.0-20211029224645-99673261e6eb h1:pirldcYWx7rx7kE5r+9WsOXPXK0+WH5+uZ7uPmJ44uM= golang.org/x/net v0.0.0-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -18,4 +36,12 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZOR golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= diff --git a/processor/douyin/douyin_test.go b/processor/douyin/douyin_test.go index 59fac0c..a2a0b97 100644 --- a/processor/douyin/douyin_test.go +++ b/processor/douyin/douyin_test.go @@ -44,7 +44,6 @@ func TestCore_FetchMetaAndResourceInfo(t *testing.T) { Description: "七朵花《我只想要》是多少人的回忆#音乐推荐 #经典音乐#情感音乐#热门歌曲#抖音热歌#音乐mv#音乐 ", Duration: 260, CoverUrl: "jpeg", - Artist: "音乐而动(激光炮)", Album: "抖音Video", Audios: []meta.Audio{{ Url: ".mp3", diff --git a/processor/douyin/gen-xb-js/ascii-base64.js.go b/processor/douyin/gen-xb-js/ascii-base64.js.go new file mode 100644 index 0000000..29251cb --- /dev/null +++ b/processor/douyin/gen-xb-js/ascii-base64.js.go @@ -0,0 +1,712 @@ +package gen_xb_js + +var AsciiBase64 = `(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ethereumjs = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o=0;o--)if(u[o]!==f[o])return!1;for(o=u.length-1;o>=0;o--)if(s=u[o],!_deepEqual(e[s],t[s],r,n))return!1;return!0}function notDeepStrictEqual(e,t,r){_deepEqual(e,t,!0)&&fail(e,t,r,"notDeepStrictEqual",notDeepStrictEqual)}function expectedException(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function _tryBlock(e){var t;try{e()}catch(e){t=e}return t}function _throws(e,t,r,n){var i;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=_tryBlock(t),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),e&&!i&&fail(i,r,"Missing expected exception"+n);var a="string"==typeof n,s=!e&&util.isError(i),o=!e&&i&&!r;if((s&&a&&expectedException(i,r)||o)&&fail(i,r,"Got unwanted exception"+n),e&&i&&r&&!expectedException(i,r)||!e&&i)throw i}var util=require("util/"),hasOwn=Object.prototype.hasOwnProperty,pSlice=Array.prototype.slice,functionsHaveNames="foo"===function(){}.name,assert=module.exports=ok,regex=/\s*function\s+([^\(\s]*)\s*/;assert.AssertionError=function(e){this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=getMessage(this),this.generatedMessage=!0);var t=e.stackStartFunction||fail;if(Error.captureStackTrace)Error.captureStackTrace(this,t);else{var r=new Error;if(r.stack){var n=r.stack,i=getName(t),a=n.indexOf("\n"+i);if(a>=0){var s=n.indexOf("\n",a+1);n=n.substring(s+1)}this.stack=n}}},util.inherits(assert.AssertionError,Error),assert.fail=fail,assert.ok=ok,assert.equal=function(e,t,r){e!=t&&fail(e,t,r,"==",assert.equal)},assert.notEqual=function(e,t,r){e==t&&fail(e,t,r,"!=",assert.notEqual)},assert.deepEqual=function(e,t,r){_deepEqual(e,t,!1)||fail(e,t,r,"deepEqual",assert.deepEqual)},assert.deepStrictEqual=function(e,t,r){_deepEqual(e,t,!0)||fail(e,t,r,"deepStrictEqual",assert.deepStrictEqual)},assert.notDeepEqual=function(e,t,r){_deepEqual(e,t,!1)&&fail(e,t,r,"notDeepEqual",assert.notDeepEqual)},assert.notDeepStrictEqual=notDeepStrictEqual,assert.strictEqual=function(e,t,r){e!==t&&fail(e,t,r,"===",assert.strictEqual)},assert.notStrictEqual=function(e,t,r){e===t&&fail(e,t,r,"!==",assert.notStrictEqual)},assert.throws=function(e,t,r){_throws(!0,e,t,r)},assert.doesNotThrow=function(e,t,r){_throws(!1,e,t,r)},assert.ifError=function(e){if(e)throw e};var objectKeys=Object.keys||function(e){var t=[];for(var r in e)hasOwn.call(e,r)&&t.push(r);return t}; + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"util/":103}],2:[function(require,module,exports){ +"use strict";function placeHoldersCount(o){var r=o.length;if(r%4>0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===o[r-2]?2:"="===o[r-1]?1:0}function byteLength(o){return 3*o.length/4-placeHoldersCount(o)}function toByteArray(o){var r,e,t,u,n,p=o.length;u=placeHoldersCount(o),n=new Arr(3*p/4-u),e=u>0?p-4:p;var a=0;for(r=0;r>16&255,n[a++]=t>>8&255,n[a++]=255&t;return 2===u?(t=revLookup[o.charCodeAt(r)]<<2|revLookup[o.charCodeAt(r+1)]>>4,n[a++]=255&t):1===u&&(t=revLookup[o.charCodeAt(r)]<<10|revLookup[o.charCodeAt(r+1)]<<4|revLookup[o.charCodeAt(r+2)]>>2,n[a++]=t>>8&255,n[a++]=255&t),n}function tripletToBase64(o){return lookup[o>>18&63]+lookup[o>>12&63]+lookup[o>>6&63]+lookup[63&o]}function encodeChunk(o,r,e){for(var t,u=[],n=r;na?a:p+16383));return 1===t?(r=o[e-1],u+=lookup[r>>2],u+=lookup[r<<4&63],u+="=="):2===t&&(r=(o[e-2]<<8)+o[e-1],u+=lookup[r>>10],u+=lookup[r>>4&63],u+=lookup[r<<2&63],u+="="),n.push(u),n.join("")}exports.byteLength=byteLength,exports.toByteArray=toByteArray,exports.fromByteArray=fromByteArray;for(var lookup=[],revLookup=[],Arr="undefined"!=typeof Uint8Array?Uint8Array:Array,code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,len=code.length;i72)return!1;if(48!==e[0])return!1;if(e[1]!==e.length-2)return!1;if(2!==e[2])return!1;var r=e[3];if(0===r)return!1;if(5+r>=e.length)return!1;if(2!==e[4+r])return!1;var n=e[5+r];return 0!==n&&(6+r+n===e.length&&(!(128&e[4])&&(!(r>1&&0===e[4]&&!(128&e[5]))&&(!(128&e[r+6])&&!(n>1&&0===e[r+6]&&!(128&e[r+7]))))))}function decode(e){if(e.length<8)throw new Error("DER sequence length is too short");if(e.length>72)throw new Error("DER sequence length is too long");if(48!==e[0])throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(2!==e[2])throw new Error("Expected DER integer");var r=e[3];if(0===r)throw new Error("R length is zero");if(5+r>=e.length)throw new Error("R length is too long");if(2!==e[4+r])throw new Error("Expected DER integer (2)");var n=e[5+r];if(0===n)throw new Error("S length is zero");if(6+r+n!==e.length)throw new Error("S length is invalid");if(128&e[4])throw new Error("R value is negative");if(r>1&&0===e[4]&&!(128&e[5]))throw new Error("R value excessively padded");if(128&e[r+6])throw new Error("S value is negative");if(n>1&&0===e[r+6]&&!(128&e[r+7]))throw new Error("S value excessively padded");return{r:e.slice(4,4+r),s:e.slice(6+r)}}function encode(e,r){var n=e.length,t=r.length;if(0===n)throw new Error("R length is zero");if(0===t)throw new Error("S length is zero");if(n>33)throw new Error("R length is too long");if(t>33)throw new Error("S length is too long");if(128&e[0])throw new Error("R value is negative");if(128&r[0])throw new Error("S value is negative");if(n>1&&0===e[0]&&!(128&e[1]))throw new Error("R value excessively padded");if(t>1&&0===r[0]&&!(128&r[1]))throw new Error("S value excessively padded");var o=Buffer.allocUnsafe(6+n+t);return o[0]=48,o[1]=o.length-2,o[2]=2,o[3]=e.length,e.copy(o,4),o[4+n]=2,o[5+n]=r.length,r.copy(o,6+n),o}var Buffer=require("safe-buffer").Buffer;module.exports={check:check,decode:decode,encode:encode}; + +},{"safe-buffer":82}],4:[function(require,module,exports){ +!function(t,i){"use strict";function r(t,i){if(!t)throw new Error(i||"Assertion failed")}function h(t,i){t.super_=i;var r=function(){};r.prototype=i.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,i,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==i&&"be"!==i||(r=i,i=10),this._init(t||0,i||10,r||"be"))}function e(t,i,r){for(var h=0,n=Math.min(t.length,r),e=i;e=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return h}function o(t,i,r,h){for(var n=0,e=Math.min(t.length,r),o=i;o=49?s-49+10:s>=17?s-17+10:s}return n}function s(t){for(var i=new Array(t.bitLength()),r=0;r>>n}return i}function u(t,i,r){r.negative=i.negative^t.negative;var h=t.length+i.length|0;r.length=h,h=h-1|0;var n=0|t.words[0],e=0|i.words[0],o=n*e,s=67108863&o,u=o/67108864|0;r.words[0]=s;for(var a=1;a>>26,m=67108863&u,f=Math.min(a,i.length-1),d=Math.max(0,a-t.length+1);d<=f;d++){var p=a-d|0;l+=(o=(n=0|t.words[p])*(e=0|i.words[d])+m)/67108864|0,m=67108863&o}r.words[a]=0|m,u=0|l}return 0!==u?r.words[a]=0|u:r.length--,r.strip()}function a(t,i,r){r.negative=i.negative^t.negative,r.length=t.length+i.length;for(var h=0,n=0,e=0;e>>26)|0)>>>26,o&=67108863}r.words[e]=s,h=o,o=n}return 0!==h?r.words[e]=h:r.length--,r.strip()}function l(t,i,r){return(new m).mulp(t,i,r)}function m(t,i){this.x=t,this.y=i}function f(t,i){this.name=t,this.p=new n(i,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function d(){f.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function p(){f.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function M(){f.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function v(){f.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function g(t){if("string"==typeof t){var i=n._prime(t);this.m=i.p,this.prime=i}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function c(t){g.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}"object"==typeof t?t.exports=n:i.BN=n,n.BN=n,n.wordSize=26;var w;try{w=require("buffer").Buffer}catch(t){}n.isBN=function(t){return t instanceof n||null!==t&&"object"==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,i){return t.cmp(i)>0?t:i},n.min=function(t,i){return t.cmp(i)<0?t:i},n.prototype._init=function(t,i,h){if("number"==typeof t)return this._initNumber(t,i,h);if("object"==typeof t)return this._initArray(t,i,h);"hex"===i&&(i=16),r(i===(0|i)&&i>=2&&i<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&n++,16===i?this._parseHex(t,n):this._parseBase(t,i,n),"-"===t[0]&&(this.negative=1),this.strip(),"le"===h&&this._initArray(this.toArray(),i,h)},n.prototype._initNumber=function(t,i,h){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===h&&this._initArray(this.toArray(),i,h)},n.prototype._initArray=function(t,i,h){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[e]|=o<>>26-s&67108863,(s+=24)>=26&&(s-=26,e++);else if("le"===h)for(n=0,e=0;n>>26-s&67108863,(s+=24)>=26&&(s-=26,e++);return this.strip()},n.prototype._parseHex=function(t,i){this.length=Math.ceil((t.length-i)/6),this.words=new Array(this.length);for(var r=0;r=i;r-=6)n=e(t,r,r+6),this.words[h]|=n<>>26-o&4194303,(o+=24)>=26&&(o-=26,h++);r+6!==i&&(n=e(t,i,r+6),this.words[h]|=n<>>26-o&4194303),this.strip()},n.prototype._parseBase=function(t,i,r){this.words=[0],this.length=1;for(var h=0,n=1;n<=67108863;n*=i)h++;h--,n=n/i|0;for(var e=t.length-r,s=e%h,u=Math.min(e,e-s)+r,a=0,l=r;l1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},n.prototype.inspect=function(){return(this.red?""};var y=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],b=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],_=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(t,i){t=t||10,i=0|i||1;var h;if(16===t||"hex"===t){h="";for(var n=0,e=0,o=0;o>>24-n&16777215)||o!==this.length-1?y[6-u.length]+u+h:u+h,(n+=2)>=26&&(n-=26,o--)}for(0!==e&&(h=e.toString(16)+h);h.length%i!=0;)h="0"+h;return 0!==this.negative&&(h="-"+h),h}if(t===(0|t)&&t>=2&&t<=36){var a=b[t],l=_[t];h="";var m=this.clone();for(m.negative=0;!m.isZero();){var f=m.modn(l).toString(t);h=(m=m.idivn(l)).isZero()?f+h:y[a-f.length]+f+h}for(this.isZero()&&(h="0"+h);h.length%i!=0;)h="0"+h;return 0!==this.negative&&(h="-"+h),h}r(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(t,i){return r(void 0!==w),this.toArrayLike(w,t,i)},n.prototype.toArray=function(t,i){return this.toArrayLike(Array,t,i)},n.prototype.toArrayLike=function(t,i,h){var n=this.byteLength(),e=h||Math.max(1,n);r(n<=e,"byte array longer than desired length"),r(e>0,"Requested array length <= 0"),this.strip();var o,s,u="le"===i,a=new t(e),l=this.clone();if(u){for(s=0;!l.isZero();s++)o=l.andln(255),l.iushrn(8),a[s]=o;for(;s=4096&&(r+=13,i>>>=13),i>=64&&(r+=7,i>>>=7),i>=8&&(r+=4,i>>>=4),i>=2&&(r+=2,i>>>=2),r+i},n.prototype._zeroBits=function(t){if(0===t)return 26;var i=t,r=0;return 0==(8191&i)&&(r+=13,i>>>=13),0==(127&i)&&(r+=7,i>>>=7),0==(15&i)&&(r+=4,i>>>=4),0==(3&i)&&(r+=2,i>>>=2),0==(1&i)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],i=this._countBits(t);return 26*(this.length-1)+i},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,i=0;it.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var i;i=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var i,r;this.length>t.length?(i=this,r=t):(i=t,r=this);for(var h=0;ht.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var i=0|Math.ceil(t/26),h=t%26;this._expand(i),h>0&&i--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-h),this.strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,i){r("number"==typeof t&&t>=0);var h=t/26|0,n=t%26;return this._expand(h+1),this.words[h]=i?this.words[h]|1<t.length?(r=this,h=t):(r=t,h=this);for(var n=0,e=0;e>>26;for(;0!==n&&e>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;et.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var i=this.iadd(t);return t.negative=1,i._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r=this.cmp(t);if(0===r)return this.negative=0,this.length=1,this.words[0]=0,this;var h,n;r>0?(h=this,n=t):(h=t,n=this);for(var e=0,o=0;o>26,this.words[o]=67108863&i;for(;0!==e&&o>26,this.words[o]=67108863&i;if(0===e&&o>>13,d=0|o[1],p=8191&d,M=d>>>13,v=0|o[2],g=8191&v,c=v>>>13,w=0|o[3],y=8191&w,b=w>>>13,_=0|o[4],k=8191&_,A=_>>>13,x=0|o[5],S=8191&x,Z=x>>>13,q=0|o[6],R=8191&q,B=q>>>13,N=0|o[7],L=8191&N,I=N>>>13,z=0|o[8],T=8191&z,E=z>>>13,O=0|o[9],j=8191&O,K=O>>>13,P=0|s[0],F=8191&P,C=P>>>13,D=0|s[1],H=8191&D,J=D>>>13,U=0|s[2],G=8191&U,Q=U>>>13,V=0|s[3],W=8191&V,X=V>>>13,Y=0|s[4],$=8191&Y,tt=Y>>>13,it=0|s[5],rt=8191&it,ht=it>>>13,nt=0|s[6],et=8191&nt,ot=nt>>>13,st=0|s[7],ut=8191&st,at=st>>>13,lt=0|s[8],mt=8191<,ft=lt>>>13,dt=0|s[9],pt=8191&dt,Mt=dt>>>13;r.negative=t.negative^i.negative,r.length=19;var vt=(a+(h=Math.imul(m,F))|0)+((8191&(n=(n=Math.imul(m,C))+Math.imul(f,F)|0))<<13)|0;a=((e=Math.imul(f,C))+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,h=Math.imul(p,F),n=(n=Math.imul(p,C))+Math.imul(M,F)|0,e=Math.imul(M,C);var gt=(a+(h=h+Math.imul(m,H)|0)|0)+((8191&(n=(n=n+Math.imul(m,J)|0)+Math.imul(f,H)|0))<<13)|0;a=((e=e+Math.imul(f,J)|0)+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,h=Math.imul(g,F),n=(n=Math.imul(g,C))+Math.imul(c,F)|0,e=Math.imul(c,C),h=h+Math.imul(p,H)|0,n=(n=n+Math.imul(p,J)|0)+Math.imul(M,H)|0,e=e+Math.imul(M,J)|0;var ct=(a+(h=h+Math.imul(m,G)|0)|0)+((8191&(n=(n=n+Math.imul(m,Q)|0)+Math.imul(f,G)|0))<<13)|0;a=((e=e+Math.imul(f,Q)|0)+(n>>>13)|0)+(ct>>>26)|0,ct&=67108863,h=Math.imul(y,F),n=(n=Math.imul(y,C))+Math.imul(b,F)|0,e=Math.imul(b,C),h=h+Math.imul(g,H)|0,n=(n=n+Math.imul(g,J)|0)+Math.imul(c,H)|0,e=e+Math.imul(c,J)|0,h=h+Math.imul(p,G)|0,n=(n=n+Math.imul(p,Q)|0)+Math.imul(M,G)|0,e=e+Math.imul(M,Q)|0;var wt=(a+(h=h+Math.imul(m,W)|0)|0)+((8191&(n=(n=n+Math.imul(m,X)|0)+Math.imul(f,W)|0))<<13)|0;a=((e=e+Math.imul(f,X)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,h=Math.imul(k,F),n=(n=Math.imul(k,C))+Math.imul(A,F)|0,e=Math.imul(A,C),h=h+Math.imul(y,H)|0,n=(n=n+Math.imul(y,J)|0)+Math.imul(b,H)|0,e=e+Math.imul(b,J)|0,h=h+Math.imul(g,G)|0,n=(n=n+Math.imul(g,Q)|0)+Math.imul(c,G)|0,e=e+Math.imul(c,Q)|0,h=h+Math.imul(p,W)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(M,W)|0,e=e+Math.imul(M,X)|0;var yt=(a+(h=h+Math.imul(m,$)|0)|0)+((8191&(n=(n=n+Math.imul(m,tt)|0)+Math.imul(f,$)|0))<<13)|0;a=((e=e+Math.imul(f,tt)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,h=Math.imul(S,F),n=(n=Math.imul(S,C))+Math.imul(Z,F)|0,e=Math.imul(Z,C),h=h+Math.imul(k,H)|0,n=(n=n+Math.imul(k,J)|0)+Math.imul(A,H)|0,e=e+Math.imul(A,J)|0,h=h+Math.imul(y,G)|0,n=(n=n+Math.imul(y,Q)|0)+Math.imul(b,G)|0,e=e+Math.imul(b,Q)|0,h=h+Math.imul(g,W)|0,n=(n=n+Math.imul(g,X)|0)+Math.imul(c,W)|0,e=e+Math.imul(c,X)|0,h=h+Math.imul(p,$)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(M,$)|0,e=e+Math.imul(M,tt)|0;var bt=(a+(h=h+Math.imul(m,rt)|0)|0)+((8191&(n=(n=n+Math.imul(m,ht)|0)+Math.imul(f,rt)|0))<<13)|0;a=((e=e+Math.imul(f,ht)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,h=Math.imul(R,F),n=(n=Math.imul(R,C))+Math.imul(B,F)|0,e=Math.imul(B,C),h=h+Math.imul(S,H)|0,n=(n=n+Math.imul(S,J)|0)+Math.imul(Z,H)|0,e=e+Math.imul(Z,J)|0,h=h+Math.imul(k,G)|0,n=(n=n+Math.imul(k,Q)|0)+Math.imul(A,G)|0,e=e+Math.imul(A,Q)|0,h=h+Math.imul(y,W)|0,n=(n=n+Math.imul(y,X)|0)+Math.imul(b,W)|0,e=e+Math.imul(b,X)|0,h=h+Math.imul(g,$)|0,n=(n=n+Math.imul(g,tt)|0)+Math.imul(c,$)|0,e=e+Math.imul(c,tt)|0,h=h+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,ht)|0)+Math.imul(M,rt)|0,e=e+Math.imul(M,ht)|0;var _t=(a+(h=h+Math.imul(m,et)|0)|0)+((8191&(n=(n=n+Math.imul(m,ot)|0)+Math.imul(f,et)|0))<<13)|0;a=((e=e+Math.imul(f,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,h=Math.imul(L,F),n=(n=Math.imul(L,C))+Math.imul(I,F)|0,e=Math.imul(I,C),h=h+Math.imul(R,H)|0,n=(n=n+Math.imul(R,J)|0)+Math.imul(B,H)|0,e=e+Math.imul(B,J)|0,h=h+Math.imul(S,G)|0,n=(n=n+Math.imul(S,Q)|0)+Math.imul(Z,G)|0,e=e+Math.imul(Z,Q)|0,h=h+Math.imul(k,W)|0,n=(n=n+Math.imul(k,X)|0)+Math.imul(A,W)|0,e=e+Math.imul(A,X)|0,h=h+Math.imul(y,$)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(b,$)|0,e=e+Math.imul(b,tt)|0,h=h+Math.imul(g,rt)|0,n=(n=n+Math.imul(g,ht)|0)+Math.imul(c,rt)|0,e=e+Math.imul(c,ht)|0,h=h+Math.imul(p,et)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(M,et)|0,e=e+Math.imul(M,ot)|0;var kt=(a+(h=h+Math.imul(m,ut)|0)|0)+((8191&(n=(n=n+Math.imul(m,at)|0)+Math.imul(f,ut)|0))<<13)|0;a=((e=e+Math.imul(f,at)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,h=Math.imul(T,F),n=(n=Math.imul(T,C))+Math.imul(E,F)|0,e=Math.imul(E,C),h=h+Math.imul(L,H)|0,n=(n=n+Math.imul(L,J)|0)+Math.imul(I,H)|0,e=e+Math.imul(I,J)|0,h=h+Math.imul(R,G)|0,n=(n=n+Math.imul(R,Q)|0)+Math.imul(B,G)|0,e=e+Math.imul(B,Q)|0,h=h+Math.imul(S,W)|0,n=(n=n+Math.imul(S,X)|0)+Math.imul(Z,W)|0,e=e+Math.imul(Z,X)|0,h=h+Math.imul(k,$)|0,n=(n=n+Math.imul(k,tt)|0)+Math.imul(A,$)|0,e=e+Math.imul(A,tt)|0,h=h+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,ht)|0)+Math.imul(b,rt)|0,e=e+Math.imul(b,ht)|0,h=h+Math.imul(g,et)|0,n=(n=n+Math.imul(g,ot)|0)+Math.imul(c,et)|0,e=e+Math.imul(c,ot)|0,h=h+Math.imul(p,ut)|0,n=(n=n+Math.imul(p,at)|0)+Math.imul(M,ut)|0,e=e+Math.imul(M,at)|0;var At=(a+(h=h+Math.imul(m,mt)|0)|0)+((8191&(n=(n=n+Math.imul(m,ft)|0)+Math.imul(f,mt)|0))<<13)|0;a=((e=e+Math.imul(f,ft)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,h=Math.imul(j,F),n=(n=Math.imul(j,C))+Math.imul(K,F)|0,e=Math.imul(K,C),h=h+Math.imul(T,H)|0,n=(n=n+Math.imul(T,J)|0)+Math.imul(E,H)|0,e=e+Math.imul(E,J)|0,h=h+Math.imul(L,G)|0,n=(n=n+Math.imul(L,Q)|0)+Math.imul(I,G)|0,e=e+Math.imul(I,Q)|0,h=h+Math.imul(R,W)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(B,W)|0,e=e+Math.imul(B,X)|0,h=h+Math.imul(S,$)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(Z,$)|0,e=e+Math.imul(Z,tt)|0,h=h+Math.imul(k,rt)|0,n=(n=n+Math.imul(k,ht)|0)+Math.imul(A,rt)|0,e=e+Math.imul(A,ht)|0,h=h+Math.imul(y,et)|0,n=(n=n+Math.imul(y,ot)|0)+Math.imul(b,et)|0,e=e+Math.imul(b,ot)|0,h=h+Math.imul(g,ut)|0,n=(n=n+Math.imul(g,at)|0)+Math.imul(c,ut)|0,e=e+Math.imul(c,at)|0,h=h+Math.imul(p,mt)|0,n=(n=n+Math.imul(p,ft)|0)+Math.imul(M,mt)|0,e=e+Math.imul(M,ft)|0;var xt=(a+(h=h+Math.imul(m,pt)|0)|0)+((8191&(n=(n=n+Math.imul(m,Mt)|0)+Math.imul(f,pt)|0))<<13)|0;a=((e=e+Math.imul(f,Mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,h=Math.imul(j,H),n=(n=Math.imul(j,J))+Math.imul(K,H)|0,e=Math.imul(K,J),h=h+Math.imul(T,G)|0,n=(n=n+Math.imul(T,Q)|0)+Math.imul(E,G)|0,e=e+Math.imul(E,Q)|0,h=h+Math.imul(L,W)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(I,W)|0,e=e+Math.imul(I,X)|0,h=h+Math.imul(R,$)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(B,$)|0,e=e+Math.imul(B,tt)|0,h=h+Math.imul(S,rt)|0,n=(n=n+Math.imul(S,ht)|0)+Math.imul(Z,rt)|0,e=e+Math.imul(Z,ht)|0,h=h+Math.imul(k,et)|0,n=(n=n+Math.imul(k,ot)|0)+Math.imul(A,et)|0,e=e+Math.imul(A,ot)|0,h=h+Math.imul(y,ut)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(b,ut)|0,e=e+Math.imul(b,at)|0,h=h+Math.imul(g,mt)|0,n=(n=n+Math.imul(g,ft)|0)+Math.imul(c,mt)|0,e=e+Math.imul(c,ft)|0;var St=(a+(h=h+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,Mt)|0)+Math.imul(M,pt)|0))<<13)|0;a=((e=e+Math.imul(M,Mt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,h=Math.imul(j,G),n=(n=Math.imul(j,Q))+Math.imul(K,G)|0,e=Math.imul(K,Q),h=h+Math.imul(T,W)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(E,W)|0,e=e+Math.imul(E,X)|0,h=h+Math.imul(L,$)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(I,$)|0,e=e+Math.imul(I,tt)|0,h=h+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,ht)|0)+Math.imul(B,rt)|0,e=e+Math.imul(B,ht)|0,h=h+Math.imul(S,et)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(Z,et)|0,e=e+Math.imul(Z,ot)|0,h=h+Math.imul(k,ut)|0,n=(n=n+Math.imul(k,at)|0)+Math.imul(A,ut)|0,e=e+Math.imul(A,at)|0,h=h+Math.imul(y,mt)|0,n=(n=n+Math.imul(y,ft)|0)+Math.imul(b,mt)|0,e=e+Math.imul(b,ft)|0;var Zt=(a+(h=h+Math.imul(g,pt)|0)|0)+((8191&(n=(n=n+Math.imul(g,Mt)|0)+Math.imul(c,pt)|0))<<13)|0;a=((e=e+Math.imul(c,Mt)|0)+(n>>>13)|0)+(Zt>>>26)|0,Zt&=67108863,h=Math.imul(j,W),n=(n=Math.imul(j,X))+Math.imul(K,W)|0,e=Math.imul(K,X),h=h+Math.imul(T,$)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(E,$)|0,e=e+Math.imul(E,tt)|0,h=h+Math.imul(L,rt)|0,n=(n=n+Math.imul(L,ht)|0)+Math.imul(I,rt)|0,e=e+Math.imul(I,ht)|0,h=h+Math.imul(R,et)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(B,et)|0,e=e+Math.imul(B,ot)|0,h=h+Math.imul(S,ut)|0,n=(n=n+Math.imul(S,at)|0)+Math.imul(Z,ut)|0,e=e+Math.imul(Z,at)|0,h=h+Math.imul(k,mt)|0,n=(n=n+Math.imul(k,ft)|0)+Math.imul(A,mt)|0,e=e+Math.imul(A,ft)|0;var qt=(a+(h=h+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,Mt)|0)+Math.imul(b,pt)|0))<<13)|0;a=((e=e+Math.imul(b,Mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863,h=Math.imul(j,$),n=(n=Math.imul(j,tt))+Math.imul(K,$)|0,e=Math.imul(K,tt),h=h+Math.imul(T,rt)|0,n=(n=n+Math.imul(T,ht)|0)+Math.imul(E,rt)|0,e=e+Math.imul(E,ht)|0,h=h+Math.imul(L,et)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(I,et)|0,e=e+Math.imul(I,ot)|0,h=h+Math.imul(R,ut)|0,n=(n=n+Math.imul(R,at)|0)+Math.imul(B,ut)|0,e=e+Math.imul(B,at)|0,h=h+Math.imul(S,mt)|0,n=(n=n+Math.imul(S,ft)|0)+Math.imul(Z,mt)|0,e=e+Math.imul(Z,ft)|0;var Rt=(a+(h=h+Math.imul(k,pt)|0)|0)+((8191&(n=(n=n+Math.imul(k,Mt)|0)+Math.imul(A,pt)|0))<<13)|0;a=((e=e+Math.imul(A,Mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,h=Math.imul(j,rt),n=(n=Math.imul(j,ht))+Math.imul(K,rt)|0,e=Math.imul(K,ht),h=h+Math.imul(T,et)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(E,et)|0,e=e+Math.imul(E,ot)|0,h=h+Math.imul(L,ut)|0,n=(n=n+Math.imul(L,at)|0)+Math.imul(I,ut)|0,e=e+Math.imul(I,at)|0,h=h+Math.imul(R,mt)|0,n=(n=n+Math.imul(R,ft)|0)+Math.imul(B,mt)|0,e=e+Math.imul(B,ft)|0;var Bt=(a+(h=h+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,Mt)|0)+Math.imul(Z,pt)|0))<<13)|0;a=((e=e+Math.imul(Z,Mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,h=Math.imul(j,et),n=(n=Math.imul(j,ot))+Math.imul(K,et)|0,e=Math.imul(K,ot),h=h+Math.imul(T,ut)|0,n=(n=n+Math.imul(T,at)|0)+Math.imul(E,ut)|0,e=e+Math.imul(E,at)|0,h=h+Math.imul(L,mt)|0,n=(n=n+Math.imul(L,ft)|0)+Math.imul(I,mt)|0,e=e+Math.imul(I,ft)|0;var Nt=(a+(h=h+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,Mt)|0)+Math.imul(B,pt)|0))<<13)|0;a=((e=e+Math.imul(B,Mt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,h=Math.imul(j,ut),n=(n=Math.imul(j,at))+Math.imul(K,ut)|0,e=Math.imul(K,at),h=h+Math.imul(T,mt)|0,n=(n=n+Math.imul(T,ft)|0)+Math.imul(E,mt)|0,e=e+Math.imul(E,ft)|0;var Lt=(a+(h=h+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,Mt)|0)+Math.imul(I,pt)|0))<<13)|0;a=((e=e+Math.imul(I,Mt)|0)+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,h=Math.imul(j,mt),n=(n=Math.imul(j,ft))+Math.imul(K,mt)|0,e=Math.imul(K,ft);var It=(a+(h=h+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,Mt)|0)+Math.imul(E,pt)|0))<<13)|0;a=((e=e+Math.imul(E,Mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863;var zt=(a+(h=Math.imul(j,pt))|0)+((8191&(n=(n=Math.imul(j,Mt))+Math.imul(K,pt)|0))<<13)|0;return a=((e=Math.imul(K,Mt))+(n>>>13)|0)+(zt>>>26)|0,zt&=67108863,u[0]=vt,u[1]=gt,u[2]=ct,u[3]=wt,u[4]=yt,u[5]=bt,u[6]=_t,u[7]=kt,u[8]=At,u[9]=xt,u[10]=St,u[11]=Zt,u[12]=qt,u[13]=Rt,u[14]=Bt,u[15]=Nt,u[16]=Lt,u[17]=It,u[18]=zt,0!==a&&(u[19]=a,r.length++),r};Math.imul||(k=u),n.prototype.mulTo=function(t,i){var r=this.length+t.length;return 10===this.length&&10===t.length?k(this,t,i):r<63?u(this,t,i):r<1024?a(this,t,i):l(this,t,i)},m.prototype.makeRBT=function(t){for(var i=new Array(t),r=n.prototype._countBits(t)-1,h=0;h>=1;return h},m.prototype.permute=function(t,i,r,h,n,e){for(var o=0;o>>=1)n++;return 1<>>=13,h[2*o+1]=8191&e,e>>>=13;for(o=2*i;o>=26,i+=n/67108864|0,i+=e>>>26,this.words[h]=67108863&e}return 0!==i&&(this.words[h]=i,this.length++),this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var i=s(t);if(0===i.length)return new n(1);for(var r=this,h=0;h=0);var i,h=t%26,n=(t-h)/26,e=67108863>>>26-h<<26-h;if(0!==h){var o=0;for(i=0;i>>26-h}o&&(this.words[i]=o,this.length++)}if(0!==n){for(i=this.length-1;i>=0;i--)this.words[i+n]=this.words[i];for(i=0;i=0);var n;n=i?(i-i%26)/26:0;var e=t%26,o=Math.min((t-e)/26,this.length),s=67108863^67108863>>>e<o)for(this.length-=o,a=0;a=0&&(0!==l||a>=n);a--){var m=0|this.words[a];this.words[a]=l<<26-e|m>>>e,l=m&s}return u&&0!==l&&(u.words[u.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(t,i,h){return r(0===this.negative),this.iushrn(t,i,h)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r("number"==typeof t&&t>=0);var i=t%26,h=(t-i)/26,n=1<=0);var i=t%26,h=(t-i)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=h)return this;if(0!==i&&h++,this.length=Math.min(h,this.length),0!==i){var n=67108863^67108863>>>i<=67108864;i++)this.words[i]-=67108864,i===this.length-1?this.words[i+1]=1:this.words[i+1]++;return this.length=Math.max(this.length,i+1),this},n.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var i=0;i>26)-(u/67108864|0),this.words[n+h]=67108863&o}for(;n>26,this.words[n+h]=67108863&o;if(0===s)return this.strip();for(r(-1===s),s=0,n=0;n>26,this.words[n]=67108863&o;return this.negative=1,this.strip()},n.prototype._wordDiv=function(t,i){var r=this.length-t.length,h=this.clone(),e=t,o=0|e.words[e.length-1];0!==(r=26-this._countBits(o))&&(e=e.ushln(r),h.iushln(r),o=0|e.words[e.length-1]);var s,u=h.length-e.length;if("mod"!==i){(s=new n(null)).length=u+1,s.words=new Array(s.length);for(var a=0;a=0;m--){var f=67108864*(0|h.words[e.length+m])+(0|h.words[e.length+m-1]);for(f=Math.min(f/o|0,67108863),h._ishlnsubmul(e,f,m);0!==h.negative;)f--,h.negative=0,h._ishlnsubmul(e,1,m),h.isZero()||(h.negative^=1);s&&(s.words[m]=f)}return s&&s.strip(),h.strip(),"div"!==i&&0!==r&&h.iushrn(r),{div:s||null,mod:h}},n.prototype.divmod=function(t,i,h){if(r(!t.isZero()),this.isZero())return{div:new n(0),mod:new n(0)};var e,o,s;return 0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,i),"mod"!==i&&(e=s.div.neg()),"div"!==i&&(o=s.mod.neg(),h&&0!==o.negative&&o.iadd(t)),{div:e,mod:o}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),i),"mod"!==i&&(e=s.div.neg()),{div:e,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),i),"div"!==i&&(o=s.mod.neg(),h&&0!==o.negative&&o.isub(t)),{div:s.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?"div"===i?{div:this.divn(t.words[0]),mod:null}:"mod"===i?{div:null,mod:new n(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modn(t.words[0]))}:this._wordDiv(t,i)},n.prototype.div=function(t){return this.divmod(t,"div",!1).div},n.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},n.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},n.prototype.divRound=function(t){var i=this.divmod(t);if(i.mod.isZero())return i.div;var r=0!==i.div.negative?i.mod.isub(t):i.mod,h=t.ushrn(1),n=t.andln(1),e=r.cmp(h);return e<0||1===n&&0===e?i.div:0!==i.div.negative?i.div.isubn(1):i.div.iaddn(1)},n.prototype.modn=function(t){r(t<=67108863);for(var i=(1<<26)%t,h=0,n=this.length-1;n>=0;n--)h=(i*h+(0|this.words[n]))%t;return h},n.prototype.idivn=function(t){r(t<=67108863);for(var i=0,h=this.length-1;h>=0;h--){var n=(0|this.words[h])+67108864*i;this.words[h]=n/t|0,i=n%t}return this.strip()},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var i=this,h=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var e=new n(1),o=new n(0),s=new n(0),u=new n(1),a=0;i.isEven()&&h.isEven();)i.iushrn(1),h.iushrn(1),++a;for(var l=h.clone(),m=i.clone();!i.isZero();){for(var f=0,d=1;0==(i.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(i.iushrn(f);f-- >0;)(e.isOdd()||o.isOdd())&&(e.iadd(l),o.isub(m)),e.iushrn(1),o.iushrn(1);for(var p=0,M=1;0==(h.words[0]&M)&&p<26;++p,M<<=1);if(p>0)for(h.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(l),u.isub(m)),s.iushrn(1),u.iushrn(1);i.cmp(h)>=0?(i.isub(h),e.isub(s),o.isub(u)):(h.isub(i),s.isub(e),u.isub(o))}return{a:s,b:u,gcd:h.iushln(a)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var i=this,h=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var e=new n(1),o=new n(0),s=h.clone();i.cmpn(1)>0&&h.cmpn(1)>0;){for(var u=0,a=1;0==(i.words[0]&a)&&u<26;++u,a<<=1);if(u>0)for(i.iushrn(u);u-- >0;)e.isOdd()&&e.iadd(s),e.iushrn(1);for(var l=0,m=1;0==(h.words[0]&m)&&l<26;++l,m<<=1);if(l>0)for(h.iushrn(l);l-- >0;)o.isOdd()&&o.iadd(s),o.iushrn(1);i.cmp(h)>=0?(i.isub(h),e.isub(o)):(h.isub(i),o.isub(e))}var f;return(f=0===i.cmpn(1)?e:o).cmpn(0)<0&&f.iadd(t),f},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var i=this.clone(),r=t.clone();i.negative=0,r.negative=0;for(var h=0;i.isEven()&&r.isEven();h++)i.iushrn(1),r.iushrn(1);for(;;){for(;i.isEven();)i.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=i.cmp(r);if(n<0){var e=i;i=r,r=e}else if(0===n||0===r.cmpn(1))break;i.isub(r)}return r.iushln(h)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return 0==(1&this.words[0])},n.prototype.isOdd=function(){return 1==(1&this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r("number"==typeof t);var i=t%26,h=(t-i)/26,n=1<>>26,s&=67108863,this.words[o]=s}return 0!==e&&(this.words[o]=e,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;this.strip();var h;if(this.length>1)h=1;else{i&&(t=-t),r(t<=67108863,"Number is too big");var n=0|this.words[0];h=n===t?0:nt.length)return 1;if(this.length=0;r--){var h=0|this.words[r],n=0|t.words[r];if(h!==n){hn&&(i=1);break}}return i},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new g(t)},n.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var A={k256:null,p224:null,p192:null,p25519:null};f.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},f.prototype.ireduce=function(t){var i,r=t;do{this.split(r,this.tmp),i=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(i>this.n);var h=i0?r.isub(this.p):r.strip(),r},f.prototype.split=function(t,i){t.iushrn(this.n,0,i)},f.prototype.imulK=function(t){return t.imul(this.k)},h(d,f),d.prototype.split=function(t,i){for(var r=Math.min(t.length,9),h=0;h>>22,n=e}n>>>=22,t.words[h-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},d.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var i=0,r=0;r>>=26,t.words[r]=n,i=h}return 0!==i&&(t.words[t.length++]=i),t},n._prime=function(t){if(A[t])return A[t];var i;if("k256"===t)i=new d;else if("p224"===t)i=new p;else if("p192"===t)i=new M;else{if("p25519"!==t)throw new Error("Unknown prime "+t);i=new v}return A[t]=i,i},g.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},g.prototype._verify2=function(t,i){r(0==(t.negative|i.negative),"red works only with positives"),r(t.red&&t.red===i.red,"red works only with red numbers")},g.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},g.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},g.prototype.add=function(t,i){this._verify2(t,i);var r=t.add(i);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},g.prototype.iadd=function(t,i){this._verify2(t,i);var r=t.iadd(i);return r.cmp(this.m)>=0&&r.isub(this.m),r},g.prototype.sub=function(t,i){this._verify2(t,i);var r=t.sub(i);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},g.prototype.isub=function(t,i){this._verify2(t,i);var r=t.isub(i);return r.cmpn(0)<0&&r.iadd(this.m),r},g.prototype.shl=function(t,i){return this._verify1(t),this.imod(t.ushln(i))},g.prototype.imul=function(t,i){return this._verify2(t,i),this.imod(t.imul(i))},g.prototype.mul=function(t,i){return this._verify2(t,i),this.imod(t.mul(i))},g.prototype.isqr=function(t){return this.imul(t,t.clone())},g.prototype.sqr=function(t){return this.mul(t,t)},g.prototype.sqrt=function(t){if(t.isZero())return t.clone();var i=this.m.andln(3);if(r(i%2==1),3===i){var h=this.m.add(new n(1)).iushrn(2);return this.pow(t,h)}for(var e=this.m.subn(1),o=0;!e.isZero()&&0===e.andln(1);)o++,e.iushrn(1);r(!e.isZero());var s=new n(1).toRed(this),u=s.redNeg(),a=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,a).cmp(u);)l.redIAdd(u);for(var m=this.pow(l,e),f=this.pow(t,e.addn(1).iushrn(1)),d=this.pow(t,e),p=o;0!==d.cmp(s);){for(var M=d,v=0;0!==M.cmp(s);v++)M=M.redSqr();r(v=0;h--){for(var a=i.words[h],l=u-1;l>=0;l--){var m=a>>l&1;e!==r[0]&&(e=this.sqr(e)),0!==m||0!==o?(o<<=1,o|=m,(4===++s||0===h&&0===l)&&(e=this.mul(e,r[o]),s=0,o=0)):s=0}u=26}return e},g.prototype.convertTo=function(t){var i=t.umod(this.m);return i===t?i.clone():i},g.prototype.convertFrom=function(t){var i=t.clone();return i.red=null,i},n.mont=function(t){return new c(t)},h(c,g),c.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},c.prototype.convertFrom=function(t){var i=this.imod(t.mul(this.rinv));return i.red=null,i},c.prototype.imul=function(t,i){if(t.isZero()||i.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(i),h=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(h).iushrn(this.shift),e=n;return n.cmp(this.m)>=0?e=n.isub(this.m):n.cmpn(0)<0&&(e=n.iadd(this.m)),e._forceRed(this)},c.prototype.mul=function(t,i){if(t.isZero()||i.isZero())return new n(0)._forceRed(this);var r=t.mul(i),h=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),e=r.isub(h).iushrn(this.shift),o=e;return e.cmp(this.m)>=0?o=e.isub(this.m):e.cmpn(0)<0&&(o=e.iadd(this.m)),o._forceRed(this)},c.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}("undefined"==typeof module||module,this); + +},{"buffer":6}],5:[function(require,module,exports){ +function Rand(t){this.rand=t}var r;if(module.exports=function(t){return r||(r=new Rand(null)),r.generate(t)},module.exports.Rand=Rand,Rand.prototype.generate=function(t){return this._rand(t)},Rand.prototype._rand=function(t){if(this.rand.getBytes)return this.rand.getBytes(t);for(var r=new Uint8Array(t),e=0;eK_MAX_LENGTH)throw new RangeError("Invalid typed array length");var t=new Uint8Array(e);return t.__proto__=Buffer.prototype,t}function Buffer(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return allocUnsafe(e)}return from(e,t,r)}function from(e,t,r){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return isArrayBuffer(e)?fromArrayBuffer(e,t,r):"string"==typeof e?fromString(e,t):fromObject(e)}function assertSize(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function alloc(e,t,r){return assertSize(e),e<=0?createBuffer(e):void 0!==t?"string"==typeof r?createBuffer(e).fill(t,r):createBuffer(e).fill(t):createBuffer(e)}function allocUnsafe(e){return assertSize(e),createBuffer(e<0?0:0|checked(e))}function fromString(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!Buffer.isEncoding(t))throw new TypeError('"encoding" must be a valid string encoding');var r=0|byteLength(e,t),n=createBuffer(r),f=n.write(e,t);return f!==r&&(n=n.slice(0,f)),n}function fromArrayLike(e){for(var t=e.length<0?0:0|checked(e.length),r=createBuffer(t),n=0;n=K_MAX_LENGTH)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+K_MAX_LENGTH.toString(16)+" bytes");return 0|e}function SlowBuffer(e){return+e!=e&&(e=0),Buffer.alloc(+e)}function byteLength(e,t){if(Buffer.isBuffer(e))return e.length;if(isArrayBufferView(e)||isArrayBuffer(e))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return utf8ToBytes(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return base64ToBytes(e).length;default:if(n)return utf8ToBytes(e).length;t=(""+t).toLowerCase(),n=!0}}function slowToString(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if(r>>>=0,t>>>=0,r<=t)return"";for(e||(e="utf8");;)switch(e){case"hex":return hexSlice(this,t,r);case"utf8":case"utf-8":return utf8Slice(this,t,r);case"ascii":return asciiSlice(this,t,r);case"latin1":case"binary":return latin1Slice(this,t,r);case"base64":return base64Slice(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function swap(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function bidirectionalIndexOf(e,t,r,n,f){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,numberIsNaN(r)&&(r=f?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(f)return-1;r=e.length-1}else if(r<0){if(!f)return-1;r=0}if("string"==typeof t&&(t=Buffer.from(t,n)),Buffer.isBuffer(t))return 0===t.length?-1:arrayIndexOf(e,t,r,n,f);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?f?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):arrayIndexOf(e,[t],r,n,f);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(e,t,r,n,f){function i(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}var o=1,u=e.length,s=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;o=2,u/=2,s/=2,r/=2}var a;if(f){var h=-1;for(a=r;au&&(r=u-s),a=r;a>=0;a--){for(var c=!0,l=0;lf&&(n=f):n=f;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var o=0;o239?4:i>223?3:i>191?2:1;if(f+u<=r){var s,a,h,c;switch(u){case 1:i<128&&(o=i);break;case 2:128==(192&(s=e[f+1]))&&(c=(31&i)<<6|63&s)>127&&(o=c);break;case 3:s=e[f+1],a=e[f+2],128==(192&s)&&128==(192&a)&&(c=(15&i)<<12|(63&s)<<6|63&a)>2047&&(c<55296||c>57343)&&(o=c);break;case 4:s=e[f+1],a=e[f+2],h=e[f+3],128==(192&s)&&128==(192&a)&&128==(192&h)&&(c=(15&i)<<18|(63&s)<<12|(63&a)<<6|63&h)>65535&&c<1114112&&(o=c)}}null===o?(o=65533,u=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),f+=u}return decodeCodePointsArray(n)}function decodeCodePointsArray(e){var t=e.length;if(t<=MAX_ARGUMENTS_LENGTH)return String.fromCharCode.apply(String,e);for(var r="",n=0;nn)&&(r=n);for(var f="",i=t;ir)throw new RangeError("Trying to access beyond buffer length")}function checkInt(e,t,r,n,f,i){if(!Buffer.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>f||te.length)throw new RangeError("Index out of range")}function checkIEEE754(e,t,r,n,f,i){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function writeFloat(e,t,r,n,f){return t=+t,r>>>=0,f||checkIEEE754(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38),ieee754.write(e,t,r,n,23,4),r+4}function writeDouble(e,t,r,n,f){return t=+t,r>>>=0,f||checkIEEE754(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308),ieee754.write(e,t,r,n,52,8),r+8}function base64clean(e){if((e=e.trim().replace(INVALID_BASE64_RE,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}function toHex(e){return e<16?"0"+e.toString(16):e.toString(16)}function utf8ToBytes(e,t){t=t||1/0;for(var r,n=e.length,f=null,i=[],o=0;o55295&&r<57344){if(!f){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(o+1===n){(t-=3)>-1&&i.push(239,191,189);continue}f=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),f=r;continue}r=65536+(f-55296<<10|r-56320)}else f&&(t-=3)>-1&&i.push(239,191,189);if(f=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function asciiToBytes(e){for(var t=[],r=0;r>8,f=r%256,i.push(f),i.push(n);return i}function base64ToBytes(e){return base64.toByteArray(base64clean(e))}function blitBuffer(e,t,r,n){for(var f=0;f=t.length||f>=e.length);++f)t[f+r]=e[f];return f}function isArrayBuffer(e){return e instanceof ArrayBuffer||null!=e&&null!=e.constructor&&"ArrayBuffer"===e.constructor.name&&"number"==typeof e.byteLength}function isArrayBufferView(e){return"function"==typeof ArrayBuffer.isView&&ArrayBuffer.isView(e)}function numberIsNaN(e){return e!==e}var base64=require("base64-js"),ieee754=require("ieee754");exports.Buffer=Buffer,exports.SlowBuffer=SlowBuffer,exports.INSPECT_MAX_BYTES=50;var K_MAX_LENGTH=2147483647;exports.kMaxLength=K_MAX_LENGTH,Buffer.TYPED_ARRAY_SUPPORT=typedArraySupport(),Buffer.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by buffer v5.x. Use buffer v4.x if you require old browser support."),"undefined"!=typeof Symbol&&Symbol.species&&Buffer[Symbol.species]===Buffer&&Object.defineProperty(Buffer,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),Buffer.poolSize=8192,Buffer.from=function(e,t,r){return from(e,t,r)},Buffer.prototype.__proto__=Uint8Array.prototype,Buffer.__proto__=Uint8Array,Buffer.alloc=function(e,t,r){return alloc(e,t,r)},Buffer.allocUnsafe=function(e){return allocUnsafe(e)},Buffer.allocUnsafeSlow=function(e){return allocUnsafe(e)},Buffer.isBuffer=function(e){return null!=e&&!0===e._isBuffer},Buffer.compare=function(e,t){if(!Buffer.isBuffer(e)||!Buffer.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,f=0,i=Math.min(r,n);f0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""},Buffer.prototype.compare=function(e,t,r,n,f){if(!Buffer.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===f&&(f=this.length),t<0||r>e.length||n<0||f>this.length)throw new RangeError("out of range index");if(n>=f&&t>=r)return 0;if(n>=f)return-1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,f>>>=0,this===e)return 0;for(var i=f-n,o=r-t,u=Math.min(i,o),s=this.slice(n,f),a=e.slice(t,r),h=0;h>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var f=this.length-t;if((void 0===r||r>f)&&(r=f),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return hexWrite(this,e,t,r);case"utf8":case"utf-8":return utf8Write(this,e,t,r);case"ascii":return asciiWrite(this,e,t,r);case"latin1":case"binary":return latin1Write(this,e,t,r);case"base64":return base64Write(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var MAX_ARGUMENTS_LENGTH=4096;Buffer.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),t<0?(t+=r)<0&&(t=0):t>r&&(t=r),t>>=0,t>>>=0,r||checkOffset(e,t,this.length);for(var n=this[e],f=1,i=0;++i>>=0,t>>>=0,r||checkOffset(e,t,this.length);for(var n=this[e+--t],f=1;t>0&&(f*=256);)n+=this[e+--t]*f;return n},Buffer.prototype.readUInt8=function(e,t){return e>>>=0,t||checkOffset(e,1,this.length),this[e]},Buffer.prototype.readUInt16LE=function(e,t){return e>>>=0,t||checkOffset(e,2,this.length),this[e]|this[e+1]<<8},Buffer.prototype.readUInt16BE=function(e,t){return e>>>=0,t||checkOffset(e,2,this.length),this[e]<<8|this[e+1]},Buffer.prototype.readUInt32LE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Buffer.prototype.readUInt32BE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Buffer.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||checkOffset(e,t,this.length);for(var n=this[e],f=1,i=0;++i=f&&(n-=Math.pow(2,8*t)),n},Buffer.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||checkOffset(e,t,this.length);for(var n=t,f=1,i=this[e+--n];n>0&&(f*=256);)i+=this[e+--n]*f;return f*=128,i>=f&&(i-=Math.pow(2,8*t)),i},Buffer.prototype.readInt8=function(e,t){return e>>>=0,t||checkOffset(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Buffer.prototype.readInt16LE=function(e,t){e>>>=0,t||checkOffset(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt16BE=function(e,t){e>>>=0,t||checkOffset(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt32LE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Buffer.prototype.readInt32BE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Buffer.prototype.readFloatLE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),ieee754.read(this,e,!0,23,4)},Buffer.prototype.readFloatBE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),ieee754.read(this,e,!1,23,4)},Buffer.prototype.readDoubleLE=function(e,t){return e>>>=0,t||checkOffset(e,8,this.length),ieee754.read(this,e,!0,52,8)},Buffer.prototype.readDoubleBE=function(e,t){return e>>>=0,t||checkOffset(e,8,this.length),ieee754.read(this,e,!1,52,8)},Buffer.prototype.writeUIntLE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||checkInt(this,e,t,r,Math.pow(2,8*r)-1,0);var f=1,i=0;for(this[t]=255&e;++i>>=0,r>>>=0,n||checkInt(this,e,t,r,Math.pow(2,8*r)-1,0);var f=r-1,i=1;for(this[t+f]=255&e;--f>=0&&(i*=256);)this[t+f]=e/i&255;return t+r},Buffer.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,1,255,0),this[t]=255&e,t+1},Buffer.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},Buffer.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var f=Math.pow(2,8*r-1);checkInt(this,e,t,r,f-1,-f)}var i=0,o=1,u=0;for(this[t]=255&e;++i>0)-u&255;return t+r},Buffer.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var f=Math.pow(2,8*r-1);checkInt(this,e,t,r,f-1,-f)}var i=r-1,o=1,u=0;for(this[t+i]=255&e;--i>=0&&(o*=256);)e<0&&0===u&&0!==this[t+i+1]&&(u=1),this[t+i]=(e/o>>0)-u&255;return t+r},Buffer.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},Buffer.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},Buffer.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeFloatLE=function(e,t,r){return writeFloat(this,e,t,!0,r)},Buffer.prototype.writeFloatBE=function(e,t,r){return writeFloat(this,e,t,!1,r)},Buffer.prototype.writeDoubleLE=function(e,t,r){return writeDouble(this,e,t,!0,r)},Buffer.prototype.writeDoubleBE=function(e,t,r){return writeDouble(this,e,t,!1,r)},Buffer.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--f)e[f+t]=this[f+r];else if(i<1e3)for(f=0;f>>=0,r=void 0===r?this.length:r>>>0,e||(e=0);var i;if("number"==typeof e)for(i=t;i>>2),n=0,i=0;n>5]|=128<<_%32,d[14+(_+64>>>9<<4)]=_;for(var m=1732584193,f=-271733879,i=-1732584194,h=271733878,g=0;g>16)+(_>>16)+(m>>16)<<16|65535&m}function bit_rol(d,_){return d<<_|d>>>32-_}var makeHash=require("./make-hash");module.exports=function(d){return makeHash(d,core_md5)}; + +},{"./make-hash":12}],14:[function(require,module,exports){ +"use strict";var elliptic=exports;elliptic.version=require("../package.json").version,elliptic.utils=require("./elliptic/utils"),elliptic.rand=require("brorand"),elliptic.curve=require("./elliptic/curve"),elliptic.curves=require("./elliptic/curves"),elliptic.ec=require("./elliptic/ec"),elliptic.eddsa=require("./elliptic/eddsa"); + +},{"../package.json":29,"./elliptic/curve":17,"./elliptic/curves":20,"./elliptic/ec":21,"./elliptic/eddsa":24,"./elliptic/utils":28,"brorand":5}],15:[function(require,module,exports){ +"use strict";function BaseCurve(t,e){this.type=t,this.p=new BN(e.p,16),this.red=e.prime?BN.red(e.prime):BN.mont(this.p),this.zero=new BN(0).toRed(this.red),this.one=new BN(1).toRed(this.red),this.two=new BN(2).toRed(this.red),this.n=e.n&&new BN(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var n=this.n&&this.p.div(this.n);!n||n.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function BasePoint(t,e){this.curve=t,this.type=e,this.precomputed=null}var BN=require("bn.js"),elliptic=require("../../elliptic"),utils=elliptic.utils,getNAF=utils.getNAF,getJSF=utils.getJSF,assert=utils.assert;module.exports=BaseCurve,BaseCurve.prototype.point=function(){throw new Error("Not implemented")},BaseCurve.prototype.validate=function(){throw new Error("Not implemented")},BaseCurve.prototype._fixedNafMul=function(t,e){assert(t.precomputed);var n=t._getDoubles(),r=getNAF(e,1),i=(1<=s;e--)a=(a<<1)+r[e];o.push(a)}for(var p=this.jpoint(null,null,null),u=this.jpoint(null,null,null),d=i;d>0;d--){for(s=0;s=0;a--){for(var e=0;a>=0&&0===o[a];a--)e++;if(a>=0&&e++,s=s.dblp(e),a<0)break;var p=o[a];assert(0!==p),s="affine"===t.type?p>0?s.mixedAdd(i[p-1>>1]):s.mixedAdd(i[-p-1>>1].neg()):p>0?s.add(i[p-1>>1]):s.add(i[-p-1>>1].neg())}return"affine"===t.type?s.toP():s},BaseCurve.prototype._wnafMulAdd=function(t,e,n,r,i){for(var o=this._wnafT1,s=this._wnafT2,a=this._wnafT3,p=0,u=0;u=1;u-=2){var l=u-1,h=u;if(1===o[l]&&1===o[h]){var f=[e[l],null,null,e[h]];0===e[l].y.cmp(e[h].y)?(f[1]=e[l].add(e[h]),f[2]=e[l].toJ().mixedAdd(e[h].neg())):0===e[l].y.cmp(e[h].y.redNeg())?(f[1]=e[l].toJ().mixedAdd(e[h]),f[2]=e[l].add(e[h].neg())):(f[1]=e[l].toJ().mixedAdd(e[h]),f[2]=e[l].toJ().mixedAdd(e[h].neg()));var c=[-3,-1,-5,-7,0,7,5,1,3],g=getJSF(n[l],n[h]);p=Math.max(g[0].length,p),a[l]=new Array(p),a[h]=new Array(p);for(b=0;b=0;u--){for(var B=0;u>=0;){for(var A=!0,b=0;b=0&&B++,y=y.dblp(B),u<0)break;for(b=0;b0?N=s[b][_-1>>1]:_<0&&(N=s[b][-_-1>>1].neg()),y="affine"===N.type?y.mixedAdd(N):y.add(N))}}for(u=0;u=Math.ceil((t.bitLength()+1)/e.step)},BasePoint.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var n=[this],r=this,i=0;i":""},Point.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&0===this.y.cmp(this.z)},Point.prototype._extDbl=function(){var t=this.x.redSqr(),r=this.y.redSqr(),e=this.z.redSqr();e=e.redIAdd(e);var i=this.curve._mulA(t),d=this.x.redAdd(this.y).redSqr().redISub(t).redISub(r),s=i.redAdd(r),u=s.redSub(e),n=i.redSub(r),h=d.redMul(u),o=s.redMul(n),l=d.redMul(n),c=u.redMul(s);return this.curve.point(h,o,c,l)},Point.prototype._projDbl=function(){var t,r,e,i=this.x.redAdd(this.y).redSqr(),d=this.x.redSqr(),s=this.y.redSqr();if(this.curve.twisted){var u=(o=this.curve._mulA(d)).redAdd(s);if(this.zOne)t=i.redSub(d).redSub(s).redMul(u.redSub(this.curve.two)),r=u.redMul(o.redSub(s)),e=u.redSqr().redSub(u).redSub(u);else{var n=this.z.redSqr(),h=u.redSub(n).redISub(n);t=i.redSub(d).redISub(s).redMul(h),r=u.redMul(o.redSub(s)),e=u.redMul(h)}}else{var o=d.redAdd(s),n=this.curve._mulC(this.c.redMul(this.z)).redSqr(),h=o.redSub(n).redSub(n);t=this.curve._mulC(i.redISub(o)).redMul(h),r=this.curve._mulC(o).redMul(d.redISub(s)),e=o.redMul(h)}return this.curve.point(t,r,e)},Point.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},Point.prototype._extAdd=function(t){var r=this.y.redSub(this.x).redMul(t.y.redSub(t.x)),e=this.y.redAdd(this.x).redMul(t.y.redAdd(t.x)),i=this.t.redMul(this.curve.dd).redMul(t.t),d=this.z.redMul(t.z.redAdd(t.z)),s=e.redSub(r),u=d.redSub(i),n=d.redAdd(i),h=e.redAdd(r),o=s.redMul(u),l=n.redMul(h),c=s.redMul(h),p=u.redMul(n);return this.curve.point(o,l,p,c)},Point.prototype._projAdd=function(t){var r,e,i=this.z.redMul(t.z),d=i.redSqr(),s=this.x.redMul(t.x),u=this.y.redMul(t.y),n=this.curve.d.redMul(s).redMul(u),h=d.redSub(n),o=d.redAdd(n),l=this.x.redAdd(this.y).redMul(t.x.redAdd(t.y)).redISub(s).redISub(u),c=i.redMul(h).redMul(l);return this.curve.twisted?(r=i.redMul(o).redMul(u.redSub(this.curve._mulA(s))),e=h.redMul(o)):(r=i.redMul(o).redMul(u.redSub(s)),e=this.curve._mulC(h).redMul(o)),this.curve.point(c,r,e)},Point.prototype.add=function(t){return this.isInfinity()?t:t.isInfinity()?this:this.curve.extended?this._extAdd(t):this._projAdd(t)},Point.prototype.mul=function(t){return this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve._wnafMul(this,t)},Point.prototype.mulAdd=function(t,r,e){return this.curve._wnafMulAdd(1,[this,r],[t,e],2,!1)},Point.prototype.jmulAdd=function(t,r,e){return this.curve._wnafMulAdd(1,[this,r],[t,e],2,!0)},Point.prototype.normalize=function(){if(this.zOne)return this;var t=this.z.redInvm();return this.x=this.x.redMul(t),this.y=this.y.redMul(t),this.t&&(this.t=this.t.redMul(t)),this.z=this.curve.one,this.zOne=!0,this},Point.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()},Point.prototype.getY=function(){return this.normalize(),this.y.fromRed()},Point.prototype.eq=function(t){return this===t||0===this.getX().cmp(t.getX())&&0===this.getY().cmp(t.getY())},Point.prototype.eqXToP=function(t){var r=t.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(r))return!0;for(var e=t.clone(),i=this.curve.redN.redMul(this.z);;){if(e.iadd(this.curve.n),e.cmp(this.curve.p)>=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}return!1},Point.prototype.toP=Point.prototype.normalize,Point.prototype.mixedAdd=Point.prototype.add; + +},{"../../elliptic":14,"../curve":17,"bn.js":4,"inherits":51}],17:[function(require,module,exports){ +"use strict";var curve=exports;curve.base=require("./base"),curve.short=require("./short"),curve.mont=require("./mont"),curve.edwards=require("./edwards"); + +},{"./base":15,"./edwards":16,"./mont":18,"./short":19}],18:[function(require,module,exports){ +"use strict";function MontCurve(t){Base.call(this,"mont",t),this.a=new BN(t.a,16).toRed(this.red),this.b=new BN(t.b,16).toRed(this.red),this.i4=new BN(4).toRed(this.red).redInvm(),this.two=new BN(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function Point(t,r,e){Base.BasePoint.call(this,t,"projective"),null===r&&null===e?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new BN(r,16),this.z=new BN(e,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}var curve=require("../curve"),BN=require("bn.js"),inherits=require("inherits"),Base=curve.base,elliptic=require("../../elliptic"),utils=elliptic.utils;inherits(MontCurve,Base),module.exports=MontCurve,MontCurve.prototype.validate=function(t){var r=t.normalize().x,e=r.redSqr(),i=e.redMul(r).redAdd(e.redMul(this.a)).redAdd(r);return 0===i.redSqrt().redSqr().cmp(i)},inherits(Point,Base.BasePoint),MontCurve.prototype.decodePoint=function(t,r){return this.point(utils.toArray(t,r),1)},MontCurve.prototype.point=function(t,r){return new Point(this,t,r)},MontCurve.prototype.pointFromJSON=function(t){return Point.fromJSON(this,t)},Point.prototype.precompute=function(){},Point.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},Point.fromJSON=function(t,r){return new Point(t,r[0],r[1]||t.one)},Point.prototype.inspect=function(){return this.isInfinity()?"":""},Point.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},Point.prototype.dbl=function(){var t=this.x.redAdd(this.z).redSqr(),r=this.x.redSub(this.z).redSqr(),e=t.redSub(r),i=t.redMul(r),o=e.redMul(r.redAdd(this.curve.a24.redMul(e)));return this.curve.point(i,o)},Point.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.diffAdd=function(t,r){var e=this.x.redAdd(this.z),i=this.x.redSub(this.z),o=t.x.redAdd(t.z),n=t.x.redSub(t.z).redMul(e),u=o.redMul(i),d=r.z.redMul(n.redAdd(u).redSqr()),s=r.x.redMul(n.redISub(u).redSqr());return this.curve.point(d,s)},Point.prototype.mul=function(t){for(var r=t.clone(),e=this,i=this.curve.point(null,null),o=this,n=[];0!==r.cmpn(0);r.iushrn(1))n.push(r.andln(1));for(var u=n.length-1;u>=0;u--)0===n[u]?(e=e.diffAdd(i,o),i=i.dbl()):(i=e.diffAdd(i,o),e=e.dbl());return i},Point.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.eq=function(t){return 0===this.getX().cmp(t.getX())},Point.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()}; + +},{"../../elliptic":14,"../curve":17,"bn.js":4,"inherits":51}],19:[function(require,module,exports){ +"use strict";function ShortCurve(r){Base.call(this,"short",r),this.a=new BN(r.a,16).toRed(this.red),this.b=new BN(r.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(r),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function Point(r,e,t,d){Base.BasePoint.call(this,r,"affine"),null===e&&null===t?(this.x=null,this.y=null,this.inf=!0):(this.x=new BN(e,16),this.y=new BN(t,16),d&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function JPoint(r,e,t,d){Base.BasePoint.call(this,r,"jacobian"),null===e&&null===t&&null===d?(this.x=this.curve.one,this.y=this.curve.one,this.z=new BN(0)):(this.x=new BN(e,16),this.y=new BN(t,16),this.z=new BN(d,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}var curve=require("../curve"),elliptic=require("../../elliptic"),BN=require("bn.js"),inherits=require("inherits"),Base=curve.base,assert=elliptic.utils.assert;inherits(ShortCurve,Base),module.exports=ShortCurve,ShortCurve.prototype._getEndomorphism=function(r){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var e,t;if(r.beta)e=new BN(r.beta,16).toRed(this.red);else{var d=this._getEndoRoots(this.p);e=(e=d[0].cmp(d[1])<0?d[0]:d[1]).toRed(this.red)}if(r.lambda)t=new BN(r.lambda,16);else{var i=this._getEndoRoots(this.n);0===this.g.mul(i[0]).x.cmp(this.g.x.redMul(e))?t=i[0]:(t=i[1],assert(0===this.g.mul(t).x.cmp(this.g.x.redMul(e))))}var n;return n=r.basis?r.basis.map(function(r){return{a:new BN(r.a,16),b:new BN(r.b,16)}}):this._getEndoBasis(t),{beta:e,lambda:t,basis:n}}},ShortCurve.prototype._getEndoRoots=function(r){var e=r===this.p?this.red:BN.mont(r),t=new BN(2).toRed(e).redInvm(),d=t.redNeg(),i=new BN(3).toRed(e).redNeg().redSqrt().redMul(t);return[d.redAdd(i).fromRed(),d.redSub(i).fromRed()]},ShortCurve.prototype._getEndoBasis=function(r){for(var e,t,d,i,n,u,s,o,h,l=this.n.ushrn(Math.floor(this.n.bitLength()/2)),p=r,a=this.n.clone(),c=new BN(1),f=new BN(0),v=new BN(0),S=new BN(1),b=0;0!==p.cmpn(0);){var I=a.div(p);o=a.sub(I.mul(p)),h=v.sub(I.mul(c));var y=S.sub(I.mul(f));if(!d&&o.cmp(l)<0)e=s.neg(),t=c,d=o.neg(),i=h;else if(d&&2==++b)break;s=o,a=p,p=o,v=c,c=h,S=f,f=y}n=o.neg(),u=h;var A=d.sqr().add(i.sqr());return n.sqr().add(u.sqr()).cmp(A)>=0&&(n=e,u=t),d.negative&&(d=d.neg(),i=i.neg()),n.negative&&(n=n.neg(),u=u.neg()),[{a:d,b:i},{a:n,b:u}]},ShortCurve.prototype._endoSplit=function(r){var e=this.endo.basis,t=e[0],d=e[1],i=d.b.mul(r).divRound(this.n),n=t.b.neg().mul(r).divRound(this.n),u=i.mul(t.a),s=n.mul(d.a),o=i.mul(t.b),h=n.mul(d.b);return{k1:r.sub(u).sub(s),k2:o.add(h).neg()}},ShortCurve.prototype.pointFromX=function(r,e){(r=new BN(r,16)).red||(r=r.toRed(this.red));var t=r.redSqr().redMul(r).redIAdd(r.redMul(this.a)).redIAdd(this.b),d=t.redSqrt();if(0!==d.redSqr().redSub(t).cmp(this.zero))throw new Error("invalid point");var i=d.fromRed().isOdd();return(e&&!i||!e&&i)&&(d=d.redNeg()),this.point(r,d)},ShortCurve.prototype.validate=function(r){if(r.inf)return!0;var e=r.x,t=r.y,d=this.a.redMul(e),i=e.redSqr().redMul(e).redIAdd(d).redIAdd(this.b);return 0===t.redSqr().redISub(i).cmpn(0)},ShortCurve.prototype._endoWnafMulAdd=function(r,e,t){for(var d=this._endoWnafT1,i=this._endoWnafT2,n=0;n":""},Point.prototype.isInfinity=function(){return this.inf},Point.prototype.add=function(r){if(this.inf)return r;if(r.inf)return this;if(this.eq(r))return this.dbl();if(this.neg().eq(r))return this.curve.point(null,null);if(0===this.x.cmp(r.x))return this.curve.point(null,null);var e=this.y.redSub(r.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(r.x).redInvm()));var t=e.redSqr().redISub(this.x).redISub(r.x),d=e.redMul(this.x.redSub(t)).redISub(this.y);return this.curve.point(t,d)},Point.prototype.dbl=function(){if(this.inf)return this;var r=this.y.redAdd(this.y);if(0===r.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,t=this.x.redSqr(),d=r.redInvm(),i=t.redAdd(t).redIAdd(t).redIAdd(e).redMul(d),n=i.redSqr().redISub(this.x.redAdd(this.x)),u=i.redMul(this.x.redSub(n)).redISub(this.y);return this.curve.point(n,u)},Point.prototype.getX=function(){return this.x.fromRed()},Point.prototype.getY=function(){return this.y.fromRed()},Point.prototype.mul=function(r){return r=new BN(r,16),this._hasDoubles(r)?this.curve._fixedNafMul(this,r):this.curve.endo?this.curve._endoWnafMulAdd([this],[r]):this.curve._wnafMul(this,r)},Point.prototype.mulAdd=function(r,e,t){var d=[this,e],i=[r,t];return this.curve.endo?this.curve._endoWnafMulAdd(d,i):this.curve._wnafMulAdd(1,d,i,2)},Point.prototype.jmulAdd=function(r,e,t){var d=[this,e],i=[r,t];return this.curve.endo?this.curve._endoWnafMulAdd(d,i,!0):this.curve._wnafMulAdd(1,d,i,2,!0)},Point.prototype.eq=function(r){return this===r||this.inf===r.inf&&(this.inf||0===this.x.cmp(r.x)&&0===this.y.cmp(r.y))},Point.prototype.neg=function(r){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(r&&this.precomputed){var t=this.precomputed,d=function(r){return r.neg()};e.precomputed={naf:t.naf&&{wnd:t.naf.wnd,points:t.naf.points.map(d)},doubles:t.doubles&&{step:t.doubles.step,points:t.doubles.points.map(d)}}}return e},Point.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},inherits(JPoint,Base.BasePoint),ShortCurve.prototype.jpoint=function(r,e,t){return new JPoint(this,r,e,t)},JPoint.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var r=this.z.redInvm(),e=r.redSqr(),t=this.x.redMul(e),d=this.y.redMul(e).redMul(r);return this.curve.point(t,d)},JPoint.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},JPoint.prototype.add=function(r){if(this.isInfinity())return r;if(r.isInfinity())return this;var e=r.z.redSqr(),t=this.z.redSqr(),d=this.x.redMul(e),i=r.x.redMul(t),n=this.y.redMul(e.redMul(r.z)),u=r.y.redMul(t.redMul(this.z)),s=d.redSub(i),o=n.redSub(u);if(0===s.cmpn(0))return 0!==o.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h=s.redSqr(),l=h.redMul(s),p=d.redMul(h),a=o.redSqr().redIAdd(l).redISub(p).redISub(p),c=o.redMul(p.redISub(a)).redISub(n.redMul(l)),f=this.z.redMul(r.z).redMul(s);return this.curve.jpoint(a,c,f)},JPoint.prototype.mixedAdd=function(r){if(this.isInfinity())return r.toJ();if(r.isInfinity())return this;var e=this.z.redSqr(),t=this.x,d=r.x.redMul(e),i=this.y,n=r.y.redMul(e).redMul(this.z),u=t.redSub(d),s=i.redSub(n);if(0===u.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var o=u.redSqr(),h=o.redMul(u),l=t.redMul(o),p=s.redSqr().redIAdd(h).redISub(l).redISub(l),a=s.redMul(l.redISub(p)).redISub(i.redMul(h)),c=this.z.redMul(u);return this.curve.jpoint(p,a,c)},JPoint.prototype.dblp=function(r){if(0===r)return this;if(this.isInfinity())return this;if(!r)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var e=this,t=0;t=0)return!1;if(t.redIAdd(i),0===this.x.cmp(t))return!0}return!1},JPoint.prototype.inspect=function(){return this.isInfinity()?"":""},JPoint.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}; + +},{"../../elliptic":14,"../curve":17,"bn.js":4,"inherits":51}],20:[function(require,module,exports){ +"use strict";function PresetCurve(f){"short"===f.type?this.curve=new elliptic.curve.short(f):"edwards"===f.type?this.curve=new elliptic.curve.edwards(f):this.curve=new elliptic.curve.mont(f),this.g=this.curve.g,this.n=this.curve.n,this.hash=f.hash,assert(this.g.validate(),"Invalid curve"),assert(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function defineCurve(f,e){Object.defineProperty(curves,f,{configurable:!0,enumerable:!0,get:function(){var a=new PresetCurve(e);return Object.defineProperty(curves,f,{configurable:!0,enumerable:!0,value:a}),a}})}var curves=exports,hash=require("hash.js"),elliptic=require("../elliptic"),assert=elliptic.utils.assert;curves.PresetCurve=PresetCurve,defineCurve("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:hash.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),defineCurve("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:hash.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),defineCurve("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:hash.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),defineCurve("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:hash.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),defineCurve("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:hash.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),defineCurve("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:hash.sha256,gRed:!1,g:["9"]}),defineCurve("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:hash.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var pre;try{pre=require("./precomputed/secp256k1")}catch(f){pre=void 0}defineCurve("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:hash.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",pre]}); + +},{"../elliptic":14,"./precomputed/secp256k1":27,"hash.js":37}],21:[function(require,module,exports){ +"use strict";function EC(e){if(!(this instanceof EC))return new EC(e);"string"==typeof e&&(assert(elliptic.curves.hasOwnProperty(e),"Unknown curve "+e),e=elliptic.curves[e]),e instanceof elliptic.curves.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}var BN=require("bn.js"),HmacDRBG=require("hmac-drbg"),elliptic=require("../../elliptic"),utils=elliptic.utils,assert=utils.assert,KeyPair=require("./key"),Signature=require("./signature");module.exports=EC,EC.prototype.keyPair=function(e){return new KeyPair(this,e)},EC.prototype.keyFromPrivate=function(e,t){return KeyPair.fromPrivate(this,e,t)},EC.prototype.keyFromPublic=function(e,t){return KeyPair.fromPublic(this,e,t)},EC.prototype.genKeyPair=function(e){e||(e={});for(var t=new HmacDRBG({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||elliptic.rand(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),n=this.n.sub(new BN(2));;){var i=new BN(t.generate(r));if(!(i.cmp(n)>0))return i.iaddn(1),this.keyFromPrivate(i)}},EC.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},EC.prototype.sign=function(e,t,r,n){"object"==typeof r&&(n=r,r=null),n||(n={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new BN(e,16));for(var i=this.n.byteLength(),s=t.getPrivate().toArray("be",i),u=e.toArray("be",i),o=new HmacDRBG({hash:this.hash,entropy:s,nonce:u,pers:n.pers,persEnc:n.persEnc||"utf8"}),c=this.n.sub(new BN(1)),h=0;!0;h++){var a=n.k?n.k(h):new BN(o.generate(this.n.byteLength()));if(!((a=this._truncateToN(a,!0)).cmpn(1)<=0||a.cmp(c)>=0)){var p=this.g.mul(a);if(!p.isInfinity()){var m=p.getX(),v=m.umod(this.n);if(0!==v.cmpn(0)){var y=a.invm(this.n).mul(v.mul(t.getPrivate()).iadd(e));if(0!==(y=y.umod(this.n)).cmpn(0)){var l=(p.getY().isOdd()?1:0)|(0!==m.cmp(v)?2:0);return n.canonical&&y.cmp(this.nh)>0&&(y=this.n.sub(y),l^=1),new Signature({r:v,s:y,recoveryParam:l})}}}}}},EC.prototype.verify=function(e,t,r,n){e=this._truncateToN(new BN(e,16)),r=this.keyFromPublic(r,n);var i=(t=new Signature(t,"hex")).r,s=t.s;if(i.cmpn(1)<0||i.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var u=s.invm(this.n),o=u.mul(e).umod(this.n),c=u.mul(i).umod(this.n);if(!this.curve._maxwellTrick)return!(h=this.g.mulAdd(o,r.getPublic(),c)).isInfinity()&&0===h.getX().umod(this.n).cmp(i);var h=this.g.jmulAdd(o,r.getPublic(),c);return!h.isInfinity()&&h.eqXToP(i)},EC.prototype.recoverPubKey=function(e,t,r,n){assert((3&r)===r,"The recovery param is more than two bits"),t=new Signature(t,n);var i=this.n,s=new BN(e),u=t.r,o=t.s,c=1&r,h=r>>1;if(u.cmp(this.curve.p.umod(this.curve.n))>=0&&h)throw new Error("Unable to find sencond key candinate");u=h?this.curve.pointFromX(u.add(this.curve.n),c):this.curve.pointFromX(u,c);var a=t.r.invm(i),p=i.sub(s).mul(a).umod(i),m=o.mul(a).umod(i);return this.g.mulAdd(p,u,m)},EC.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new Signature(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var s;try{s=this.recoverPubKey(e,t,i)}catch(e){continue}if(s.eq(r))return i}throw new Error("Unable to find valid recovery factor")}; + +},{"../../elliptic":14,"./key":22,"./signature":23,"bn.js":4,"hmac-drbg":49}],22:[function(require,module,exports){ +"use strict";function KeyPair(i,t){this.ec=i,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}var BN=require("bn.js"),elliptic=require("../../elliptic"),utils=elliptic.utils,assert=utils.assert;module.exports=KeyPair,KeyPair.fromPublic=function(i,t,e){return t instanceof KeyPair?t:new KeyPair(i,{pub:t,pubEnc:e})},KeyPair.fromPrivate=function(i,t,e){return t instanceof KeyPair?t:new KeyPair(i,{priv:t,privEnc:e})},KeyPair.prototype.validate=function(){var i=this.getPublic();return i.isInfinity()?{result:!1,reason:"Invalid public key"}:i.validate()?i.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},KeyPair.prototype.getPublic=function(i,t){return"string"==typeof i&&(t=i,i=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,i):this.pub},KeyPair.prototype.getPrivate=function(i){return"hex"===i?this.priv.toString(16,2):this.priv},KeyPair.prototype._importPrivate=function(i,t){this.priv=new BN(i,t||16),this.priv=this.priv.umod(this.ec.curve.n)},KeyPair.prototype._importPublic=function(i,t){if(i.x||i.y)return"mont"===this.ec.curve.type?assert(i.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||assert(i.x&&i.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(i.x,i.y));this.pub=this.ec.curve.decodePoint(i,t)},KeyPair.prototype.derive=function(i){return i.mul(this.priv).getX()},KeyPair.prototype.sign=function(i,t,e){return this.ec.sign(i,this,t,e)},KeyPair.prototype.verify=function(i,t){return this.ec.verify(i,t,this)},KeyPair.prototype.inspect=function(){return""}; + +},{"../../elliptic":14,"bn.js":4}],23:[function(require,module,exports){ +"use strict";function Signature(t,r){if(t instanceof Signature)return t;this._importDER(t,r)||(assert(t.r&&t.s,"Signature without r or s"),this.r=new BN(t.r,16),this.s=new BN(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}function Position(){this.place=0}function getLength(t,r){var e=t[r.place++];if(!(128&e))return e;for(var n=15&e,i=0,a=0,c=r.place;a>>3);for(t.push(128|e);--e;)t.push(r>>>(e<<3)&255);t.push(r)}}var BN=require("bn.js"),elliptic=require("../../elliptic"),utils=elliptic.utils,assert=utils.assert;module.exports=Signature,Signature.prototype._importDER=function(t,r){t=utils.toArray(t,r);var e=new Position;if(48!==t[e.place++])return!1;if(getLength(t,e)+e.place!==t.length)return!1;if(2!==t[e.place++])return!1;var n=getLength(t,e),i=t.slice(e.place,n+e.place);if(e.place+=n,2!==t[e.place++])return!1;var a=getLength(t,e);if(t.length!==a+e.place)return!1;var c=t.slice(e.place,a+e.place);return 0===i[0]&&128&i[1]&&(i=i.slice(1)),0===c[0]&&128&c[1]&&(c=c.slice(1)),this.r=new BN(i),this.s=new BN(c),this.recoveryParam=null,!0},Signature.prototype.toDER=function(t){var r=this.r.toArray(),e=this.s.toArray();for(128&r[0]&&(r=[0].concat(r)),128&e[0]&&(e=[0].concat(e)),r=rmPadding(r),e=rmPadding(e);!(e[0]||128&e[1]);)e=e.slice(1);var n=[2];constructLength(n,r.length),(n=n.concat(r)).push(2),constructLength(n,e.length);var i=n.concat(e),a=[48];return constructLength(a,i.length),a=a.concat(i),utils.encode(a,t)}; + +},{"../../elliptic":14,"bn.js":4}],24:[function(require,module,exports){ +"use strict";function EDDSA(t){if(assert("ed25519"===t,"only tested with ed25519 so far"),!(this instanceof EDDSA))return new EDDSA(t);var t=elliptic.curves[t].curve;this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=hash.sha512}var hash=require("hash.js"),elliptic=require("../../elliptic"),utils=elliptic.utils,assert=utils.assert,parseBytes=utils.parseBytes,KeyPair=require("./key"),Signature=require("./signature");module.exports=EDDSA,EDDSA.prototype.sign=function(t,e){t=parseBytes(t);var i=this.keyFromSecret(e),r=this.hashInt(i.messagePrefix(),t),n=this.g.mul(r),s=this.encodePoint(n),o=this.hashInt(s,i.pubBytes(),t).mul(i.priv()),u=r.add(o).umod(this.curve.n);return this.makeSignature({R:n,S:u,Rencoded:s})},EDDSA.prototype.verify=function(t,e,i){t=parseBytes(t),e=this.makeSignature(e);var r=this.keyFromPublic(i),n=this.hashInt(e.Rencoded(),r.pubBytes(),t),s=this.g.mul(e.S());return e.R().add(r.pub().mul(n)).eq(s)},EDDSA.prototype.hashInt=function(){for(var t=this.hash(),e=0;e=0;){var s;if(e.isOdd()){var u=e.andln(n-1);s=u>(n>>1)-1?(n>>1)-u:u,e.isubn(s)}else s=0;i.push(s);for(var l=0!==e.cmpn(0)&&0===e.andln(n-1)?r+1:1,o=1;o0||r.cmpn(-e)>0;){var s=t.andln(3)+n&3,u=r.andln(3)+e&3;3===s&&(s=-1),3===u&&(u=-1);var l;l=0==(1&s)?0:3!==(a=t.andln(7)+n&7)&&5!==a||2!==u?s:-s,i[0].push(l);var o;if(0==(1&u))o=0;else{var a=r.andln(7)+e&7;o=3!==a&&5!==a||2!==s?u:-u}i[1].push(o),2*n===l+1&&(n=1-n),2*e===o+1&&(e=1-e),t.iushrn(1),r.iushrn(1)}return i}function cachedProperty(t,r,i){var n="_"+r;t.prototype[r]=function(){return void 0!==this[n]?this[n]:this[n]=i.call(this)}}function parseBytes(t){return"string"==typeof t?utils.toArray(t,"hex"):t}function intFromLE(t){return new BN(t,"hex","le")}var utils=exports,BN=require("bn.js"),minAssert=require("minimalistic-assert"),minUtils=require("minimalistic-crypto-utils");utils.assert=minAssert,utils.toArray=minUtils.toArray,utils.zero2=minUtils.zero2,utils.toHex=minUtils.toHex,utils.encode=minUtils.encode,utils.getNAF=getNAF,utils.getJSF=getJSF,utils.cachedProperty=cachedProperty,utils.parseBytes=parseBytes,utils.intFromLE=intFromLE; + +},{"bn.js":4,"minimalistic-assert":63,"minimalistic-crypto-utils":64}],29:[function(require,module,exports){ +module.exports={ + "_args": [ + [ + "elliptic@6.4.0", + "/Users/hdrewes/Documents/DEV/EthereumJS/browser-builds" + ] + ], + "_from": "elliptic@6.4.0", + "_id": "elliptic@6.4.0", + "_inBundle": false, + "_integrity": "sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=", + "_location": "/elliptic", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "elliptic@6.4.0", + "name": "elliptic", + "escapedName": "elliptic", + "rawSpec": "6.4.0", + "saveSpec": null, + "fetchSpec": "6.4.0" + }, + "_requiredBy": [ + "/browserify-sign", + "/create-ecdh", + "/secp256k1" + ], + "_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz", + "_spec": "6.4.0", + "_where": "/Users/hdrewes/Documents/DEV/EthereumJS/browser-builds", + "author": { + "name": "Fedor Indutny", + "email": "fedor@indutny.com" + }, + "bugs": { + "url": "https://github.com/indutny/elliptic/issues" + }, + "dependencies": { + "bn.js": "^4.4.0", + "brorand": "^1.0.1", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.0", + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.0" + }, + "description": "EC cryptography", + "devDependencies": { + "brfs": "^1.4.3", + "coveralls": "^2.11.3", + "grunt": "^0.4.5", + "grunt-browserify": "^5.0.0", + "grunt-cli": "^1.2.0", + "grunt-contrib-connect": "^1.0.0", + "grunt-contrib-copy": "^1.0.0", + "grunt-contrib-uglify": "^1.0.1", + "grunt-mocha-istanbul": "^3.0.1", + "grunt-saucelabs": "^8.6.2", + "istanbul": "^0.4.2", + "jscs": "^2.9.0", + "jshint": "^2.6.0", + "mocha": "^2.1.0" + }, + "files": [ + "lib" + ], + "homepage": "https://github.com/indutny/elliptic", + "keywords": [ + "EC", + "Elliptic", + "curve", + "Cryptography" + ], + "license": "MIT", + "main": "lib/elliptic.js", + "name": "elliptic", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/indutny/elliptic.git" + }, + "scripts": { + "jscs": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js", + "jshint": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js", + "lint": "npm run jscs && npm run jshint", + "test": "npm run lint && npm run unit", + "unit": "istanbul test _mocha --reporter=spec test/index.js", + "version": "grunt dist && git add dist/" + }, + "version": "6.4.0" +} + +},{}],30:[function(require,module,exports){ +module.exports={ + "genesisGasLimit": { + "v": 5000, + "d": "Gas limit of the Genesis block." + }, + "genesisDifficulty": { + "v": 17179869184, + "d": "Difficulty of the Genesis block." + }, + "genesisNonce": { + "v": "0x0000000000000042", + "d": "the geneis nonce" + }, + "genesisExtraData": { + "v": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", + "d": "extra data " + }, + "genesisHash": { + "v": "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3", + "d": "genesis hash" + }, + "genesisStateRoot": { + "v": "0xd7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544", + "d": "the genesis state root" + }, + "minGasLimit": { + "v": 5000, + "d": "Minimum the gas limit may ever be." + }, + "gasLimitBoundDivisor": { + "v": 1024, + "d": "The bound divisor of the gas limit, used in update calculations." + }, + "minimumDifficulty": { + "v": 131072, + "d": "The minimum that the difficulty may ever be." + }, + "difficultyBoundDivisor": { + "v": 2048, + "d": "The bound divisor of the difficulty, used in the update calculations." + }, + "durationLimit": { + "v": 13, + "d": "The decision boundary on the blocktime duration used to determine whether difficulty should go up or not." + }, + "maximumExtraDataSize": { + "v": 32, + "d": "Maximum size extra data may be after Genesis." + }, + "epochDuration": { + "v": 30000, + "d": "Duration between proof-of-work epochs." + }, + "stackLimit": { + "v": 1024, + "d": "Maximum size of VM stack allowed." + }, + "callCreateDepth": { + "v": 1024, + "d": "Maximum depth of call/create stack." + }, + + "tierStepGas": { + "v": [0, 2, 3, 5, 8, 10, 20], + "d": "Once per operation, for a selection of them." + }, + "expGas": { + "v": 10, + "d": "Once per EXP instruction." + }, + "expByteGas": { + "v": 10, + "d": "Times ceil(log256(exponent)) for the EXP instruction." + }, + + "sha3Gas": { + "v": 30, + "d": "Once per SHA3 operation." + }, + "sha3WordGas": { + "v": 6, + "d": "Once per word of the SHA3 operation's data." + }, + "sloadGas": { + "v": 50, + "d": "Once per SLOAD operation." + }, + "sstoreSetGas": { + "v": 20000, + "d": "Once per SSTORE operation if the zeroness changes from zero." + }, + "sstoreResetGas": { + "v": 5000, + "d": "Once per SSTORE operation if the zeroness does not change from zero." + }, + "sstoreRefundGas": { + "v": 15000, + "d": "Once per SSTORE operation if the zeroness changes to zero." + }, + "jumpdestGas": { + "v": 1, + "d": "Refunded gas, once per SSTORE operation if the zeroness changes to zero." + }, + + "logGas": { + "v": 375, + "d": "Per LOG* operation." + }, + "logDataGas": { + "v": 8, + "d": "Per byte in a LOG* operation's data." + }, + "logTopicGas": { + "v": 375, + "d": "Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas." + }, + + "createGas": { + "v": 32000, + "d": "Once per CREATE operation & contract-creation transaction." + }, + + "callGas": { + "v": 40, + "d": "Once per CALL operation & message call transaction." + }, + "callStipend": { + "v": 2300, + "d": "Free gas given at beginning of call." + }, + "callValueTransferGas": { + "v": 9000, + "d": "Paid for CALL when the value transfor is non-zero." + }, + "callNewAccountGas": { + "v": 25000, + "d": "Paid for CALL when the destination address didn't exist prior." + }, + + "suicideRefundGas": { + "v": 24000, + "d": "Refunded following a suicide operation." + }, + + "memoryGas": { + "v": 3, + "d": "Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL." + }, + "quadCoeffDiv": { + "v": 512, + "d": "Divisor for the quadratic particle of the memory cost equation." + }, + + "createDataGas": { + "v": 200, + "d": "" + }, + "txGas": { + "v": 21000, + "d": "Per transaction. NOTE: Not payable on data of calls between transactions." + }, + "txCreation": { + "v": 32000, + "d": "the cost of creating a contract via tx" + }, + "txDataZeroGas": { + "v": 4, + "d": "Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions." + }, + "txDataNonZeroGas": { + "v": 68, + "d": "Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions." + }, + + "copyGas": { + "v": 3, + "d": "Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added." + }, + + "ecrecoverGas": { + "v": 3000, + "d": "" + }, + "sha256Gas": { + "v": 60, + "d": "" + }, + "sha256WordGas": { + "v": 12, + "d": "" + }, + "ripemd160Gas": { + "v": 600, + "d": "" + }, + "ripemd160WordGas": { + "v": 120, + "d": "" + }, + "identityGas": { + "v": 15, + "d": "" + }, + "identityWordGas": { + "v": 3, + "d": "" + }, + "minerReward": { + "v": "5000000000000000000", + "d": "the amount a miner get rewarded for mining a block" + }, + "ommerReward": { + "v": "625000000000000000", + "d": "The amount of wei a miner of an uncle block gets for being included in the blockchain" + }, + "niblingReward": { + "v": "156250000000000000", + "d": "the amount a miner gets for including a uncle" + }, + "homeSteadForkNumber": { + "v": 1150000, + "d": "the block that the Homestead fork started at" + }, + "homesteadRepriceForkNumber": { + "v": 2463000, + "d": "the block that the Homestead Reprice (EIP150) fork started at" + }, + "timebombPeriod": { + "v": 100000, + "d": "Exponential difficulty timebomb period" + }, + "freeBlockPeriod": { + "v": 2 + } +} + +},{}],31:[function(require,module,exports){ +(function (Buffer){ +"use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var ethUtil=require("ethereumjs-util"),fees=require("ethereum-common/params.json"),BN=ethUtil.BN,N_DIV_2=new BN("7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0",16),Transaction=function(){function e(t){_classCallCheck(this,e),t=t||{};var i=[{name:"nonce",length:32,allowLess:!0,default:new Buffer([])},{name:"gasPrice",length:32,allowLess:!0,default:new Buffer([])},{name:"gasLimit",alias:"gas",length:32,allowLess:!0,default:new Buffer([])},{name:"to",allowZero:!0,length:20,default:new Buffer([])},{name:"value",length:32,allowLess:!0,default:new Buffer([])},{name:"data",alias:"input",allowZero:!0,default:new Buffer([])},{name:"v",allowZero:!0,default:new Buffer([28])},{name:"r",length:32,allowZero:!0,allowLess:!0,default:new Buffer([])},{name:"s",length:32,allowZero:!0,allowLess:!0,default:new Buffer([])}];ethUtil.defineProperties(this,i,t),Object.defineProperty(this,"from",{enumerable:!0,configurable:!0,get:this.getSenderAddress.bind(this)});var r=ethUtil.bufferToInt(this.v),s=Math.floor((r-35)/2);s<0&&(s=0),this._chainId=s||t.chainId||0,this._homestead=!0}return e.prototype.toCreationAddress=function(){return""===this.to.toString("hex")},e.prototype.hash=function(e){void 0===e&&(e=!0);var t=void 0;if(e)t=this.raw;else if(this._chainId>0){var i=this.raw.slice();this.v=this._chainId,this.r=0,this.s=0,t=this.raw,this.raw=i}else t=this.raw.slice(0,6);return ethUtil.rlphash(t)},e.prototype.getChainId=function(){return this._chainId},e.prototype.getSenderAddress=function(){if(this._from)return this._from;var e=this.getSenderPublicKey();return this._from=ethUtil.publicToAddress(e),this._from},e.prototype.getSenderPublicKey=function(){if(!(this._senderPubKey&&this._senderPubKey.length||this.verifySignature()))throw new Error("Invalid Signature");return this._senderPubKey},e.prototype.verifySignature=function(){var e=this.hash(!1);if(this._homestead&&1===new BN(this.s).cmp(N_DIV_2))return!1;try{var t=ethUtil.bufferToInt(this.v);this._chainId>0&&(t-=2*this._chainId+8),this._senderPubKey=ethUtil.ecrecover(e,t,this.r,this.s)}catch(e){return!1}return!!this._senderPubKey},e.prototype.sign=function(e){var t=this.hash(!1),i=ethUtil.ecsign(t,e);this._chainId>0&&(i.v+=2*this._chainId+8),Object.assign(this,i)},e.prototype.getDataFee=function(){for(var e=this.raw[5],t=new BN(0),i=0;i0&&t.push(["gas limit is too low. Need at least "+this.getBaseFee()]),void 0===e||!1===e?0===t.length:t.join(" ")},e}();module.exports=Transaction; + +}).call(this,require("buffer").Buffer) +},{"buffer":8,"ethereum-common/params.json":30,"ethereumjs-util":32}],32:[function(require,module,exports){ +(function (Buffer){ +"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},createKeccakHash=require("keccak"),secp256k1=require("secp256k1"),assert=require("assert"),rlp=require("rlp"),BN=require("bn.js"),createHash=require("create-hash");Object.assign(exports,require("ethjs-util")),exports.MAX_INTEGER=new BN("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16),exports.TWO_POW256=new BN("10000000000000000000000000000000000000000000000000000000000000000",16),exports.SHA3_NULL_S="c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",exports.SHA3_NULL=Buffer.from(exports.SHA3_NULL_S,"hex"),exports.SHA3_RLP_ARRAY_S="1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",exports.SHA3_RLP_ARRAY=Buffer.from(exports.SHA3_RLP_ARRAY_S,"hex"),exports.SHA3_RLP_S="56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",exports.SHA3_RLP=Buffer.from(exports.SHA3_RLP_S,"hex"),exports.BN=BN,exports.rlp=rlp,exports.secp256k1=secp256k1,exports.zeros=function(e){return Buffer.allocUnsafe(e).fill(0)},exports.setLengthLeft=exports.setLength=function(e,r,t){var f=exports.zeros(r);return e=exports.toBuffer(e),t?e.length0&&"0"===r.toString();)r=(e=e.slice(1))[0];return e},exports.toBuffer=function(e){if(!Buffer.isBuffer(e))if(Array.isArray(e))e=Buffer.from(e);else if("string"==typeof e)e=exports.isHexString(e)?Buffer.from(exports.padToEven(exports.stripHexPrefix(e)),"hex"):Buffer.from(e);else if("number"==typeof e)e=exports.intToBuffer(e);else if(null===e||void 0===e)e=Buffer.allocUnsafe(0);else{if(!e.toArray)throw new Error("invalid type");e=Buffer.from(e.toArray())}return e},exports.bufferToInt=function(e){return new BN(exports.toBuffer(e)).toNumber()},exports.bufferToHex=function(e){return"0x"+(e=exports.toBuffer(e)).toString("hex")},exports.fromSigned=function(e){return new BN(e).fromTwos(256)},exports.toUnsigned=function(e){return Buffer.from(e.toTwos(256).toArray())},exports.sha3=function(e,r){return e=exports.toBuffer(e),r||(r=256),createKeccakHash("keccak"+r).update(e).digest()},exports.sha256=function(e){return e=exports.toBuffer(e),createHash("sha256").update(e).digest()},exports.ripemd160=function(e,r){e=exports.toBuffer(e);var t=createHash("rmd160").update(e).digest();return!0===r?exports.setLength(t,32):t},exports.rlphash=function(e){return exports.sha3(rlp.encode(e))},exports.isValidPrivate=function(e){return secp256k1.privateKeyVerify(e)},exports.isValidPublic=function(e,r){return 64===e.length?secp256k1.publicKeyVerify(Buffer.concat([Buffer.from([4]),e])):!!r&&secp256k1.publicKeyVerify(e)},exports.pubToAddress=exports.publicToAddress=function(e,r){return e=exports.toBuffer(e),r&&64!==e.length&&(e=secp256k1.publicKeyConvert(e,!1).slice(1)),assert(64===e.length),exports.sha3(e).slice(-20)};var privateToPublic=exports.privateToPublic=function(e){return e=exports.toBuffer(e),secp256k1.publicKeyCreate(e,!1).slice(1)};exports.importPublic=function(e){return 64!==(e=exports.toBuffer(e)).length&&(e=secp256k1.publicKeyConvert(e,!1).slice(1)),e},exports.ecsign=function(e,r){var t=secp256k1.sign(e,r),f={};return f.r=t.signature.slice(0,32),f.s=t.signature.slice(32,64),f.v=t.recovery+27,f},exports.hashPersonalMessage=function(e){var r=exports.toBuffer("Ethereum Signed Message:\n"+e.length.toString());return exports.sha3(Buffer.concat([r,e]))},exports.ecrecover=function(e,r,t,f){var o=Buffer.concat([exports.setLength(t,32),exports.setLength(f,32)],64),s=r-27;if(0!==s&&1!==s)throw new Error("Invalid signature v value");var n=secp256k1.recover(e,o,s);return secp256k1.publicKeyConvert(n,!1).slice(1)},exports.toRpcSig=function(e,r,t){if(27!==e&&28!==e)throw new Error("Invalid recovery id");return exports.bufferToHex(Buffer.concat([exports.setLengthLeft(r,32),exports.setLengthLeft(t,32),exports.toBuffer(e-27)]))},exports.fromRpcSig=function(e){if(65!==(e=exports.toBuffer(e)).length)throw new Error("Invalid signature length");var r=e[64];return r<27&&(r+=27),{v:r,r:e.slice(0,32),s:e.slice(32,64)}},exports.privateToAddress=function(e){return exports.publicToAddress(privateToPublic(e))},exports.isValidAddress=function(e){return/^0x[0-9a-fA-F]{40}$/i.test(e)},exports.toChecksumAddress=function(e){e=exports.stripHexPrefix(e).toLowerCase();for(var r=exports.sha3(e).toString("hex"),t="0x",f=0;f=8?t+=e[f].toUpperCase():t+=e[f];return t},exports.isValidChecksumAddress=function(e){return exports.isValidAddress(e)&&exports.toChecksumAddress(e)===e},exports.generateAddress=function(e,r){return e=exports.toBuffer(e),r=new BN(r),r=r.isZero()?null:Buffer.from(r.toArray()),exports.rlphash([e,r]).slice(-20)},exports.isPrecompiled=function(e){var r=exports.unpad(e);return 1===r.length&&r[0]>0&&r[0]<5},exports.addHexPrefix=function(e){return"string"!=typeof e?e:exports.isHexPrefixed(e)?e:"0x"+e},exports.isValidSignature=function(e,r,t,f){var o=new BN("7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0",16),s=new BN("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",16);return 32===r.length&&32===t.length&&((27===e||28===e)&&(r=new BN(r),t=new BN(t),!(r.isZero()||r.gt(s)||t.isZero()||t.gt(s))&&(!1!==f||1!==new BN(t).cmp(o))))},exports.baToJSON=function(e){if(Buffer.isBuffer(e))return"0x"+e.toString("hex");if(e instanceof Array){for(var r=[],t=0;t=f.length,"The field "+r.name+" must not have more "+r.length+" bytes")):r.allowZero&&0===f.length||!r.length||assert(r.length===f.length,"The field "+r.name+" must have byte length of "+r.length),e.raw[t]=f}e._fields.push(r.name),Object.defineProperty(e,r.name,{enumerable:!0,configurable:!0,get:f,set:o}),r.default&&(e[r.name]=r.default),r.alias&&Object.defineProperty(e,r.alias,{enumerable:!1,configurable:!0,set:o,get:f})}),t)if("string"==typeof t&&(t=Buffer.from(exports.stripHexPrefix(t),"hex")),Buffer.isBuffer(t)&&(t=rlp.decode(t)),Array.isArray(t)){if(t.length>e._fields.length)throw new Error("wrong number of fields in data");t.forEach(function(r,t){e[e._fields[t]]=exports.toBuffer(r)})}else{if("object"!==(void 0===t?"undefined":_typeof(t)))throw new Error("invalid data");var f=Object.keys(t);r.forEach(function(r){-1!==f.indexOf(r.name)&&(e[r.name]=t[r.name]),-1!==f.indexOf(r.alias)&&(e[r.alias]=t[r.alias])})}}; + +}).call(this,require("buffer").Buffer) +},{"assert":1,"bn.js":4,"buffer":8,"create-hash":11,"ethjs-util":34,"keccak":56,"rlp":81,"secp256k1":83}],33:[function(require,module,exports){ +(function (Buffer){ +const SHA3=require("keccakjs"),secp256k1=require("secp256k1"),assert=require("assert"),rlp=require("rlp"),BN=require("bn.js"),createHash=require("create-hash");exports.MAX_INTEGER=new BN("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16),exports.TWO_POW256=new BN("10000000000000000000000000000000000000000000000000000000000000000",16),exports.SHA3_NULL_S="c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",exports.SHA3_NULL=new Buffer(exports.SHA3_NULL_S,"hex"),exports.SHA3_RLP_ARRAY_S="1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",exports.SHA3_RLP_ARRAY=new Buffer(exports.SHA3_RLP_ARRAY_S,"hex"),exports.SHA3_RLP_S="56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",exports.SHA3_RLP=new Buffer(exports.SHA3_RLP_S,"hex"),exports.BN=BN,exports.rlp=rlp,exports.secp256k1=secp256k1,exports.zeros=function(e){var r=new Buffer(e);return r.fill(0),r},exports.setLengthLeft=exports.setLength=function(e,r,t){var f=exports.zeros(r);return e=exports.toBuffer(e),t?e.length0&&"0"===r.toString();)r=(e=e.slice(1))[0];return e},exports.toBuffer=function(e){if(!Buffer.isBuffer(e))if(Array.isArray(e))e=new Buffer(e);else if("string"==typeof e)e=exports.isHexPrefixed(e)?new Buffer(exports.padToEven(exports.stripHexPrefix(e)),"hex"):new Buffer(e);else if("number"==typeof e)e=exports.intToBuffer(e);else if(null===e||void 0===e)e=new Buffer([]);else{if(!e.toArray)throw new Error("invalid type");e=new Buffer(e.toArray())}return e},exports.intToHex=function(e){assert(e%1==0,"number is not a integer"),assert(e>=0,"number must be positive");var r=e.toString(16);return r.length%2&&(r="0"+r),"0x"+r},exports.intToBuffer=function(e){var r=exports.intToHex(e);return new Buffer(r.slice(2),"hex")},exports.bufferToInt=function(e){return parseInt(exports.bufferToHex(e),16)},exports.bufferToHex=function(e){return 0===(e=exports.toBuffer(e)).length?0:"0x"+e.toString("hex")},exports.fromSigned=function(e){return new BN(e).fromTwos(256)},exports.toUnsigned=function(e){return new Buffer(e.toTwos(256).toArray())},exports.sha3=function(e,r){e=exports.toBuffer(e),r||(r=256);var t=new SHA3(r);return e&&t.update(e),new Buffer(t.digest("hex"),"hex")},exports.sha256=function(e){return e=exports.toBuffer(e),createHash("sha256").update(e).digest()},exports.ripemd160=function(e,r){e=exports.toBuffer(e);var t=createHash("rmd160").update(e).digest();return!0===r?exports.setLength(t,32):t},exports.rlphash=function(e){return exports.sha3(rlp.encode(e))},exports.isValidPrivate=function(e){return secp256k1.privateKeyVerify(e)},exports.isValidPublic=function(e,r){return 64===e.length?secp256k1.publicKeyVerify(Buffer.concat([new Buffer([4]),e])):!!r&&secp256k1.publicKeyVerify(e)},exports.pubToAddress=exports.publicToAddress=function(e,r){return e=exports.toBuffer(e),r&&64!==e.length&&(e=secp256k1.publicKeyConvert(e,!1).slice(1)),assert(64===e.length),exports.sha3(e).slice(-20)};var privateToPublic=exports.privateToPublic=function(e){return e=exports.toBuffer(e),secp256k1.publicKeyCreate(e,!1).slice(1)};exports.importPublic=function(e){return 64!==(e=exports.toBuffer(e)).length&&(e=secp256k1.publicKeyConvert(e,!1).slice(1)),e},exports.ecsign=function(e,r){var t=secp256k1.sign(e,r),f={};return f.r=t.signature.slice(0,32),f.s=t.signature.slice(32,64),f.v=t.recovery+27,f},exports.ecrecover=function(e,r,t,f){var s=Buffer.concat([exports.setLength(t,32),exports.setLength(f,32)],64),o=exports.bufferToInt(r)-27;if(0!==o&&1!==o)throw new Error("Invalid signature v value");var n=secp256k1.recover(e,s,o);return secp256k1.publicKeyConvert(n,!1).slice(1)},exports.toRpcSig=function(e,r,t){return exports.bufferToHex(Buffer.concat([r,t,exports.toBuffer(e-27)]))},exports.fromRpcSig=function(e){var r=(e=exports.toBuffer(e))[64];return r<27&&(r+=27),{v:r,r:e.slice(0,32),s:e.slice(32,64)}},exports.privateToAddress=function(e){return exports.publicToAddress(privateToPublic(e))},exports.isValidAddress=function(e){return/^0x[0-9a-fA-F]{40}$/i.test(e)},exports.toChecksumAddress=function(e){e=exports.stripHexPrefix(e).toLowerCase();for(var r=exports.sha3(e).toString("hex"),t="0x",f=0;f=8?t+=e[f].toUpperCase():t+=e[f];return t},exports.isValidChecksumAddress=function(e){return exports.isValidAddress(e)&&exports.toChecksumAddress(e)===e},exports.generateAddress=function(e,r){return e=exports.toBuffer(e),r=new BN(r),r=r.isZero()?null:new Buffer(r.toArray()),exports.rlphash([e,r]).slice(-20)},exports.isPrecompiled=function(e){var r=exports.unpad(e);return 1===r.length&&r[0]>0&&r[0]<5},exports.isHexPrefixed=function(e){return"0x"===e.slice(0,2)},exports.stripHexPrefix=function(e){return"string"!=typeof e?e:exports.isHexPrefixed(e)?e.slice(2):e},exports.addHexPrefix=function(e){return"string"!=typeof e?e:exports.isHexPrefixed(e)?e:"0x"+e},exports.padToEven=function(e){return e.length%2&&(e="0"+e),e},exports.baToJSON=function(e){if(Buffer.isBuffer(e))return"0x"+e.toString("hex");if(e instanceof Array){for(var r=[],t=0;t=f.length,"The field "+r.name+" must not have more "+r.length+" bytes")):r.allowZero&&0===f.length||!r.length||assert(r.length===f.length,"The field "+r.name+" must have byte length of "+r.length),e.raw[t]=f}e._fields.push(r.name),Object.defineProperty(e,r.name,{enumerable:!0,configurable:!0,get:f,set:s}),r.default&&(e[r.name]=r.default),r.alias&&Object.defineProperty(e,r.alias,{enumerable:!1,configurable:!0,set:s,get:f})}),t)if("string"==typeof t&&(t=new Buffer(exports.stripHexPrefix(t),"hex")),Buffer.isBuffer(t)&&(t=rlp.decode(t)),Array.isArray(t)){if(t.length>e._fields.length)throw new Error("wrong number of fields in data");t.forEach(function(r,t){e[e._fields[t]]=exports.toBuffer(r)})}else{if("object"!=typeof t)throw new Error("invalid data");for(var f in t)-1!==e._fields.indexOf(f)&&(e[f]=t[f])}}; + +}).call(this,require("buffer").Buffer) +},{"assert":1,"bn.js":4,"buffer":8,"create-hash":11,"keccakjs":62,"rlp":81,"secp256k1":83}],34:[function(require,module,exports){ +(function (Buffer){ +"use strict";function padToEven(r){var e=r;if("string"!=typeof e)throw new Error("[ethjs-util] while padding to even, value must be string, is currently "+typeof e+", while padToEven.");return e.length%2&&(e="0"+e),e}function intToHex(r){return"0x"+padToEven(r.toString(16))}function intToBuffer(r){var e=intToHex(r);return new Buffer(e.slice(2),"hex")}function getBinarySize(r){if("string"!=typeof r)throw new Error("[ethjs-util] while getting binary size, method getBinarySize requires input 'str' to be type String, got '"+typeof r+"'.");return Buffer.byteLength(r,"utf8")}function arrayContainsArray(r,e,t){if(!0!==Array.isArray(r))throw new Error("[ethjs-util] method arrayContainsArray requires input 'superset' to be an array got type '"+typeof r+"'");if(!0!==Array.isArray(e))throw new Error("[ethjs-util] method arrayContainsArray requires input 'subset' to be an array got type '"+typeof e+"'");return e[Boolean(t)&&"some"||"every"](function(e){return r.indexOf(e)>=0})}function toUtf8(r){return new Buffer(padToEven(stripHexPrefix(r).replace(/^0+|0+$/g,"")),"hex").toString("utf8")}function toAscii(r){var e="",t=0,i=r.length;for("0x"===r.substring(0,2)&&(t=2);t0&&this._events[e].length>i&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},EventEmitter.prototype.on=EventEmitter.prototype.addListener,EventEmitter.prototype.once=function(e,t){function i(){this.removeListener(e,i),n||(n=!0,t.apply(this,arguments))}if(!isFunction(t))throw TypeError("listener must be a function");var n=!1;return i.listener=t,this.on(e,i),this},EventEmitter.prototype.removeListener=function(e,t){var i,n,s,r;if(!isFunction(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(i=this._events[e],s=i.length,n=-1,i===t||isFunction(i.listener)&&i.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(isObject(i)){for(r=s;r-- >0;)if(i[r]===t||i[r].listener&&i[r].listener===t){n=r;break}if(n<0)return this;1===i.length?(i.length=0,delete this._events[e]):i.splice(n,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},EventEmitter.prototype.removeAllListeners=function(e){var t,i;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(i=this._events[e],isFunction(i))this.removeListener(e,i);else if(i)for(;i.length;)this.removeListener(e,i[i.length-1]);return delete this._events[e],this},EventEmitter.prototype.listeners=function(e){return this._events&&this._events[e]?isFunction(this._events[e])?[this._events[e]]:this._events[e].slice():[]},EventEmitter.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(isFunction(t))return 1;if(t)return t.length}return 0},EventEmitter.listenerCount=function(e,t){return e.listenerCount(t)}; + +},{}],36:[function(require,module,exports){ +(function (Buffer){ +"use strict";function HashBase(t){Transform.call(this),this._block=new Buffer(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}var Transform=require("stream").Transform,inherits=require("inherits");inherits(HashBase,Transform),HashBase.prototype._transform=function(t,e,r){var s=null;try{"buffer"!==e&&(t=new Buffer(t,e)),this.update(t)}catch(t){s=t}r(s)},HashBase.prototype._flush=function(t){var e=null;try{this.push(this._digest())}catch(t){e=t}t(e)},HashBase.prototype.update=function(t,e){if(!Buffer.isBuffer(t)&&"string"!=typeof t)throw new TypeError("Data must be a string or a buffer");if(this._finalized)throw new Error("Digest already called");Buffer.isBuffer(t)||(t=new Buffer(t,e||"binary"));for(var r=this._block,s=0;this._blockOffset+t.length-s>=this._blockSize;){for(var i=this._blockOffset;i0;++o)this._length[o]+=a,(a=this._length[o]/4294967296|0)>0&&(this._length[o]-=4294967296*a);return this},HashBase.prototype._update=function(t){throw new Error("_update is not implemented")},HashBase.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();return void 0!==t&&(e=e.toString(t)),e},HashBase.prototype._digest=function(){throw new Error("_digest is not implemented")},module.exports=HashBase; + +}).call(this,require("buffer").Buffer) +},{"buffer":8,"inherits":51,"stream":97}],37:[function(require,module,exports){ +var hash=exports;hash.utils=require("./hash/utils"),hash.common=require("./hash/common"),hash.sha=require("./hash/sha"),hash.ripemd=require("./hash/ripemd"),hash.hmac=require("./hash/hmac"),hash.sha1=hash.sha.sha1,hash.sha256=hash.sha.sha256,hash.sha224=hash.sha.sha224,hash.sha384=hash.sha.sha384,hash.sha512=hash.sha.sha512,hash.ripemd160=hash.ripemd.ripemd160; + +},{"./hash/common":38,"./hash/hmac":39,"./hash/ripemd":40,"./hash/sha":41,"./hash/utils":48}],38:[function(require,module,exports){ +"use strict";function BlockHash(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}var utils=require("./utils"),assert=require("minimalistic-assert");exports.BlockHash=BlockHash,BlockHash.prototype.update=function(t,i){if(t=utils.toArray(t,i),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var n=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-n,t.length),0===this.pending.length&&(this.pending=null),t=utils.join32(t,0,t.length-n,this.endian);for(var s=0;s>>24&255,s[e++]=t>>>16&255,s[e++]=t>>>8&255,s[e++]=255&t}else for(s[e++]=255&t,s[e++]=t>>>8&255,s[e++]=t>>>16&255,s[e++]=t>>>24&255,s[e++]=0,s[e++]=0,s[e++]=0,s[e++]=0,h=8;hthis.blockSize&&(t=(new this.Hash).update(t).digest()),assert(t.length<=this.blockSize);for(var i=t.length;i>>3}function g1_256(r){return rotr32(r,17)^rotr32(r,19)^r>>>10}var utils=require("../utils"),rotr32=utils.rotr32;exports.ft_1=ft_1,exports.ch32=ch32,exports.maj32=maj32,exports.p32=p32,exports.s0_256=s0_256,exports.s1_256=s1_256,exports.g0_256=g0_256,exports.g1_256=g1_256; + +},{"../utils":48}],48:[function(require,module,exports){ +"use strict";function toArray(r,t){if(Array.isArray(r))return r.slice();if(!r)return[];var o=[];if("string"==typeof r)if(t){if("hex"===t)for((r=r.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(r="0"+r),n=0;n>8,u=255&e;s?o.push(s,u):o.push(u)}else for(n=0;n>>24|r>>>8&65280|r<<8&16711680|(255&r)<<24)>>>0}function toHex32(r,t){for(var o="",n=0;n>>0}return s}function split32(r,t){for(var o=new Array(4*r.length),n=0,e=0;n>>24,o[e+1]=s>>>16&255,o[e+2]=s>>>8&255,o[e+3]=255&s):(o[e+3]=s>>>24,o[e+2]=s>>>16&255,o[e+1]=s>>>8&255,o[e]=255&s)}return o}function rotr32(r,t){return r>>>t|r<<32-t}function rotl32(r,t){return r<>>32-t}function sum32(r,t){return r+t>>>0}function sum32_3(r,t,o){return r+t+o>>>0}function sum32_4(r,t,o,n){return r+t+o+n>>>0}function sum32_5(r,t,o,n,e){return r+t+o+n+e>>>0}function sum64(r,t,o,n){var e=r[t],s=n+r[t+1]>>>0,u=(s>>0,r[t+1]=s}function sum64_hi(r,t,o,n){return(t+n>>>0>>0}function sum64_lo(r,t,o,n){return t+n>>>0}function sum64_4_hi(r,t,o,n,e,s,u,i){var h=0,_=t;return h+=(_=_+n>>>0)>>0)>>0)>>0}function sum64_4_lo(r,t,o,n,e,s,u,i){return t+n+s+i>>>0}function sum64_5_hi(r,t,o,n,e,s,u,i,h,_){var l=0,f=t;return l+=(f=f+n>>>0)>>0)>>0)>>0)<_?1:0)>>>0}function sum64_5_lo(r,t,o,n,e,s,u,i,h,_){return t+n+s+i+_>>>0}function rotr64_hi(r,t,o){return(t<<32-o|r>>>o)>>>0}function rotr64_lo(r,t,o){return(r<<32-o|t>>>o)>>>0}function shr64_hi(r,t,o){return r>>>o}function shr64_lo(r,t,o){return(r<<32-o|t>>>o)>>>0}var assert=require("minimalistic-assert"),inherits=require("inherits");exports.inherits=inherits,exports.toArray=toArray,exports.toHex=toHex,exports.htonl=htonl,exports.toHex32=toHex32,exports.zero2=zero2,exports.zero8=zero8,exports.join32=join32,exports.split32=split32,exports.rotr32=rotr32,exports.rotl32=rotl32,exports.sum32=sum32,exports.sum32_3=sum32_3,exports.sum32_4=sum32_4,exports.sum32_5=sum32_5,exports.sum64=sum64,exports.sum64_hi=sum64_hi,exports.sum64_lo=sum64_lo,exports.sum64_4_hi=sum64_4_hi,exports.sum64_4_lo=sum64_4_lo,exports.sum64_5_hi=sum64_5_hi,exports.sum64_5_lo=sum64_5_lo,exports.rotr64_hi=rotr64_hi,exports.rotr64_lo=rotr64_lo,exports.shr64_hi=shr64_hi,exports.shr64_lo=shr64_lo; + +},{"inherits":51,"minimalistic-assert":63}],49:[function(require,module,exports){ +"use strict";function HmacDRBG(t){if(!(this instanceof HmacDRBG))return new HmacDRBG(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=utils.toArray(t.entropy,t.entropyEnc||"hex"),i=utils.toArray(t.nonce,t.nonceEnc||"hex"),s=utils.toArray(t.pers,t.persEnc||"hex");assert(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,i,s)}var hash=require("hash.js"),utils=require("minimalistic-crypto-utils"),assert=require("minimalistic-assert");module.exports=HmacDRBG,HmacDRBG.prototype._init=function(t,e,i){var s=t.concat(e).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var h=0;h=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(i||[])),this._reseed=1},HmacDRBG.prototype.generate=function(t,e,i,s){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(s=i,i=e,e=null),i&&(i=utils.toArray(i,s||"hex"),this._update(i));for(var h=[];h.length>1,i=-7,N=t?h-1:0,n=t?-1:1,s=a[o+N];for(N+=n,M=s&(1<<-i)-1,s>>=-i,i+=w;i>0;M=256*M+a[o+N],N+=n,i-=8);for(p=M&(1<<-i)-1,M>>=-i,i+=r;i>0;p=256*p+a[o+N],N+=n,i-=8);if(0===M)M=1-e;else{if(M===f)return p?NaN:1/0*(s?-1:1);p+=Math.pow(2,r),M-=e}return(s?-1:1)*p*Math.pow(2,M-r)},exports.write=function(a,o,t,r,h,M){var p,w,f,e=8*M-h-1,i=(1<>1,n=23===h?Math.pow(2,-24)-Math.pow(2,-77):0,s=r?0:M-1,u=r?1:-1,l=o<0||0===o&&1/o<0?1:0;for(o=Math.abs(o),isNaN(o)||o===1/0?(w=isNaN(o)?1:0,p=i):(p=Math.floor(Math.log(o)/Math.LN2),o*(f=Math.pow(2,-p))<1&&(p--,f*=2),(o+=p+N>=1?n/f:n*Math.pow(2,1-N))*f>=2&&(p++,f/=2),p+N>=i?(w=0,p=i):p+N>=1?(w=(o*f-1)*Math.pow(2,h),p+=N):(w=o*Math.pow(2,N-1)*Math.pow(2,h),p=0));h>=8;a[t+s]=255&w,s+=u,w/=256,h-=8);for(p=p<0;a[t+s]=255&p,s+=u,p/=256,e-=8);a[t+s-u]|=128*l}; + +},{}],51:[function(require,module,exports){ +"function"==typeof Object.create?module.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:module.exports=function(t,e){t.super_=e;var o=function(){};o.prototype=e.prototype,t.prototype=new o,t.prototype.constructor=t}; + +},{}],52:[function(require,module,exports){ +function isBuffer(f){return!!f.constructor&&"function"==typeof f.constructor.isBuffer&&f.constructor.isBuffer(f)}function isSlowBuffer(f){return"function"==typeof f.readFloatLE&&"function"==typeof f.slice&&isBuffer(f.slice(0,0))}module.exports=function(f){return null!=f&&(isBuffer(f)||isSlowBuffer(f)||!!f._isBuffer)}; + +},{}],53:[function(require,module,exports){ +module.exports=function(e){if("string"!=typeof e)throw new Error("[is-hex-prefixed] value must be type 'string', is currently type "+typeof e+", while checking isHexPrefixed.");return"0x"===e.slice(0,2)}; + +},{}],54:[function(require,module,exports){ +var toString={}.toString;module.exports=Array.isArray||function(r){return"[object Array]"==toString.call(r)}; + +},{}],55:[function(require,module,exports){ +(function (global){ +!function(r,e){"use strict";var n="undefined"!=typeof module;n&&(r=global).JS_SHA3_TEST&&(r.navigator={userAgent:"Chrome"});var t=(r.JS_SHA3_TEST||!n)&&-1!=navigator.userAgent.indexOf("Chrome"),o="0123456789abcdef".split(""),a=[1,256,65536,16777216],c=[6,1536,393216,100663296],f=[0,8,16,24],u=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],i=[],_=[],s=function(r){return v(r,224,a)},k=function(r){return v(r,256,a)},h=function(r){return v(r,384,a)},d=function(r){return v(r,224,c)},l=function(r){return v(r,256,c)},A=function(r){return v(r,384,c)},S=function(r){return v(r,512,c)},v=function(e,n,c){var s="string"!=typeof e;s&&e.constructor==r.ArrayBuffer&&(e=new Uint8Array(e)),void 0===n&&(n=512,c=a);var k,h,d,l,A,S,v,g,T,m,p,y,C,E,H,J,b,w,x,B,O,U,j,q,z,D,F,G,I,K,L,M,N,P,Q,R,V,W,X,Y,Z,$,rr,er,nr,tr,or,ar,cr,fr,ur,ir,_r,sr,kr,hr,dr,lr,Ar,Sr,vr,gr,Tr,mr,pr,yr,Cr=!1,Er=0,Hr=0,Jr=e.length,br=(1600-2*n)/32,wr=4*br;for(l=0;l<50;++l)_[l]=0;k=0;do{for(i[0]=k,l=1;l>2]|=e[Er]<>2]|=h<>2]|=(192|h>>6)<>2]|=(128|63&h)<=57344?(i[l>>2]|=(224|h>>12)<>2]|=(128|h>>6&63)<>2]|=(128|63&h)<>2]|=(240|h>>18)<>2]|=(128|h>>12&63)<>2]|=(128|h>>6&63)<>2]|=(128|63&h)<>2]|=c[3&l],++Er),k=i[br],Er>Jr&&l>>31),S=(J=_[9]^_[19]^_[29]^_[39]^_[49])^(m<<1|T>>>31),_[0]^=A,_[1]^=S,_[10]^=A,_[11]^=S,_[20]^=A,_[21]^=S,_[30]^=A,_[31]^=S,_[40]^=A,_[41]^=S,A=v^(p<<1|y>>>31),S=g^(y<<1|p>>>31),_[2]^=A,_[3]^=S,_[12]^=A,_[13]^=S,_[22]^=A,_[23]^=S,_[32]^=A,_[33]^=S,_[42]^=A,_[43]^=S,A=T^(C<<1|E>>>31),S=m^(E<<1|C>>>31),_[4]^=A,_[5]^=S,_[14]^=A,_[15]^=S,_[24]^=A,_[25]^=S,_[34]^=A,_[35]^=S,_[44]^=A,_[45]^=S,A=p^(H<<1|J>>>31),S=y^(J<<1|H>>>31),_[6]^=A,_[7]^=S,_[16]^=A,_[17]^=S,_[26]^=A,_[27]^=S,_[36]^=A,_[37]^=S,_[46]^=A,_[47]^=S,A=C^(v<<1|g>>>31),S=E^(g<<1|v>>>31),_[8]^=A,_[9]^=S,_[18]^=A,_[19]^=S,_[28]^=A,_[29]^=S,_[38]^=A,_[39]^=S,_[48]^=A,_[49]^=S,b=_[0],w=_[1],cr=_[11]<<4|_[10]>>>28,fr=_[10]<<4|_[11]>>>28,L=_[20]<<3|_[21]>>>29,M=_[21]<<3|_[20]>>>29,Tr=_[31]<<9|_[30]>>>23,mr=_[30]<<9|_[31]>>>23,nr=_[40]<<18|_[41]>>>14,tr=_[41]<<18|_[40]>>>14,V=_[2]<<1|_[3]>>>31,W=_[3]<<1|_[2]>>>31,x=_[13]<<12|_[12]>>>20,B=_[12]<<12|_[13]>>>20,ur=_[22]<<10|_[23]>>>22,ir=_[23]<<10|_[22]>>>22,N=_[33]<<13|_[32]>>>19,P=_[32]<<13|_[33]>>>19,pr=_[42]<<2|_[43]>>>30,yr=_[43]<<2|_[42]>>>30,dr=_[5]<<30|_[4]>>>2,lr=_[4]<<30|_[5]>>>2,X=_[14]<<6|_[15]>>>26,Y=_[15]<<6|_[14]>>>26,O=_[25]<<11|_[24]>>>21,U=_[24]<<11|_[25]>>>21,_r=_[34]<<15|_[35]>>>17,sr=_[35]<<15|_[34]>>>17,Q=_[45]<<29|_[44]>>>3,R=_[44]<<29|_[45]>>>3,F=_[6]<<28|_[7]>>>4,G=_[7]<<28|_[6]>>>4,Ar=_[17]<<23|_[16]>>>9,Sr=_[16]<<23|_[17]>>>9,Z=_[26]<<25|_[27]>>>7,$=_[27]<<25|_[26]>>>7,j=_[36]<<21|_[37]>>>11,q=_[37]<<21|_[36]>>>11,kr=_[47]<<24|_[46]>>>8,hr=_[46]<<24|_[47]>>>8,or=_[8]<<27|_[9]>>>5,ar=_[9]<<27|_[8]>>>5,I=_[18]<<20|_[19]>>>12,K=_[19]<<20|_[18]>>>12,vr=_[29]<<7|_[28]>>>25,gr=_[28]<<7|_[29]>>>25,rr=_[38]<<8|_[39]>>>24,er=_[39]<<8|_[38]>>>24,z=_[48]<<14|_[49]>>>18,D=_[49]<<14|_[48]>>>18,_[0]=b^~x&O,_[1]=w^~B&U,_[10]=F^~I&L,_[11]=G^~K&M,_[20]=V^~X&Z,_[21]=W^~Y&$,_[30]=or^~cr&ur,_[31]=ar^~fr&ir,_[40]=dr^~Ar&vr,_[41]=lr^~Sr&gr,_[2]=x^~O&j,_[3]=B^~U&q,_[12]=I^~L&N,_[13]=K^~M&P,_[22]=X^~Z&rr,_[23]=Y^~$&er,_[32]=cr^~ur&_r,_[33]=fr^~ir&sr,_[42]=Ar^~vr&Tr,_[43]=Sr^~gr&mr,_[4]=O^~j&z,_[5]=U^~q&D,_[14]=L^~N&Q,_[15]=M^~P&R,_[24]=Z^~rr&nr,_[25]=$^~er&tr,_[34]=ur^~_r&kr,_[35]=ir^~sr&hr,_[44]=vr^~Tr&pr,_[45]=gr^~mr&yr,_[6]=j^~z&b,_[7]=q^~D&w,_[16]=N^~Q&F,_[17]=P^~R&G,_[26]=rr^~nr&V,_[27]=er^~tr&W,_[36]=_r^~kr&or,_[37]=sr^~hr&ar,_[46]=Tr^~pr&dr,_[47]=mr^~yr&lr,_[8]=z^~b&x,_[9]=D^~w&B,_[18]=Q^~F&I,_[19]=R^~G&K,_[28]=nr^~V&X,_[29]=tr^~W&Y,_[38]=kr^~or&cr,_[39]=hr^~ar&fr,_[48]=pr^~dr&Ar,_[49]=yr^~lr&Sr,_[0]^=u[d],_[1]^=u[d+1]}while(!Cr);var xr="";if(t)b=_[0],w=_[1],x=_[2],B=_[3],O=_[4],U=_[5],j=_[6],q=_[7],z=_[8],D=_[9],F=_[10],G=_[11],I=_[12],K=_[13],L=_[14],M=_[15],xr+=o[b>>4&15]+o[15&b]+o[b>>12&15]+o[b>>8&15]+o[b>>20&15]+o[b>>16&15]+o[b>>28&15]+o[b>>24&15]+o[w>>4&15]+o[15&w]+o[w>>12&15]+o[w>>8&15]+o[w>>20&15]+o[w>>16&15]+o[w>>28&15]+o[w>>24&15]+o[x>>4&15]+o[15&x]+o[x>>12&15]+o[x>>8&15]+o[x>>20&15]+o[x>>16&15]+o[x>>28&15]+o[x>>24&15]+o[B>>4&15]+o[15&B]+o[B>>12&15]+o[B>>8&15]+o[B>>20&15]+o[B>>16&15]+o[B>>28&15]+o[B>>24&15]+o[O>>4&15]+o[15&O]+o[O>>12&15]+o[O>>8&15]+o[O>>20&15]+o[O>>16&15]+o[O>>28&15]+o[O>>24&15]+o[U>>4&15]+o[15&U]+o[U>>12&15]+o[U>>8&15]+o[U>>20&15]+o[U>>16&15]+o[U>>28&15]+o[U>>24&15]+o[j>>4&15]+o[15&j]+o[j>>12&15]+o[j>>8&15]+o[j>>20&15]+o[j>>16&15]+o[j>>28&15]+o[j>>24&15],n>=256&&(xr+=o[q>>4&15]+o[15&q]+o[q>>12&15]+o[q>>8&15]+o[q>>20&15]+o[q>>16&15]+o[q>>28&15]+o[q>>24&15]),n>=384&&(xr+=o[z>>4&15]+o[15&z]+o[z>>12&15]+o[z>>8&15]+o[z>>20&15]+o[z>>16&15]+o[z>>28&15]+o[z>>24&15]+o[D>>4&15]+o[15&D]+o[D>>12&15]+o[D>>8&15]+o[D>>20&15]+o[D>>16&15]+o[D>>28&15]+o[D>>24&15]+o[F>>4&15]+o[15&F]+o[F>>12&15]+o[F>>8&15]+o[F>>20&15]+o[F>>16&15]+o[F>>28&15]+o[F>>24&15]+o[G>>4&15]+o[15&G]+o[G>>12&15]+o[G>>8&15]+o[G>>20&15]+o[G>>16&15]+o[G>>28&15]+o[G>>24&15]),512==n&&(xr+=o[I>>4&15]+o[15&I]+o[I>>12&15]+o[I>>8&15]+o[I>>20&15]+o[I>>16&15]+o[I>>28&15]+o[I>>24&15]+o[K>>4&15]+o[15&K]+o[K>>12&15]+o[K>>8&15]+o[K>>20&15]+o[K>>16&15]+o[K>>28&15]+o[K>>24&15]+o[L>>4&15]+o[15&L]+o[L>>12&15]+o[L>>8&15]+o[L>>20&15]+o[L>>16&15]+o[L>>28&15]+o[L>>24&15]+o[M>>4&15]+o[15&M]+o[M>>12&15]+o[M>>8&15]+o[M>>20&15]+o[M>>16&15]+o[M>>28&15]+o[M>>24&15]);else for(l=0,d=n/32;l>4&15]+o[15&A]+o[A>>12&15]+o[A>>8&15]+o[A>>20&15]+o[A>>16&15]+o[A>>28&15]+o[A>>24&15];return xr};!r.JS_SHA3_TEST&&n?module.exports={sha3_512:S,sha3_384:A,sha3_256:l,sha3_224:d,keccak_512:v,keccak_384:h,keccak_256:k,keccak_224:s}:r&&(r.sha3_512=S,r.sha3_384=A,r.sha3_256=l,r.sha3_224=d,r.keccak_512=v,r.keccak_384=h,r.keccak_256=k,r.keccak_224=s)}(this); + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],56:[function(require,module,exports){ +"use strict";module.exports=require("./lib/api")(require("./lib/keccak")); + +},{"./lib/api":57,"./lib/keccak":61}],57:[function(require,module,exports){ +"use strict";var createKeccak=require("./keccak"),createShake=require("./shake");module.exports=function(e){var r=createKeccak(e),a=createShake(e);return function(e,c){switch("string"==typeof e?e.toLowerCase():e){case"keccak224":return new r(1152,448,null,224,c);case"keccak256":return new r(1088,512,null,256,c);case"keccak384":return new r(832,768,null,384,c);case"keccak512":return new r(576,1024,null,512,c);case"sha3-224":return new r(1152,448,6,224,c);case"sha3-256":return new r(1088,512,6,256,c);case"sha3-384":return new r(832,768,6,384,c);case"sha3-512":return new r(576,1024,6,512,c);case"shake128":return new a(1344,256,31,c);case"shake256":return new a(1088,512,31,c);default:throw new Error("Invald algorithm: "+e)}}}; + +},{"./keccak":58,"./shake":59}],58:[function(require,module,exports){ +"use strict";var Buffer=require("safe-buffer").Buffer,Transform=require("stream").Transform,inherits=require("inherits");module.exports=function(t){function i(i,e,r,s,a){Transform.call(this,a),this._rate=i,this._capacity=e,this._delimitedSuffix=r,this._hashBitLength=s,this._options=a,this._state=new t,this._state.initialize(i,e),this._finalized=!1}return inherits(i,Transform),i.prototype._transform=function(t,i,e){var r=null;try{this.update(t,i)}catch(t){r=t}e(r)},i.prototype._flush=function(t){var i=null;try{this.push(this.digest())}catch(t){i=t}t(i)},i.prototype.update=function(t,i){if(!Buffer.isBuffer(t)&&"string"!=typeof t)throw new TypeError("Data must be a string or a buffer");if(this._finalized)throw new Error("Digest already called");return Buffer.isBuffer(t)||(t=Buffer.from(t,i)),this._state.absorb(t),this},i.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0,this._delimitedSuffix&&this._state.absorbLastFewBits(this._delimitedSuffix);var i=this._state.squeeze(this._hashBitLength/8);return void 0!==t&&(i=i.toString(t)),this._resetState(),i},i.prototype._resetState=function(){return this._state.initialize(this._rate,this._capacity),this},i.prototype._clone=function(){var t=new i(this._rate,this._capacity,this._delimitedSuffix,this._hashBitLength,this._options);return this._state.copy(t._state),t._finalized=this._finalized,t},i}; + +},{"inherits":51,"safe-buffer":82,"stream":97}],59:[function(require,module,exports){ +"use strict";var Buffer=require("safe-buffer").Buffer,Transform=require("stream").Transform,inherits=require("inherits");module.exports=function(t){function i(i,e,r,s){Transform.call(this,s),this._rate=i,this._capacity=e,this._delimitedSuffix=r,this._options=s,this._state=new t,this._state.initialize(i,e),this._finalized=!1}return inherits(i,Transform),i.prototype._transform=function(t,i,e){var r=null;try{this.update(t,i)}catch(t){r=t}e(r)},i.prototype._flush=function(){},i.prototype._read=function(t){this.push(this.squeeze(t))},i.prototype.update=function(t,i){if(!Buffer.isBuffer(t)&&"string"!=typeof t)throw new TypeError("Data must be a string or a buffer");if(this._finalized)throw new Error("Squeeze already called");return Buffer.isBuffer(t)||(t=Buffer.from(t,i)),this._state.absorb(t),this},i.prototype.squeeze=function(t,i){this._finalized||(this._finalized=!0,this._state.absorbLastFewBits(this._delimitedSuffix));var e=this._state.squeeze(t);return void 0!==i&&(e=e.toString(i)),e},i.prototype._resetState=function(){return this._state.initialize(this._rate,this._capacity),this},i.prototype._clone=function(){var t=new i(this._rate,this._capacity,this._delimitedSuffix,this._options);return this._state.copy(t._state),t._finalized=this._finalized,t},i}; + +},{"inherits":51,"safe-buffer":82,"stream":97}],60:[function(require,module,exports){ +"use strict";var P1600_ROUND_CONSTANTS=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648];exports.p1600=function(r){for(var N=0;N<24;++N){var a=r[0]^r[10]^r[20]^r[30]^r[40],v=r[1]^r[11]^r[21]^r[31]^r[41],O=r[2]^r[12]^r[22]^r[32]^r[42],S=r[3]^r[13]^r[23]^r[33]^r[43],T=r[4]^r[14]^r[24]^r[34]^r[44],_=r[5]^r[15]^r[25]^r[35]^r[45],t=r[6]^r[16]^r[26]^r[36]^r[46],o=r[7]^r[17]^r[27]^r[37]^r[47],s=r[8]^r[18]^r[28]^r[38]^r[48],A=r[9]^r[19]^r[29]^r[39]^r[49],C=s^(O<<1|S>>>31),D=A^(S<<1|O>>>31),P=r[0]^C,R=r[1]^D,U=r[10]^C,c=r[11]^D,e=r[20]^C,f=r[21]^D,i=r[30]^C,n=r[31]^D,p=r[40]^C,u=r[41]^D;C=a^(T<<1|_>>>31),D=v^(_<<1|T>>>31);var x=r[2]^C,b=r[3]^D,d=r[12]^C,g=r[13]^D,h=r[22]^C,j=r[23]^D,k=r[32]^C,l=r[33]^D,m=r[42]^C,q=r[43]^D;C=O^(t<<1|o>>>31),D=S^(o<<1|t>>>31);var w=r[4]^C,y=r[5]^D,z=r[14]^C,B=r[15]^D,E=r[24]^C,F=r[25]^D,G=r[34]^C,H=r[35]^D,I=r[44]^C,J=r[45]^D;C=T^(s<<1|A>>>31),D=_^(A<<1|s>>>31);var K=r[6]^C,L=r[7]^D,M=r[16]^C,Q=r[17]^D,V=r[26]^C,W=r[27]^D,X=r[36]^C,Y=r[37]^D,Z=r[46]^C,$=r[47]^D;C=t^(a<<1|v>>>31),D=o^(v<<1|a>>>31);var rr=r[8]^C,Nr=r[9]^D,ar=r[18]^C,vr=r[19]^D,Or=r[28]^C,Sr=r[29]^D,Tr=r[38]^C,_r=r[39]^D,tr=r[48]^C,or=r[49]^D,sr=P,Ar=R,Cr=c<<4|U>>>28,Dr=U<<4|c>>>28,Pr=e<<3|f>>>29,Rr=f<<3|e>>>29,Ur=n<<9|i>>>23,cr=i<<9|n>>>23,er=p<<18|u>>>14,fr=u<<18|p>>>14,ir=x<<1|b>>>31,nr=b<<1|x>>>31,pr=g<<12|d>>>20,ur=d<<12|g>>>20,xr=h<<10|j>>>22,br=j<<10|h>>>22,dr=l<<13|k>>>19,gr=k<<13|l>>>19,hr=m<<2|q>>>30,jr=q<<2|m>>>30,kr=y<<30|w>>>2,lr=w<<30|y>>>2,mr=z<<6|B>>>26,qr=B<<6|z>>>26,wr=F<<11|E>>>21,yr=E<<11|F>>>21,zr=G<<15|H>>>17,Br=H<<15|G>>>17,Er=J<<29|I>>>3,Fr=I<<29|J>>>3,Gr=K<<28|L>>>4,Hr=L<<28|K>>>4,Ir=Q<<23|M>>>9,Jr=M<<23|Q>>>9,Kr=V<<25|W>>>7,Lr=W<<25|V>>>7,Mr=X<<21|Y>>>11,Qr=Y<<21|X>>>11,Vr=$<<24|Z>>>8,Wr=Z<<24|$>>>8,Xr=rr<<27|Nr>>>5,Yr=Nr<<27|rr>>>5,Zr=ar<<20|vr>>>12,$r=vr<<20|ar>>>12,rN=Sr<<7|Or>>>25,NN=Or<<7|Sr>>>25,aN=Tr<<8|_r>>>24,vN=_r<<8|Tr>>>24,ON=tr<<14|or>>>18,SN=or<<14|tr>>>18;r[0]=sr^~pr&wr,r[1]=Ar^~ur&yr,r[10]=Gr^~Zr&Pr,r[11]=Hr^~$r&Rr,r[20]=ir^~mr&Kr,r[21]=nr^~qr&Lr,r[30]=Xr^~Cr&xr,r[31]=Yr^~Dr&br,r[40]=kr^~Ir&rN,r[41]=lr^~Jr&NN,r[2]=pr^~wr&Mr,r[3]=ur^~yr&Qr,r[12]=Zr^~Pr&dr,r[13]=$r^~Rr&gr,r[22]=mr^~Kr&aN,r[23]=qr^~Lr&vN,r[32]=Cr^~xr&zr,r[33]=Dr^~br&Br,r[42]=Ir^~rN&Ur,r[43]=Jr^~NN&cr,r[4]=wr^~Mr&ON,r[5]=yr^~Qr&SN,r[14]=Pr^~dr&Er,r[15]=Rr^~gr&Fr,r[24]=Kr^~aN&er,r[25]=Lr^~vN&fr,r[34]=xr^~zr&Vr,r[35]=br^~Br&Wr,r[44]=rN^~Ur&hr,r[45]=NN^~cr&jr,r[6]=Mr^~ON&sr,r[7]=Qr^~SN&Ar,r[16]=dr^~Er&Gr,r[17]=gr^~Fr&Hr,r[26]=aN^~er&ir,r[27]=vN^~fr&nr,r[36]=zr^~Vr&Xr,r[37]=Br^~Wr&Yr,r[46]=Ur^~hr&kr,r[47]=cr^~jr&lr,r[8]=ON^~sr&pr,r[9]=SN^~Ar&ur,r[18]=Er^~Gr&Zr,r[19]=Fr^~Hr&$r,r[28]=er^~ir&mr,r[29]=fr^~nr&qr,r[38]=Vr^~Xr&Cr,r[39]=Wr^~Yr&Dr,r[48]=hr^~kr&Ir,r[49]=jr^~lr&Jr,r[0]^=P1600_ROUND_CONSTANTS[2*N],r[1]^=P1600_ROUND_CONSTANTS[2*N+1]}}; + +},{}],61:[function(require,module,exports){ +"use strict";function Keccak(){this.state=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.blockSize=null,this.count=0,this.squeezing=!1}var Buffer=require("safe-buffer").Buffer,keccakState=require("./keccak-state-unroll");Keccak.prototype.initialize=function(t,e){for(var s=0;s<50;++s)this.state[s]=0;this.blockSize=t/8,this.count=0,this.squeezing=!1},Keccak.prototype.absorb=function(t){for(var e=0;e>>this.count%4*8&255,this.count+=1,this.count===this.blockSize&&(keccakState.p1600(this.state),this.count=0);return e},Keccak.prototype.copy=function(t){for(var e=0;e<50;++e)t.state[e]=this.state[e];t.blockSize=this.blockSize,t.count=this.count,t.squeezing=this.squeezing},module.exports=Keccak; + +},{"./keccak-state-unroll":60,"safe-buffer":82}],62:[function(require,module,exports){ +module.exports=require("browserify-sha3").SHA3Hash; + +},{"browserify-sha3":7}],63:[function(require,module,exports){ +function assert(r,e){if(!r)throw new Error(e||"Assertion failed")}module.exports=assert,assert.equal=function(r,e,s){if(r!=e)throw new Error(s||"Assertion failed: "+r+" != "+e)}; + +},{}],64:[function(require,module,exports){ +"use strict";function toArray(r,t){if(Array.isArray(r))return r.slice();if(!r)return[];var e=[];if("string"!=typeof r){for(n=0;n>8,i=255&o;u?e.push(u,i):e.push(i)}return e}function zero2(r){return 1===r.length?"0"+r:r}function toHex(r){for(var t="",e=0;e1)for(var r=1;r0?("string"==typeof t||i.objectMode||Object.getPrototypeOf(t)===Buffer.prototype||(t=_uint8ArrayToBuffer(t)),n?i.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):addChunk(e,i,t,!0):i.ended?e.emit("error",new Error("stream.push() after EOF")):(i.reading=!1,i.decoder&&!r?(t=i.decoder.write(t),i.objectMode||0!==t.length?addChunk(e,i,t,!1):maybeReadMore(e,i)):addChunk(e,i,t,!1))):n||(i.reading=!1)}return needMoreData(i)}function addChunk(e,t,r,n){t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,n?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&emitReadable(e)),maybeReadMore(e,t)}function chunkInvalid(e,t){var r;return _isUint8Array(t)||"string"==typeof t||void 0===t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk")),r}function needMoreData(e){return!e.ended&&(e.needReadable||e.length=MAX_HWM?e=MAX_HWM:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function howMuchToRead(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=computeNewHighWaterMark(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function onEofChunk(e,t){if(!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,emitReadable(e)}}function emitReadable(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(debug("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?processNextTick(emitReadable_,e):emitReadable_(e))}function emitReadable_(e){debug("emit readable"),e.emit("readable"),flow(e)}function maybeReadMore(e,t){t.readingMore||(t.readingMore=!0,processNextTick(maybeReadMore_,e,t))}function maybeReadMore_(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=fromListPartial(e,t.buffer,t.decoder),r}function fromListPartial(e,t,r){var n;return ei.length?i.length:e;if(d===i.length?a+=i:a+=i.slice(0,e),0===(e-=d)){d===i.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=i.slice(d));break}++n}return t.length-=n,a}function copyFromBuffer(e,t){var r=Buffer.allocUnsafe(e),n=t.head,a=1;for(n.data.copy(r),e-=n.data.length;n=n.next;){var i=n.data,d=e>i.length?i.length:e;if(i.copy(r,r.length-e,0,d),0===(e-=d)){d===i.length?(++a,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=i.slice(d));break}++a}return t.length-=a,r}function endReadable(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,processNextTick(endReadableNT,t,e))}function endReadableNT(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function forEach(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return debug("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?endReadable(this):emitReadable(this),null;if(0===(e=howMuchToRead(e,t))&&t.ended)return 0===t.length&&endReadable(this),null;var n=t.needReadable;debug("need readable",n),(0===t.length||t.length-e0?fromList(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&endReadable(this)),null!==a&&this.emit("data",a),a},Readable.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},Readable.prototype.pipe=function(e,t){function r(e,t){debug("onunpipe"),e===l&&t&&!1===t.hasUnpiped&&(t.hasUnpiped=!0,a())}function n(){debug("onend"),e.end()}function a(){debug("cleanup"),e.removeListener("close",o),e.removeListener("finish",u),e.removeListener("drain",p),e.removeListener("error",d),e.removeListener("unpipe",r),l.removeListener("end",n),l.removeListener("end",s),l.removeListener("data",i),c=!0,!h.awaitDrain||e._writableState&&!e._writableState.needDrain||p()}function i(t){debug("ondata"),b=!1,!1!==e.write(t)||b||((1===h.pipesCount&&h.pipes===e||h.pipesCount>1&&-1!==indexOf(h.pipes,e))&&!c&&(debug("false write response, pause",l._readableState.awaitDrain),l._readableState.awaitDrain++,b=!0),l.pause())}function d(t){debug("onerror",t),s(),e.removeListener("error",d),0===EElistenerCount(e,"error")&&e.emit("error",t)}function o(){e.removeListener("finish",u),s()}function u(){debug("onfinish"),e.removeListener("close",o),s()}function s(){debug("unpipe"),l.unpipe(e)}var l=this,h=this._readableState;switch(h.pipesCount){case 0:h.pipes=e;break;case 1:h.pipes=[h.pipes,e];break;default:h.pipes.push(e)}h.pipesCount+=1,debug("pipe count=%d opts=%j",h.pipesCount,t);var f=(!t||!1!==t.end)&&e!==process.stdout&&e!==process.stderr?n:s;h.endEmitted?processNextTick(f):l.once("end",f),e.on("unpipe",r);var p=pipeOnDrain(l);e.on("drain",p);var c=!1,b=!1;return l.on("data",i),prependListener(e,"error",d),e.once("close",o),e.once("finish",u),e.emit("pipe",l),h.flowing||(debug("pipe resume"),l.resume()),e},Readable.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,a=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1?setImmediate:processNextTick,Duplex;Writable.WritableState=WritableState;var util=require("core-util-is");util.inherits=require("inherits");var internalUtil={deprecate:require("util-deprecate")},Stream=require("./internal/streams/stream"),Buffer=require("safe-buffer").Buffer,OurUint8Array=global.Uint8Array||function(){},destroyImpl=require("./internal/streams/destroy");util.inherits(Writable,Stream),WritableState.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(WritableState.prototype,"buffer",{get:internalUtil.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}();var realHasInstance;"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(realHasInstance=Function.prototype[Symbol.hasInstance],Object.defineProperty(Writable,Symbol.hasInstance,{value:function(e){return!!realHasInstance.call(this,e)||e&&e._writableState instanceof WritableState}})):realHasInstance=function(e){return e instanceof this},Writable.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Writable.prototype.write=function(e,t,r){var i=this._writableState,n=!1,o=_isUint8Array(e)&&!i.objectMode;return o&&!Buffer.isBuffer(e)&&(e=_uint8ArrayToBuffer(e)),"function"==typeof t&&(r=t,t=null),o?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=nop),i.ended?writeAfterEnd(this,r):(o||validChunk(this,i,e,r))&&(i.pendingcb++,n=writeOrBuffer(this,i,o,e,t,r)),n},Writable.prototype.cork=function(){this._writableState.corked++},Writable.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||clearBuffer(this,e))},Writable.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Writable.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},Writable.prototype._writev=null,Writable.prototype.end=function(e,t,r){var i=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!==e&&void 0!==e&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||i.finished||endWritable(this,i,r)},Object.defineProperty(Writable.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),Writable.prototype.destroy=destroyImpl.destroy,Writable.prototype._undestroy=destroyImpl.undestroy,Writable.prototype._destroy=function(e,t){this.end(),t(e)}; + +}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"./_stream_duplex":68,"./internal/streams/destroy":74,"./internal/streams/stream":75,"_process":66,"core-util-is":10,"inherits":51,"process-nextick-args":65,"safe-buffer":82,"util-deprecate":100}],73:[function(require,module,exports){ +"use strict";function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function copyBuffer(t,e,h){t.copy(e,h)}var Buffer=require("safe-buffer").Buffer;module.exports=function(){function t(){_classCallCheck(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},t.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},t.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,h=""+e.data;e=e.next;)h+=t+e.data;return h},t.prototype.concat=function(t){if(0===this.length)return Buffer.alloc(0);if(1===this.length)return this.head.data;for(var e=Buffer.allocUnsafe(t>>>0),h=this.head,n=0;h;)copyBuffer(h.data,e,n),n+=h.data.length,h=h.next;return e},t}(); + +},{"safe-buffer":82}],74:[function(require,module,exports){ +"use strict";function destroy(t,e){var r=this,i=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;i||a?e?e(t):!t||this._writableState&&this._writableState.errorEmitted||processNextTick(emitErrorNT,this,t):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(t){!e&&t?(processNextTick(emitErrorNT,r,t),r._writableState&&(r._writableState.errorEmitted=!0)):e&&e(t)}))}function undestroy(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function emitErrorNT(t,e){t.emit("error",e)}var processNextTick=require("process-nextick-args");module.exports={destroy:destroy,undestroy:undestroy}; + +},{"process-nextick-args":65}],75:[function(require,module,exports){ +module.exports=require("events").EventEmitter; + +},{"events":35}],76:[function(require,module,exports){ +module.exports=require("./readable").PassThrough; + +},{"./readable":77}],77:[function(require,module,exports){ +exports=module.exports=require("./lib/_stream_readable.js"),exports.Stream=exports,exports.Readable=exports,exports.Writable=require("./lib/_stream_writable.js"),exports.Duplex=require("./lib/_stream_duplex.js"),exports.Transform=require("./lib/_stream_transform.js"),exports.PassThrough=require("./lib/_stream_passthrough.js"); + +},{"./lib/_stream_duplex.js":68,"./lib/_stream_passthrough.js":69,"./lib/_stream_readable.js":70,"./lib/_stream_transform.js":71,"./lib/_stream_writable.js":72}],78:[function(require,module,exports){ +module.exports=require("./readable").Transform; + +},{"./readable":77}],79:[function(require,module,exports){ +module.exports=require("./lib/_stream_writable.js"); + +},{"./lib/_stream_writable.js":72}],80:[function(require,module,exports){ +(function (Buffer){ +"use strict";function RIPEMD160(){HashBase.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function rotl(t,r){return t<>>32-r}function fn1(t,r,n,o,f,l,i,s){return rotl(t+(r^n^o)+l+i|0,s)+f|0}function fn2(t,r,n,o,f,l,i,s){return rotl(t+(r&n|~r&o)+l+i|0,s)+f|0}function fn3(t,r,n,o,f,l,i,s){return rotl(t+((r|~n)^o)+l+i|0,s)+f|0}function fn4(t,r,n,o,f,l,i,s){return rotl(t+(r&o|n&~o)+l+i|0,s)+f|0}function fn5(t,r,n,o,f,l,i,s){return rotl(t+(r^(n|~o))+l+i|0,s)+f|0}var inherits=require("inherits"),HashBase=require("hash-base");inherits(RIPEMD160,HashBase),RIPEMD160.prototype._update=function(){for(var t=new Array(16),r=0;r<16;++r)t[r]=this._block.readInt32LE(4*r);var n=this._a,o=this._b,f=this._c,l=this._d,i=this._e;i=fn1(i,n=fn1(n,o,f,l,i,t[0],0,11),o,f=rotl(f,10),l,t[1],0,14),o=fn1(o=rotl(o,10),f=fn1(f,l=fn1(l,i,n,o,f,t[2],0,15),i,n=rotl(n,10),o,t[3],0,12),l,i=rotl(i,10),n,t[4],0,5),l=fn1(l=rotl(l,10),i=fn1(i,n=fn1(n,o,f,l,i,t[5],0,8),o,f=rotl(f,10),l,t[6],0,7),n,o=rotl(o,10),f,t[7],0,9),n=fn1(n=rotl(n,10),o=fn1(o,f=fn1(f,l,i,n,o,t[8],0,11),l,i=rotl(i,10),n,t[9],0,13),f,l=rotl(l,10),i,t[10],0,14),f=fn1(f=rotl(f,10),l=fn1(l,i=fn1(i,n,o,f,l,t[11],0,15),n,o=rotl(o,10),f,t[12],0,6),i,n=rotl(n,10),o,t[13],0,7),i=fn2(i=rotl(i,10),n=fn1(n,o=fn1(o,f,l,i,n,t[14],0,9),f,l=rotl(l,10),i,t[15],0,8),o,f=rotl(f,10),l,t[7],1518500249,7),o=fn2(o=rotl(o,10),f=fn2(f,l=fn2(l,i,n,o,f,t[4],1518500249,6),i,n=rotl(n,10),o,t[13],1518500249,8),l,i=rotl(i,10),n,t[1],1518500249,13),l=fn2(l=rotl(l,10),i=fn2(i,n=fn2(n,o,f,l,i,t[10],1518500249,11),o,f=rotl(f,10),l,t[6],1518500249,9),n,o=rotl(o,10),f,t[15],1518500249,7),n=fn2(n=rotl(n,10),o=fn2(o,f=fn2(f,l,i,n,o,t[3],1518500249,15),l,i=rotl(i,10),n,t[12],1518500249,7),f,l=rotl(l,10),i,t[0],1518500249,12),f=fn2(f=rotl(f,10),l=fn2(l,i=fn2(i,n,o,f,l,t[9],1518500249,15),n,o=rotl(o,10),f,t[5],1518500249,9),i,n=rotl(n,10),o,t[2],1518500249,11),i=fn2(i=rotl(i,10),n=fn2(n,o=fn2(o,f,l,i,n,t[14],1518500249,7),f,l=rotl(l,10),i,t[11],1518500249,13),o,f=rotl(f,10),l,t[8],1518500249,12),o=fn3(o=rotl(o,10),f=fn3(f,l=fn3(l,i,n,o,f,t[3],1859775393,11),i,n=rotl(n,10),o,t[10],1859775393,13),l,i=rotl(i,10),n,t[14],1859775393,6),l=fn3(l=rotl(l,10),i=fn3(i,n=fn3(n,o,f,l,i,t[4],1859775393,7),o,f=rotl(f,10),l,t[9],1859775393,14),n,o=rotl(o,10),f,t[15],1859775393,9),n=fn3(n=rotl(n,10),o=fn3(o,f=fn3(f,l,i,n,o,t[8],1859775393,13),l,i=rotl(i,10),n,t[1],1859775393,15),f,l=rotl(l,10),i,t[2],1859775393,14),f=fn3(f=rotl(f,10),l=fn3(l,i=fn3(i,n,o,f,l,t[7],1859775393,8),n,o=rotl(o,10),f,t[0],1859775393,13),i,n=rotl(n,10),o,t[6],1859775393,6),i=fn3(i=rotl(i,10),n=fn3(n,o=fn3(o,f,l,i,n,t[13],1859775393,5),f,l=rotl(l,10),i,t[11],1859775393,12),o,f=rotl(f,10),l,t[5],1859775393,7),o=fn4(o=rotl(o,10),f=fn4(f,l=fn3(l,i,n,o,f,t[12],1859775393,5),i,n=rotl(n,10),o,t[1],2400959708,11),l,i=rotl(i,10),n,t[9],2400959708,12),l=fn4(l=rotl(l,10),i=fn4(i,n=fn4(n,o,f,l,i,t[11],2400959708,14),o,f=rotl(f,10),l,t[10],2400959708,15),n,o=rotl(o,10),f,t[0],2400959708,14),n=fn4(n=rotl(n,10),o=fn4(o,f=fn4(f,l,i,n,o,t[8],2400959708,15),l,i=rotl(i,10),n,t[12],2400959708,9),f,l=rotl(l,10),i,t[4],2400959708,8),f=fn4(f=rotl(f,10),l=fn4(l,i=fn4(i,n,o,f,l,t[13],2400959708,9),n,o=rotl(o,10),f,t[3],2400959708,14),i,n=rotl(n,10),o,t[7],2400959708,5),i=fn4(i=rotl(i,10),n=fn4(n,o=fn4(o,f,l,i,n,t[15],2400959708,6),f,l=rotl(l,10),i,t[14],2400959708,8),o,f=rotl(f,10),l,t[5],2400959708,6),o=fn5(o=rotl(o,10),f=fn4(f,l=fn4(l,i,n,o,f,t[6],2400959708,5),i,n=rotl(n,10),o,t[2],2400959708,12),l,i=rotl(i,10),n,t[4],2840853838,9),l=fn5(l=rotl(l,10),i=fn5(i,n=fn5(n,o,f,l,i,t[0],2840853838,15),o,f=rotl(f,10),l,t[5],2840853838,5),n,o=rotl(o,10),f,t[9],2840853838,11),n=fn5(n=rotl(n,10),o=fn5(o,f=fn5(f,l,i,n,o,t[7],2840853838,6),l,i=rotl(i,10),n,t[12],2840853838,8),f,l=rotl(l,10),i,t[2],2840853838,13),f=fn5(f=rotl(f,10),l=fn5(l,i=fn5(i,n,o,f,l,t[10],2840853838,12),n,o=rotl(o,10),f,t[14],2840853838,5),i,n=rotl(n,10),o,t[1],2840853838,12),i=fn5(i=rotl(i,10),n=fn5(n,o=fn5(o,f,l,i,n,t[3],2840853838,13),f,l=rotl(l,10),i,t[8],2840853838,14),o,f=rotl(f,10),l,t[11],2840853838,11),o=fn5(o=rotl(o,10),f=fn5(f,l=fn5(l,i,n,o,f,t[6],2840853838,8),i,n=rotl(n,10),o,t[15],2840853838,5),l,i=rotl(i,10),n,t[13],2840853838,6),l=rotl(l,10);var s=this._a,h=this._b,e=this._c,_=this._d,c=this._e;c=fn5(c,s=fn5(s,h,e,_,c,t[5],1352829926,8),h,e=rotl(e,10),_,t[14],1352829926,9),h=fn5(h=rotl(h,10),e=fn5(e,_=fn5(_,c,s,h,e,t[7],1352829926,9),c,s=rotl(s,10),h,t[0],1352829926,11),_,c=rotl(c,10),s,t[9],1352829926,13),_=fn5(_=rotl(_,10),c=fn5(c,s=fn5(s,h,e,_,c,t[2],1352829926,15),h,e=rotl(e,10),_,t[11],1352829926,15),s,h=rotl(h,10),e,t[4],1352829926,5),s=fn5(s=rotl(s,10),h=fn5(h,e=fn5(e,_,c,s,h,t[13],1352829926,7),_,c=rotl(c,10),s,t[6],1352829926,7),e,_=rotl(_,10),c,t[15],1352829926,8),e=fn5(e=rotl(e,10),_=fn5(_,c=fn5(c,s,h,e,_,t[8],1352829926,11),s,h=rotl(h,10),e,t[1],1352829926,14),c,s=rotl(s,10),h,t[10],1352829926,14),c=fn4(c=rotl(c,10),s=fn5(s,h=fn5(h,e,_,c,s,t[3],1352829926,12),e,_=rotl(_,10),c,t[12],1352829926,6),h,e=rotl(e,10),_,t[6],1548603684,9),h=fn4(h=rotl(h,10),e=fn4(e,_=fn4(_,c,s,h,e,t[11],1548603684,13),c,s=rotl(s,10),h,t[3],1548603684,15),_,c=rotl(c,10),s,t[7],1548603684,7),_=fn4(_=rotl(_,10),c=fn4(c,s=fn4(s,h,e,_,c,t[0],1548603684,12),h,e=rotl(e,10),_,t[13],1548603684,8),s,h=rotl(h,10),e,t[5],1548603684,9),s=fn4(s=rotl(s,10),h=fn4(h,e=fn4(e,_,c,s,h,t[10],1548603684,11),_,c=rotl(c,10),s,t[14],1548603684,7),e,_=rotl(_,10),c,t[15],1548603684,7),e=fn4(e=rotl(e,10),_=fn4(_,c=fn4(c,s,h,e,_,t[8],1548603684,12),s,h=rotl(h,10),e,t[12],1548603684,7),c,s=rotl(s,10),h,t[4],1548603684,6),c=fn4(c=rotl(c,10),s=fn4(s,h=fn4(h,e,_,c,s,t[9],1548603684,15),e,_=rotl(_,10),c,t[1],1548603684,13),h,e=rotl(e,10),_,t[2],1548603684,11),h=fn3(h=rotl(h,10),e=fn3(e,_=fn3(_,c,s,h,e,t[15],1836072691,9),c,s=rotl(s,10),h,t[5],1836072691,7),_,c=rotl(c,10),s,t[1],1836072691,15),_=fn3(_=rotl(_,10),c=fn3(c,s=fn3(s,h,e,_,c,t[3],1836072691,11),h,e=rotl(e,10),_,t[7],1836072691,8),s,h=rotl(h,10),e,t[14],1836072691,6),s=fn3(s=rotl(s,10),h=fn3(h,e=fn3(e,_,c,s,h,t[6],1836072691,6),_,c=rotl(c,10),s,t[9],1836072691,14),e,_=rotl(_,10),c,t[11],1836072691,12),e=fn3(e=rotl(e,10),_=fn3(_,c=fn3(c,s,h,e,_,t[8],1836072691,13),s,h=rotl(h,10),e,t[12],1836072691,5),c,s=rotl(s,10),h,t[2],1836072691,14),c=fn3(c=rotl(c,10),s=fn3(s,h=fn3(h,e,_,c,s,t[10],1836072691,13),e,_=rotl(_,10),c,t[0],1836072691,13),h,e=rotl(e,10),_,t[4],1836072691,7),h=fn2(h=rotl(h,10),e=fn2(e,_=fn3(_,c,s,h,e,t[13],1836072691,5),c,s=rotl(s,10),h,t[8],2053994217,15),_,c=rotl(c,10),s,t[6],2053994217,5),_=fn2(_=rotl(_,10),c=fn2(c,s=fn2(s,h,e,_,c,t[4],2053994217,8),h,e=rotl(e,10),_,t[1],2053994217,11),s,h=rotl(h,10),e,t[3],2053994217,14),s=fn2(s=rotl(s,10),h=fn2(h,e=fn2(e,_,c,s,h,t[11],2053994217,14),_,c=rotl(c,10),s,t[15],2053994217,6),e,_=rotl(_,10),c,t[0],2053994217,14),e=fn2(e=rotl(e,10),_=fn2(_,c=fn2(c,s,h,e,_,t[5],2053994217,6),s,h=rotl(h,10),e,t[12],2053994217,9),c,s=rotl(s,10),h,t[2],2053994217,12),c=fn2(c=rotl(c,10),s=fn2(s,h=fn2(h,e,_,c,s,t[13],2053994217,9),e,_=rotl(_,10),c,t[9],2053994217,12),h,e=rotl(e,10),_,t[7],2053994217,5),h=fn1(h=rotl(h,10),e=fn2(e,_=fn2(_,c,s,h,e,t[10],2053994217,15),c,s=rotl(s,10),h,t[14],2053994217,8),_,c=rotl(c,10),s,t[12],0,8),_=fn1(_=rotl(_,10),c=fn1(c,s=fn1(s,h,e,_,c,t[15],0,5),h,e=rotl(e,10),_,t[10],0,12),s,h=rotl(h,10),e,t[4],0,9),s=fn1(s=rotl(s,10),h=fn1(h,e=fn1(e,_,c,s,h,t[1],0,12),_,c=rotl(c,10),s,t[5],0,5),e,_=rotl(_,10),c,t[8],0,14),e=fn1(e=rotl(e,10),_=fn1(_,c=fn1(c,s,h,e,_,t[7],0,6),s,h=rotl(h,10),e,t[6],0,8),c,s=rotl(s,10),h,t[2],0,13),c=fn1(c=rotl(c,10),s=fn1(s,h=fn1(h,e,_,c,s,t[13],0,6),e,_=rotl(_,10),c,t[14],0,5),h,e=rotl(e,10),_,t[0],0,15),h=fn1(h=rotl(h,10),e=fn1(e,_=fn1(_,c,s,h,e,t[3],0,13),c,s=rotl(s,10),h,t[9],0,11),_,c=rotl(c,10),s,t[11],0,11),_=rotl(_,10);var a=this._b+f+_|0;this._b=this._c+l+c|0,this._c=this._d+i+s|0,this._d=this._e+n+h|0,this._e=this._a+o+e|0,this._a=a},RIPEMD160.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=new Buffer(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t},module.exports=RIPEMD160; + +}).call(this,require("buffer").Buffer) +},{"buffer":8,"hash-base":36,"inherits":51}],81:[function(require,module,exports){ +(function (Buffer){ +function safeParseInt(e,r){if("00"===e.slice(0,2))throw new Error("invalid RLP: extra zeros");return parseInt(e,r)}function encodeLength(e,r){if(e<56)return new Buffer([e+r]);var n=intToHex(e),t=intToHex(r+55+n.length/2);return new Buffer(t+n,"hex")}function _decode(e){var r,n,t,i,f,a=[],o=e[0];if(o<=127)return{data:e.slice(0,1),remainder:e.slice(1)};if(o<=183){if(r=o-127,t=128===o?new Buffer([]):e.slice(1,r),2===r&&t[0]<128)throw new Error("invalid rlp encoding: byte must be less 0x80");return{data:t,remainder:e.slice(r)}}if(o<=191){if(n=o-182,r=safeParseInt(e.slice(1,n).toString("hex"),16),(t=e.slice(n,r+n)).lengthe.length)throw new Error("invalid rlp: total length is larger than the data");if(0===(i=e.slice(n,u)).length)throw new Error("invalid rlp, List has a invalid length");for(;i.length;)f=_decode(i),a.push(f.data),i=f.remainder;return{data:a,remainder:e.slice(u)}}function isHexPrefixed(e){return"0x"===e.slice(0,2)}function stripHexPrefix(e){return"string"!=typeof e?e:isHexPrefixed(e)?e.slice(2):e}function intToHex(e){var r=e.toString(16);return r.length%2&&(r="0"+r),r}function padToEven(e){return e.length%2&&(e="0"+e),e}function intToBuffer(e){var r=intToHex(e);return new Buffer(r,"hex")}function toBuffer(e){if(!Buffer.isBuffer(e))if("string"==typeof e)e=isHexPrefixed(e)?new Buffer(padToEven(stripHexPrefix(e)),"hex"):new Buffer(e);else if("number"==typeof e)e=e?intToBuffer(e):new Buffer([]);else if(null===e||void 0===e)e=new Buffer([]);else{if(!e.toArray)throw new Error("invalid type");e=new Buffer(e.toArray())}return e}const assert=require("assert");exports.encode=function(e){if(e instanceof Array){for(var r=[],n=0;n=o)throw RangeError(e)}; + +}).call(this,{"isBuffer":require("../../is-buffer/index.js")}) +},{"../../is-buffer/index.js":52}],85:[function(require,module,exports){ +"use strict";var Buffer=require("safe-buffer").Buffer,bip66=require("bip66"),EC_PRIVKEY_EXPORT_DER_COMPRESSED=Buffer.from([48,129,211,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,133,48,129,130,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,33,2,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,36,3,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),EC_PRIVKEY_EXPORT_DER_UNCOMPRESSED=Buffer.from([48,130,1,19,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,165,48,129,162,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,65,4,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,72,58,218,119,38,163,196,101,93,164,251,252,14,17,8,168,253,23,180,72,166,133,84,25,156,71,208,143,251,16,212,184,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,68,3,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),ZERO_BUFFER_32=Buffer.from([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);exports.privateKeyExport=function(r,f,e){var o=Buffer.from(e?EC_PRIVKEY_EXPORT_DER_COMPRESSED:EC_PRIVKEY_EXPORT_DER_UNCOMPRESSED);return r.copy(o,e?8:9),f.copy(o,e?181:214),o},exports.privateKeyImport=function(r){var f=r.length,e=0;if(!(f2||f1?r[e+o-2]<<8:0);if(e+=o,!(f32||f1&&0===f[o]&&!(128&f[o+1]);--e,++o);for(var t=Buffer.concat([Buffer.from([0]),r.s]),i=33,n=0;i>1&&0===t[n]&&!(128&t[n+1]);--i,++n);return bip66.encode(f.slice(o),t.slice(n))},exports.signatureImport=function(r){var f=Buffer.from(ZERO_BUFFER_32),e=Buffer.from(ZERO_BUFFER_32);try{var o=bip66.decode(r);if(33===o.r.length&&0===o.r[0]&&(o.r=o.r.slice(1)),o.r.length>32)throw new Error("R length is too long");if(33===o.s.length&&0===o.s[0]&&(o.s=o.s.slice(1)),o.s.length>32)throw new Error("S length is too long")}catch(r){return}return o.r.copy(f,32-o.r.length),o.s.copy(e,32-o.s.length),{r:f,s:e}},exports.signatureImportLax=function(r){var f=Buffer.from(ZERO_BUFFER_32),e=Buffer.from(ZERO_BUFFER_32),o=r.length,t=0;if(48===r[t++]){var i=r[t++];if(!(128&i&&(t+=i-128)>o)&&2===r[t++]){var n=r[t++];if(128&n){if(i=n-128,t+i>o)return;for(;i>0&&0===r[t];t+=1,i-=1);for(n=0;i>0;t+=1,i-=1)n=(n<<8)+r[t]}if(!(n>o-t)){var E=t;if(t+=n,2===r[t++]){var u=r[t++];if(128&u){if(i=u-128,t+i>o)return;for(;i>0&&0===r[t];t+=1,i-=1);for(u=0;i>0;t+=1,i-=1)u=(u<<8)+r[t]}if(!(u>o-t)){var s=t;for(t+=u;n>0&&0===r[E];n-=1,E+=1);if(!(n>32)){var a=r.slice(E,E+n);for(a.copy(f,32-a.length);u>0&&0===r[s];u-=1,s+=1);if(!(u>32)){var c=r.slice(s,s+u);return c.copy(e,32-c.length),{r:f,s:e}}}}}}}}}; + +},{"bip66":3,"safe-buffer":82}],86:[function(require,module,exports){ +"use strict";function loadCompressedPublicKey(e,r){var n=new BN(r);if(n.cmp(ecparams.p)>=0)return null;var s=(n=n.toRed(ecparams.red)).redSqr().redIMul(n).redIAdd(ecparams.b).redSqrt();return 3===e!==s.isOdd()&&(s=s.redNeg()),ec.keyPair({pub:{x:n,y:s}})}function loadUncompressedPublicKey(e,r,n){var s=new BN(r),a=new BN(n);if(s.cmp(ecparams.p)>=0||a.cmp(ecparams.p)>=0)return null;if(s=s.toRed(ecparams.red),a=a.toRed(ecparams.red),(6===e||7===e)&&a.isOdd()!==(7===e))return null;var c=s.redSqr().redIMul(s);return a.redSqr().redISub(c.redIAdd(ecparams.b)).isZero()?ec.keyPair({pub:{x:s,y:a}}):null}function loadPublicKey(e){var r=e[0];switch(r){case 2:case 3:return 33!==e.length?null:loadCompressedPublicKey(r,e.slice(1,33));case 4:case 6:case 7:return 65!==e.length?null:loadUncompressedPublicKey(r,e.slice(1,33),e.slice(33,65));default:return null}}var Buffer=require("safe-buffer").Buffer,createHash=require("create-hash"),BN=require("bn.js"),EC=require("elliptic").ec,messages=require("../messages.json"),ec=new EC("secp256k1"),ecparams=ec.curve;exports.privateKeyVerify=function(e){var r=new BN(e);return r.cmp(ecparams.n)<0&&!r.isZero()},exports.privateKeyExport=function(e,r){var n=new BN(e);if(n.cmp(ecparams.n)>=0||n.isZero())throw new Error(messages.EC_PRIVATE_KEY_EXPORT_DER_FAIL);return Buffer.from(ec.keyFromPrivate(e).getPublic(r,!0))},exports.privateKeyTweakAdd=function(e,r){var n=new BN(r);if(n.cmp(ecparams.n)>=0)throw new Error(messages.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);if(n.iadd(new BN(e)),n.cmp(ecparams.n)>=0&&n.isub(ecparams.n),n.isZero())throw new Error(messages.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);return n.toArrayLike(Buffer,"be",32)},exports.privateKeyTweakMul=function(e,r){var n=new BN(r);if(n.cmp(ecparams.n)>=0||n.isZero())throw new Error(messages.EC_PRIVATE_KEY_TWEAK_MUL_FAIL);return n.imul(new BN(e)),n.cmp(ecparams.n)&&(n=n.umod(ecparams.n)),n.toArrayLike(Buffer,"be",32)},exports.publicKeyCreate=function(e,r){var n=new BN(e);if(n.cmp(ecparams.n)>=0||n.isZero())throw new Error(messages.EC_PUBLIC_KEY_CREATE_FAIL);return Buffer.from(ec.keyFromPrivate(e).getPublic(r,!0))},exports.publicKeyConvert=function(e,r){var n=loadPublicKey(e);if(null===n)throw new Error(messages.EC_PUBLIC_KEY_PARSE_FAIL);return Buffer.from(n.getPublic(r,!0))},exports.publicKeyVerify=function(e){return null!==loadPublicKey(e)},exports.publicKeyTweakAdd=function(e,r,n){var s=loadPublicKey(e);if(null===s)throw new Error(messages.EC_PUBLIC_KEY_PARSE_FAIL);if((r=new BN(r)).cmp(ecparams.n)>=0)throw new Error(messages.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);return Buffer.from(ecparams.g.mul(r).add(s.pub).encode(!0,n))},exports.publicKeyTweakMul=function(e,r,n){var s=loadPublicKey(e);if(null===s)throw new Error(messages.EC_PUBLIC_KEY_PARSE_FAIL);if((r=new BN(r)).cmp(ecparams.n)>=0||r.isZero())throw new Error(messages.EC_PUBLIC_KEY_TWEAK_MUL_FAIL);return Buffer.from(s.pub.mul(r).encode(!0,n))},exports.publicKeyCombine=function(e,r){for(var n=new Array(e.length),s=0;s=0||n.cmp(ecparams.n)>=0)throw new Error(messages.ECDSA_SIGNATURE_PARSE_FAIL);var s=Buffer.from(e);return 1===n.cmp(ec.nh)&&ecparams.n.sub(n).toArrayLike(Buffer,"be",32).copy(s,32),s},exports.signatureExport=function(e){var r=e.slice(0,32),n=e.slice(32,64);if(new BN(r).cmp(ecparams.n)>=0||new BN(n).cmp(ecparams.n)>=0)throw new Error(messages.ECDSA_SIGNATURE_PARSE_FAIL);return{r:r,s:n}},exports.signatureImport=function(e){var r=new BN(e.r);r.cmp(ecparams.n)>=0&&(r=new BN(0));var n=new BN(e.s);return n.cmp(ecparams.n)>=0&&(n=new BN(0)),Buffer.concat([r.toArrayLike(Buffer,"be",32),n.toArrayLike(Buffer,"be",32)])},exports.sign=function(e,r,n,s){if("function"==typeof n){var a=n;n=function(n){var c=a(e,r,null,s,n);if(!Buffer.isBuffer(c)||32!==c.length)throw new Error(messages.ECDSA_SIGN_FAIL);return new BN(c)}}var c=new BN(r);if(c.cmp(ecparams.n)>=0||c.isZero())throw new Error(messages.ECDSA_SIGN_FAIL);var o=ec.sign(e,r,{canonical:!0,k:n,pers:s});return{signature:Buffer.concat([o.r.toArrayLike(Buffer,"be",32),o.s.toArrayLike(Buffer,"be",32)]),recovery:o.recoveryParam}},exports.verify=function(e,r,n){var s={r:r.slice(0,32),s:r.slice(32,64)},a=new BN(s.r),c=new BN(s.s);if(a.cmp(ecparams.n)>=0||c.cmp(ecparams.n)>=0)throw new Error(messages.ECDSA_SIGNATURE_PARSE_FAIL);if(1===c.cmp(ec.nh)||a.isZero()||c.isZero())return!1;var o=loadPublicKey(n);if(null===o)throw new Error(messages.EC_PUBLIC_KEY_PARSE_FAIL);return ec.verify(e,s,{x:o.pub.x,y:o.pub.y})},exports.recover=function(e,r,n,s){var a={r:r.slice(0,32),s:r.slice(32,64)},c=new BN(a.r),o=new BN(a.s);if(c.cmp(ecparams.n)>=0||o.cmp(ecparams.n)>=0)throw new Error(messages.ECDSA_SIGNATURE_PARSE_FAIL);try{if(c.isZero()||o.isZero())throw new Error;var u=ec.recoverPubKey(e,a,n);return Buffer.from(u.encode(!0,s))}catch(e){throw new Error(messages.ECDSA_RECOVER_FAIL)}},exports.ecdh=function(e,r){var n=exports.ecdhUnsafe(e,r,!0);return createHash("sha256").update(n).digest()},exports.ecdhUnsafe=function(e,r,n){var s=loadPublicKey(e);if(null===s)throw new Error(messages.EC_PUBLIC_KEY_PARSE_FAIL);var a=new BN(r);if(a.cmp(ecparams.n)>=0||a.isZero())throw new Error(messages.ECDH_FAIL);return Buffer.from(s.pub.mul(a).encode(!0,n))}; + +},{"../messages.json":88,"bn.js":4,"create-hash":11,"elliptic":14,"safe-buffer":82}],87:[function(require,module,exports){ +"use strict";function initCompressedValue(e,s){return void 0===e?s:(assert.isBoolean(e,messages.COMPRESSED_TYPE_INVALID),e)}var assert=require("./assert"),der=require("./der"),messages=require("./messages.json");module.exports=function(e){return{privateKeyVerify:function(s){return assert.isBuffer(s,messages.EC_PRIVATE_KEY_TYPE_INVALID),32===s.length&&e.privateKeyVerify(s)},privateKeyExport:function(s,r){assert.isBuffer(s,messages.EC_PRIVATE_KEY_TYPE_INVALID),assert.isBufferLength(s,32,messages.EC_PRIVATE_KEY_LENGTH_INVALID),r=initCompressedValue(r,!0);var _=e.privateKeyExport(s,r);return der.privateKeyExport(s,_,r)},privateKeyImport:function(s){if(assert.isBuffer(s,messages.EC_PRIVATE_KEY_TYPE_INVALID),(s=der.privateKeyImport(s))&&32===s.length&&e.privateKeyVerify(s))return s;throw new Error(messages.EC_PRIVATE_KEY_IMPORT_DER_FAIL)},privateKeyTweakAdd:function(s,r){return assert.isBuffer(s,messages.EC_PRIVATE_KEY_TYPE_INVALID),assert.isBufferLength(s,32,messages.EC_PRIVATE_KEY_LENGTH_INVALID),assert.isBuffer(r,messages.TWEAK_TYPE_INVALID),assert.isBufferLength(r,32,messages.TWEAK_LENGTH_INVALID),e.privateKeyTweakAdd(s,r)},privateKeyTweakMul:function(s,r){return assert.isBuffer(s,messages.EC_PRIVATE_KEY_TYPE_INVALID),assert.isBufferLength(s,32,messages.EC_PRIVATE_KEY_LENGTH_INVALID),assert.isBuffer(r,messages.TWEAK_TYPE_INVALID),assert.isBufferLength(r,32,messages.TWEAK_LENGTH_INVALID),e.privateKeyTweakMul(s,r)},publicKeyCreate:function(s,r){return assert.isBuffer(s,messages.EC_PRIVATE_KEY_TYPE_INVALID),assert.isBufferLength(s,32,messages.EC_PRIVATE_KEY_LENGTH_INVALID),r=initCompressedValue(r,!0),e.publicKeyCreate(s,r)},publicKeyConvert:function(s,r){return assert.isBuffer(s,messages.EC_PUBLIC_KEY_TYPE_INVALID),assert.isBufferLength2(s,33,65,messages.EC_PUBLIC_KEY_LENGTH_INVALID),r=initCompressedValue(r,!0),e.publicKeyConvert(s,r)},publicKeyVerify:function(s){return assert.isBuffer(s,messages.EC_PUBLIC_KEY_TYPE_INVALID),e.publicKeyVerify(s)},publicKeyTweakAdd:function(s,r,_){return assert.isBuffer(s,messages.EC_PUBLIC_KEY_TYPE_INVALID),assert.isBufferLength2(s,33,65,messages.EC_PUBLIC_KEY_LENGTH_INVALID),assert.isBuffer(r,messages.TWEAK_TYPE_INVALID),assert.isBufferLength(r,32,messages.TWEAK_LENGTH_INVALID),_=initCompressedValue(_,!0),e.publicKeyTweakAdd(s,r,_)},publicKeyTweakMul:function(s,r,_){return assert.isBuffer(s,messages.EC_PUBLIC_KEY_TYPE_INVALID),assert.isBufferLength2(s,33,65,messages.EC_PUBLIC_KEY_LENGTH_INVALID),assert.isBuffer(r,messages.TWEAK_TYPE_INVALID),assert.isBufferLength(r,32,messages.TWEAK_LENGTH_INVALID),_=initCompressedValue(_,!0),e.publicKeyTweakMul(s,r,_)},publicKeyCombine:function(s,r){assert.isArray(s,messages.EC_PUBLIC_KEYS_TYPE_INVALID),assert.isLengthGTZero(s,messages.EC_PUBLIC_KEYS_LENGTH_INVALID);for(var _=0;_=this._finalSize&&(this._update(this._block),this._block.fill(0));var e=8*this._len;if(e<=4294967295)this._block.writeUInt32BE(e,this._blockSize-4);else{var s=4294967295&e,h=(e-s)/4294967296;this._block.writeUInt32BE(h,this._blockSize-8),this._block.writeUInt32BE(s,this._blockSize-4)}this._update(this._block);var o=this._hash();return t?o.toString(t):o},Hash.prototype._update=function(){throw new Error("_update must be implemented by subclass")},module.exports=Hash; + +},{"safe-buffer":82}],90:[function(require,module,exports){ +var exports=module.exports=function(e){e=e.toLowerCase();var r=exports[e];if(!r)throw new Error(e+" is not supported (we accept pull requests)");return new r};exports.sha=require("./sha"),exports.sha1=require("./sha1"),exports.sha224=require("./sha224"),exports.sha256=require("./sha256"),exports.sha384=require("./sha384"),exports.sha512=require("./sha512"); + +},{"./sha":91,"./sha1":92,"./sha224":93,"./sha256":94,"./sha384":95,"./sha512":96}],91:[function(require,module,exports){ +function Sha(){this.init(),this._w=W,Hash.call(this,64,56)}function rotl5(t){return t<<5|t>>>27}function rotl30(t){return t<<30|t>>>2}function ft(t,i,r,h){return 0===t?i&r|~i&h:2===t?i&r|i&h|r&h:i^r^h}var inherits=require("inherits"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,K=[1518500249,1859775393,-1894007588,-899497514],W=new Array(80);inherits(Sha,Hash),Sha.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},Sha.prototype._update=function(t){for(var i=this._w,r=0|this._a,h=0|this._b,s=0|this._c,e=0|this._d,n=0|this._e,_=0;_<16;++_)i[_]=t.readInt32BE(4*_);for(;_<80;++_)i[_]=i[_-3]^i[_-8]^i[_-14]^i[_-16];for(var a=0;a<80;++a){var o=~~(a/20),f=rotl5(r)+ft(o,h,s,e)+n+i[a]+K[o]|0;n=e,e=s,s=rotl30(h),h=r,r=f}this._a=r+this._a|0,this._b=h+this._b|0,this._c=s+this._c|0,this._d=e+this._d|0,this._e=n+this._e|0},Sha.prototype._hash=function(){var t=Buffer.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},module.exports=Sha; + +},{"./hash":89,"inherits":51,"safe-buffer":82}],92:[function(require,module,exports){ +function Sha1(){this.init(),this._w=W,Hash.call(this,64,56)}function rotl1(t){return t<<1|t>>>31}function rotl5(t){return t<<5|t>>>27}function rotl30(t){return t<<30|t>>>2}function ft(t,i,r,h){return 0===t?i&r|~i&h:2===t?i&r|i&h|r&h:i^r^h}var inherits=require("inherits"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,K=[1518500249,1859775393,-1894007588,-899497514],W=new Array(80);inherits(Sha1,Hash),Sha1.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},Sha1.prototype._update=function(t){for(var i=this._w,r=0|this._a,h=0|this._b,s=0|this._c,e=0|this._d,n=0|this._e,_=0;_<16;++_)i[_]=t.readInt32BE(4*_);for(;_<80;++_)i[_]=rotl1(i[_-3]^i[_-8]^i[_-14]^i[_-16]);for(var a=0;a<80;++a){var o=~~(a/20),f=rotl5(r)+ft(o,h,s,e)+n+i[a]+K[o]|0;n=e,e=s,s=rotl30(h),h=r,r=f}this._a=r+this._a|0,this._b=h+this._b|0,this._c=s+this._c|0,this._d=e+this._d|0,this._e=n+this._e|0},Sha1.prototype._hash=function(){var t=Buffer.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},module.exports=Sha1; + +},{"./hash":89,"inherits":51,"safe-buffer":82}],93:[function(require,module,exports){ +function Sha224(){this.init(),this._w=W,Hash.call(this,64,56)}var inherits=require("inherits"),Sha256=require("./sha256"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,W=new Array(64);inherits(Sha224,Sha256),Sha224.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},Sha224.prototype._hash=function(){var t=Buffer.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t},module.exports=Sha224; + +},{"./hash":89,"./sha256":94,"inherits":51,"safe-buffer":82}],94:[function(require,module,exports){ +function Sha256(){this.init(),this._w=W,Hash.call(this,64,56)}function ch(t,i,h){return h^t&(i^h)}function maj(t,i,h){return t&i|h&(t|i)}function sigma0(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function sigma1(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function gamma0(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}function gamma1(t){return(t>>>17|t<<15)^(t>>>19|t<<13)^t>>>10}var inherits=require("inherits"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,K=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],W=new Array(64);inherits(Sha256,Hash),Sha256.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},Sha256.prototype._update=function(t){for(var i=this._w,h=0|this._a,s=0|this._b,r=0|this._c,e=0|this._d,n=0|this._e,_=0|this._f,a=0|this._g,f=0|this._h,u=0;u<16;++u)i[u]=t.readInt32BE(4*u);for(;u<64;++u)i[u]=gamma1(i[u-2])+i[u-7]+gamma0(i[u-15])+i[u-16]|0;for(var o=0;o<64;++o){var c=f+sigma1(n)+ch(n,_,a)+K[o]+i[o]|0,m=sigma0(h)+maj(h,s,r)|0;f=a,a=_,_=n,n=e+c|0,e=r,r=s,s=h,h=c+m|0}this._a=h+this._a|0,this._b=s+this._b|0,this._c=r+this._c|0,this._d=e+this._d|0,this._e=n+this._e|0,this._f=_+this._f|0,this._g=a+this._g|0,this._h=f+this._h|0},Sha256.prototype._hash=function(){var t=Buffer.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},module.exports=Sha256; + +},{"./hash":89,"inherits":51,"safe-buffer":82}],95:[function(require,module,exports){ +function Sha384(){this.init(),this._w=W,Hash.call(this,128,112)}var inherits=require("inherits"),SHA512=require("./sha512"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,W=new Array(160);inherits(Sha384,SHA512),Sha384.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},Sha384.prototype._hash=function(){function h(h,t,s){i.writeInt32BE(h,s),i.writeInt32BE(t,s+4)}var i=Buffer.allocUnsafe(48);return h(this._ah,this._al,0),h(this._bh,this._bl,8),h(this._ch,this._cl,16),h(this._dh,this._dl,24),h(this._eh,this._el,32),h(this._fh,this._fl,40),i},module.exports=Sha384; + +},{"./hash":89,"./sha512":96,"inherits":51,"safe-buffer":82}],96:[function(require,module,exports){ +function Sha512(){this.init(),this._w=W,Hash.call(this,128,112)}function Ch(h,t,i){return i^h&(t^i)}function maj(h,t,i){return h&t|i&(h|t)}function sigma0(h,t){return(h>>>28|t<<4)^(t>>>2|h<<30)^(t>>>7|h<<25)}function sigma1(h,t){return(h>>>14|t<<18)^(h>>>18|t<<14)^(t>>>9|h<<23)}function Gamma0(h,t){return(h>>>1|t<<31)^(h>>>8|t<<24)^h>>>7}function Gamma0l(h,t){return(h>>>1|t<<31)^(h>>>8|t<<24)^(h>>>7|t<<25)}function Gamma1(h,t){return(h>>>19|t<<13)^(t>>>29|h<<3)^h>>>6}function Gamma1l(h,t){return(h>>>19|t<<13)^(t>>>29|h<<3)^(h>>>6|t<<26)}function getCarry(h,t){return h>>>0>>0?1:0}var inherits=require("inherits"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,K=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],W=new Array(160);inherits(Sha512,Hash),Sha512.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},Sha512.prototype._update=function(h){for(var t=this._w,i=0|this._ah,s=0|this._bh,r=0|this._ch,_=0|this._dh,a=0|this._eh,e=0|this._fh,l=0|this._gh,n=0|this._hh,f=0|this._al,g=0|this._bl,u=0|this._cl,c=0|this._dl,m=0|this._el,o=0|this._fl,y=0|this._gl,C=0|this._hl,d=0;d<32;d+=2)t[d]=h.readInt32BE(4*d),t[d+1]=h.readInt32BE(4*d+4);for(;d<160;d+=2){var b=t[d-30],p=t[d-30+1],G=Gamma0(b,p),v=Gamma0l(p,b),B=Gamma1(b=t[d-4],p=t[d-4+1]),S=Gamma1l(p,b),w=t[d-14],E=t[d-14+1],I=t[d-32],j=t[d-32+1],q=v+E|0,H=G+w+getCarry(q,v)|0;H=(H=H+B+getCarry(q=q+S|0,S)|0)+I+getCarry(q=q+j|0,j)|0,t[d]=H,t[d+1]=q}for(var W=0;W<160;W+=2){H=t[W],q=t[W+1];var x=maj(i,s,r),A=maj(f,g,u),U=sigma0(i,f),k=sigma0(f,i),z=sigma1(a,m),D=sigma1(m,a),F=K[W],J=K[W+1],L=Ch(a,e,l),M=Ch(m,o,y),N=C+D|0,O=n+z+getCarry(N,C)|0;O=(O=(O=O+L+getCarry(N=N+M|0,M)|0)+F+getCarry(N=N+J|0,J)|0)+H+getCarry(N=N+q|0,q)|0;var P=k+A|0,Q=U+x+getCarry(P,k)|0;n=l,C=y,l=e,y=o,e=a,o=m,a=_+O+getCarry(m=c+N|0,c)|0,_=r,c=u,r=s,u=g,s=i,g=f,i=O+Q+getCarry(f=N+P|0,N)|0}this._al=this._al+f|0,this._bl=this._bl+g|0,this._cl=this._cl+u|0,this._dl=this._dl+c|0,this._el=this._el+m|0,this._fl=this._fl+o|0,this._gl=this._gl+y|0,this._hl=this._hl+C|0,this._ah=this._ah+i+getCarry(this._al,f)|0,this._bh=this._bh+s+getCarry(this._bl,g)|0,this._ch=this._ch+r+getCarry(this._cl,u)|0,this._dh=this._dh+_+getCarry(this._dl,c)|0,this._eh=this._eh+a+getCarry(this._el,m)|0,this._fh=this._fh+e+getCarry(this._fl,o)|0,this._gh=this._gh+l+getCarry(this._gl,y)|0,this._hh=this._hh+n+getCarry(this._hl,C)|0},Sha512.prototype._hash=function(){function h(h,i,s){t.writeInt32BE(h,s),t.writeInt32BE(i,s+4)}var t=Buffer.allocUnsafe(64);return h(this._ah,this._al,0),h(this._bh,this._bl,8),h(this._ch,this._cl,16),h(this._dh,this._dl,24),h(this._eh,this._el,32),h(this._fh,this._fl,40),h(this._gh,this._gl,48),h(this._hh,this._hl,56),t},module.exports=Sha512; + +},{"./hash":89,"inherits":51,"safe-buffer":82}],97:[function(require,module,exports){ +function Stream(){EE.call(this)}module.exports=Stream;var EE=require("events").EventEmitter,inherits=require("inherits");inherits(Stream,EE),Stream.Readable=require("readable-stream/readable.js"),Stream.Writable=require("readable-stream/writable.js"),Stream.Duplex=require("readable-stream/duplex.js"),Stream.Transform=require("readable-stream/transform.js"),Stream.PassThrough=require("readable-stream/passthrough.js"),Stream.Stream=Stream,Stream.prototype.pipe=function(e,r){function t(r){e.writable&&!1===e.write(r)&&m.pause&&m.pause()}function n(){m.readable&&m.resume&&m.resume()}function a(){u||(u=!0,e.end())}function o(){u||(u=!0,"function"==typeof e.destroy&&e.destroy())}function i(e){if(s(),0===EE.listenerCount(this,"error"))throw e}function s(){m.removeListener("data",t),e.removeListener("drain",n),m.removeListener("end",a),m.removeListener("close",o),m.removeListener("error",i),e.removeListener("error",i),m.removeListener("end",s),m.removeListener("close",s),e.removeListener("close",s)}var m=this;m.on("data",t),e.on("drain",n),e._isStdio||r&&!1===r.end||(m.on("end",a),m.on("close",o));var u=!1;return m.on("error",i),e.on("error",i),m.on("end",s),m.on("close",s),e.on("close",s),e.emit("pipe",m),e}; + +},{"events":35,"inherits":51,"readable-stream/duplex.js":67,"readable-stream/passthrough.js":76,"readable-stream/readable.js":77,"readable-stream/transform.js":78,"readable-stream/writable.js":79}],98:[function(require,module,exports){ +"use strict";function _normalizeEncoding(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}function normalizeEncoding(t){var e=_normalizeEncoding(t);if("string"!=typeof e&&(Buffer.isEncoding===isEncoding||!isEncoding(t)))throw new Error("Unknown encoding: "+t);return e||t}function StringDecoder(t){this.encoding=normalizeEncoding(t);var e;switch(this.encoding){case"utf16le":this.text=utf16Text,this.end=utf16End,e=4;break;case"utf8":this.fillLast=utf8FillLast,e=4;break;case"base64":this.text=base64Text,this.end=base64End,e=3;break;default:return this.write=simpleWrite,void(this.end=simpleEnd)}this.lastNeed=0,this.lastTotal=0,this.lastChar=Buffer.allocUnsafe(e)}function utf8CheckByte(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:-1}function utf8CheckIncomplete(t,e,s){var i=e.length-1;if(i=0?(a>0&&(t.lastNeed=a-1),a):--i=0?(a>0&&(t.lastNeed=a-2),a):--i=0?(a>0&&(2===a?a=0:t.lastNeed=a-3),a):0}function utf8CheckExtraBytes(t,e,s){if(128!=(192&e[0]))return t.lastNeed=0,"�".repeat(s);if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�".repeat(s+1);if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�".repeat(s+2)}}function utf8FillLast(t){var e=this.lastTotal-this.lastNeed,s=utf8CheckExtraBytes(this,t,e);return void 0!==s?s:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function utf8Text(t,e){var s=utf8CheckIncomplete(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=s;var i=t.length-(s-this.lastNeed);return t.copy(this.lastChar,0,i),t.toString("utf8",e,i)}function utf8End(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"�".repeat(this.lastTotal-this.lastNeed):e}function utf16Text(t,e){if((t.length-e)%2==0){var s=t.toString("utf16le",e);if(s){var i=s.charCodeAt(s.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],s.slice(0,-1)}return s}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function utf16End(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var s=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,s)}return e}function base64Text(t,e){var s=(t.length-e)%3;return 0===s?t.toString("base64",e):(this.lastNeed=3-s,this.lastTotal=3,1===s?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-s))}function base64End(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function simpleWrite(t){return t.toString(this.encoding)}function simpleEnd(t){return t&&t.length?this.write(t):""}var Buffer=require("safe-buffer").Buffer,isEncoding=Buffer.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};exports.StringDecoder=StringDecoder,StringDecoder.prototype.write=function(t){if(0===t.length)return"";var e,s;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";s=this.lastNeed,this.lastNeed=0}else s=0;return s=3&&(t.depth=arguments[2]),arguments.length>=4&&(t.colors=arguments[3]),isBoolean(r)?t.showHidden=r:r&&exports._extend(t,r),isUndefined(t.showHidden)&&(t.showHidden=!1),isUndefined(t.depth)&&(t.depth=2),isUndefined(t.colors)&&(t.colors=!1),isUndefined(t.customInspect)&&(t.customInspect=!0),t.colors&&(t.stylize=stylizeWithColor),formatValue(t,e,t.depth)}function stylizeWithColor(e,r){var t=inspect.styles[r];return t?"["+inspect.colors[t][0]+"m"+e+"["+inspect.colors[t][1]+"m":e}function stylizeNoColor(e,r){return e}function arrayToHash(e){var r={};return e.forEach(function(e,t){r[e]=!0}),r}function formatValue(e,r,t){if(e.customInspect&&r&&isFunction(r.inspect)&&r.inspect!==exports.inspect&&(!r.constructor||r.constructor.prototype!==r)){var n=r.inspect(t,e);return isString(n)||(n=formatValue(e,n,t)),n}var i=formatPrimitive(e,r);if(i)return i;var o=Object.keys(r),s=arrayToHash(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(r)),isError(r)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return formatError(r);if(0===o.length){if(isFunction(r)){var u=r.name?": "+r.name:"";return e.stylize("[Function"+u+"]","special")}if(isRegExp(r))return e.stylize(RegExp.prototype.toString.call(r),"regexp");if(isDate(r))return e.stylize(Date.prototype.toString.call(r),"date");if(isError(r))return formatError(r)}var c="",a=!1,l=["{","}"];if(isArray(r)&&(a=!0,l=["[","]"]),isFunction(r)&&(c=" [Function"+(r.name?": "+r.name:"")+"]"),isRegExp(r)&&(c=" "+RegExp.prototype.toString.call(r)),isDate(r)&&(c=" "+Date.prototype.toUTCString.call(r)),isError(r)&&(c=" "+formatError(r)),0===o.length&&(!a||0==r.length))return l[0]+c+l[1];if(t<0)return isRegExp(r)?e.stylize(RegExp.prototype.toString.call(r),"regexp"):e.stylize("[Object]","special");e.seen.push(r);var p;return p=a?formatArray(e,r,t,s,o):o.map(function(n){return formatProperty(e,r,t,s,n,a)}),e.seen.pop(),reduceToSingleString(p,c,l)}function formatPrimitive(e,r){if(isUndefined(r))return e.stylize("undefined","undefined");if(isString(r)){var t="'"+JSON.stringify(r).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(t,"string")}return isNumber(r)?e.stylize(""+r,"number"):isBoolean(r)?e.stylize(""+r,"boolean"):isNull(r)?e.stylize("null","null"):void 0}function formatError(e){return"["+Error.prototype.toString.call(e)+"]"}function formatArray(e,r,t,n,i){for(var o=[],s=0,u=r.length;s-1&&(u=o?u.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+u.split("\n").map(function(e){return" "+e}).join("\n")):u=e.stylize("[Circular]","special")),isUndefined(s)){if(o&&i.match(/^\d+$/))return u;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+u}function reduceToSingleString(e,r,t){var n=0;return e.reduce(function(e,r){return n++,r.indexOf("\n")>=0&&n++,e+r.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?t[0]+(""===r?"":r+"\n ")+" "+e.join(",\n ")+" "+t[1]:t[0]+r+" "+e.join(", ")+" "+t[1]}function isArray(e){return Array.isArray(e)}function isBoolean(e){return"boolean"==typeof e}function isNull(e){return null===e}function isNullOrUndefined(e){return null==e}function isNumber(e){return"number"==typeof e}function isString(e){return"string"==typeof e}function isSymbol(e){return"symbol"==typeof e}function isUndefined(e){return void 0===e}function isRegExp(e){return isObject(e)&&"[object RegExp]"===objectToString(e)}function isObject(e){return"object"==typeof e&&null!==e}function isDate(e){return isObject(e)&&"[object Date]"===objectToString(e)}function isError(e){return isObject(e)&&("[object Error]"===objectToString(e)||e instanceof Error)}function isFunction(e){return"function"==typeof e}function isPrimitive(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e}function objectToString(e){return Object.prototype.toString.call(e)}function pad(e){return e<10?"0"+e.toString(10):e.toString(10)}function timestamp(){var e=new Date,r=[pad(e.getHours()),pad(e.getMinutes()),pad(e.getSeconds())].join(":");return[e.getDate(),months[e.getMonth()],r].join(" ")}function hasOwnProperty(e,r){return Object.prototype.hasOwnProperty.call(e,r)}var formatRegExp=/%[sdj%]/g;exports.format=function(e){if(!isString(e)){for(var r=[],t=0;t=i)return e;switch(e){case"%s":return String(n[t++]);case"%d":return Number(n[t++]);case"%j":try{return JSON.stringify(n[t++])}catch(e){return"[Circular]"}default:return e}}),s=n[t];t>>2]>>>24-o%4*8&255;e[i+o>>>2]|=s<<24-(i+o)%4*8}else for(o=0;o>>2]=r[o>>>2];return this.sigBytes+=n,this},clamp:function(){var t=this.words,e=this.sigBytes;t[e>>>2]&=4294967295<<32-e%4*8,t.length=l.ceil(e/4)},clone:function(){var t=s.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],r=0;r>>2]>>>24-n%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},parse:function(t){for(var e=t.length,r=[],i=0;i>>3]|=parseInt(t.substr(i,2),16)<<24-i%8*4;return new f.init(r,e/2)}},h=c.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,i=[],n=0;n>>2]>>>24-n%4*8&255;i.push(String.fromCharCode(o))}return i.join("")},parse:function(t){for(var e=t.length,r=[],i=0;i>>2]|=(255&t.charCodeAt(i))<<24-i%4*8;return new f.init(r,e)}},d=c.Utf8={stringify:function(t){try{return decodeURIComponent(escape(h.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return h.parse(unescape(encodeURIComponent(t)))}},u=o.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new f.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=d.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(t){var e,r=this._data,i=r.words,n=r.sigBytes,o=this.blockSize,s=n/(4*o),c=(s=t?l.ceil(s):l.max((0|s)-this._minBufferSize,0))*o,a=l.min(4*c,n);if(c){for(var h=0;h>>32-e}function Dt(t,e,r,i){var n,o=this._iv;o?(n=o.slice(0),this._iv=void 0):n=this._prevBlock,i.encryptBlock(n,0);for(var s=0;s>24&255)){var e=t>>16&255,r=t>>8&255,i=255&t;255===e?(e=0,255===r?(r=0,255===i?i=0:++i):++r):++e,t=0,t+=e<<16,t+=r<<8,t+=i}else t+=1<<24;return t}function Rt(){for(var t=this._X,e=this._C,r=0;r<8;r++)ft[r]=e[r];e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0>>0?1:0)|0,this._b=e[7]>>>0>>0?1:0;for(r=0;r<8;r++){var i=t[r]+e[r],n=65535&i,o=i>>>16,s=((n*n>>>17)+n*o>>>15)+o*o,c=((4294901760&i)*i|0)+((65535&i)*i|0);dt[r]=s^c}t[0]=dt[0]+(dt[7]<<16|dt[7]>>>16)+(dt[6]<<16|dt[6]>>>16)|0,t[1]=dt[1]+(dt[0]<<8|dt[0]>>>24)+dt[7]|0,t[2]=dt[2]+(dt[1]<<16|dt[1]>>>16)+(dt[0]<<16|dt[0]>>>16)|0,t[3]=dt[3]+(dt[2]<<8|dt[2]>>>24)+dt[1]|0,t[4]=dt[4]+(dt[3]<<16|dt[3]>>>16)+(dt[2]<<16|dt[2]>>>16)|0,t[5]=dt[5]+(dt[4]<<8|dt[4]>>>24)+dt[3]|0,t[6]=dt[6]+(dt[5]<<16|dt[5]>>>16)+(dt[4]<<16|dt[4]>>>16)|0,t[7]=dt[7]+(dt[6]<<8|dt[6]>>>24)+dt[5]|0}function Mt(){for(var t=this._X,e=this._C,r=0;r<8;r++)wt[r]=e[r];e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0>>0?1:0)|0,this._b=e[7]>>>0>>0?1:0;for(r=0;r<8;r++){var i=t[r]+e[r],n=65535&i,o=i>>>16,s=((n*n>>>17)+n*o>>>15)+o*o,c=((4294901760&i)*i|0)+((65535&i)*i|0);kt[r]=s^c}t[0]=kt[0]+(kt[7]<<16|kt[7]>>>16)+(kt[6]<<16|kt[6]>>>16)|0,t[1]=kt[1]+(kt[0]<<8|kt[0]>>>24)+kt[7]|0,t[2]=kt[2]+(kt[1]<<16|kt[1]>>>16)+(kt[0]<<16|kt[0]>>>16)|0,t[3]=kt[3]+(kt[2]<<8|kt[2]>>>24)+kt[1]|0,t[4]=kt[4]+(kt[3]<<16|kt[3]>>>16)+(kt[2]<<16|kt[2]>>>16)|0,t[5]=kt[5]+(kt[4]<<8|kt[4]>>>24)+kt[3]|0,t[6]=kt[6]+(kt[5]<<16|kt[5]>>>16)+(kt[4]<<16|kt[4]>>>16)|0,t[7]=kt[7]+(kt[6]<<8|kt[6]>>>24)+kt[5]|0}return h=bt.lib.WordArray,bt.enc.Base64={stringify:function(t){var e=t.words,r=t.sigBytes,i=this._map;t.clamp();for(var n=[],o=0;o>>2]>>>24-o%4*8&255)<<16|(e[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|e[o+2>>>2]>>>24-(o+2)%4*8&255,c=0;c<4&&o+.75*c>>6*(3-c)&63));var a=i.charAt(64);if(a)for(;n.length%4;)n.push(a);return n.join("")},parse:function(t){var e=t.length,r=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var n=0;n>>6-o%4*2,a=s|c;i[n>>>2]|=a<<24-n%4*8,n++}return h.create(i,n)}(t,e,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(l){var t=bt,e=t.lib,r=e.WordArray,i=e.Hasher,n=t.algo,H=[];!function(){for(var t=0;t<64;t++)H[t]=4294967296*l.abs(l.sin(t+1))|0}();var o=n.MD5=i.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,e){for(var r=0;r<16;r++){var i=e+r,n=t[i];t[i]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var o=this._hash.words,s=t[e+0],c=t[e+1],a=t[e+2],h=t[e+3],l=t[e+4],f=t[e+5],d=t[e+6],u=t[e+7],p=t[e+8],_=t[e+9],v=t[e+10],y=t[e+11],g=t[e+12],B=t[e+13],w=t[e+14],k=t[e+15],S=o[0],m=o[1],x=o[2],b=o[3];S=z(S,m,x,b,s,7,H[0]),b=z(b,S,m,x,c,12,H[1]),x=z(x,b,S,m,a,17,H[2]),m=z(m,x,b,S,h,22,H[3]),S=z(S,m,x,b,l,7,H[4]),b=z(b,S,m,x,f,12,H[5]),x=z(x,b,S,m,d,17,H[6]),m=z(m,x,b,S,u,22,H[7]),S=z(S,m,x,b,p,7,H[8]),b=z(b,S,m,x,_,12,H[9]),x=z(x,b,S,m,v,17,H[10]),m=z(m,x,b,S,y,22,H[11]),S=z(S,m,x,b,g,7,H[12]),b=z(b,S,m,x,B,12,H[13]),x=z(x,b,S,m,w,17,H[14]),S=A(S,m=z(m,x,b,S,k,22,H[15]),x,b,c,5,H[16]),b=A(b,S,m,x,d,9,H[17]),x=A(x,b,S,m,y,14,H[18]),m=A(m,x,b,S,s,20,H[19]),S=A(S,m,x,b,f,5,H[20]),b=A(b,S,m,x,v,9,H[21]),x=A(x,b,S,m,k,14,H[22]),m=A(m,x,b,S,l,20,H[23]),S=A(S,m,x,b,_,5,H[24]),b=A(b,S,m,x,w,9,H[25]),x=A(x,b,S,m,h,14,H[26]),m=A(m,x,b,S,p,20,H[27]),S=A(S,m,x,b,B,5,H[28]),b=A(b,S,m,x,a,9,H[29]),x=A(x,b,S,m,u,14,H[30]),S=C(S,m=A(m,x,b,S,g,20,H[31]),x,b,f,4,H[32]),b=C(b,S,m,x,p,11,H[33]),x=C(x,b,S,m,y,16,H[34]),m=C(m,x,b,S,w,23,H[35]),S=C(S,m,x,b,c,4,H[36]),b=C(b,S,m,x,l,11,H[37]),x=C(x,b,S,m,u,16,H[38]),m=C(m,x,b,S,v,23,H[39]),S=C(S,m,x,b,B,4,H[40]),b=C(b,S,m,x,s,11,H[41]),x=C(x,b,S,m,h,16,H[42]),m=C(m,x,b,S,d,23,H[43]),S=C(S,m,x,b,_,4,H[44]),b=C(b,S,m,x,g,11,H[45]),x=C(x,b,S,m,k,16,H[46]),S=D(S,m=C(m,x,b,S,a,23,H[47]),x,b,s,6,H[48]),b=D(b,S,m,x,u,10,H[49]),x=D(x,b,S,m,w,15,H[50]),m=D(m,x,b,S,f,21,H[51]),S=D(S,m,x,b,g,6,H[52]),b=D(b,S,m,x,h,10,H[53]),x=D(x,b,S,m,v,15,H[54]),m=D(m,x,b,S,c,21,H[55]),S=D(S,m,x,b,p,6,H[56]),b=D(b,S,m,x,k,10,H[57]),x=D(x,b,S,m,d,15,H[58]),m=D(m,x,b,S,B,21,H[59]),S=D(S,m,x,b,l,6,H[60]),b=D(b,S,m,x,y,10,H[61]),x=D(x,b,S,m,a,15,H[62]),m=D(m,x,b,S,_,21,H[63]),o[0]=o[0]+S|0,o[1]=o[1]+m|0,o[2]=o[2]+x|0,o[3]=o[3]+b|0},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;e[i>>>5]|=128<<24-i%32;var n=l.floor(r/4294967296),o=r;e[15+(64+i>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),e[14+(64+i>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),t.sigBytes=4*(e.length+1),this._process();for(var s=this._hash,c=s.words,a=0;a<4;a++){var h=c[a];c[a]=16711935&(h<<8|h>>>24)|4278255360&(h<<24|h>>>8)}return s},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});function z(t,e,r,i,n,o,s){var c=t+(e&r|~e&i)+n+s;return(c<>>32-o)+e}function A(t,e,r,i,n,o,s){var c=t+(e&i|r&~i)+n+s;return(c<>>32-o)+e}function C(t,e,r,i,n,o,s){var c=t+(e^r^i)+n+s;return(c<>>32-o)+e}function D(t,e,r,i,n,o,s){var c=t+(r^(e|~i))+n+s;return(c<>>32-o)+e}t.MD5=i._createHelper(o),t.HmacMD5=i._createHmacHelper(o)}(Math),e=(t=bt).lib,r=e.WordArray,i=e.Hasher,n=t.algo,f=[],o=n.SHA1=i.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=this._hash.words,i=r[0],n=r[1],o=r[2],s=r[3],c=r[4],a=0;a<80;a++){if(a<16)f[a]=0|t[e+a];else{var h=f[a-3]^f[a-8]^f[a-14]^f[a-16];f[a]=h<<1|h>>>31}var l=(i<<5|i>>>27)+c+f[a];l+=a<20?1518500249+(n&o|~n&s):a<40?1859775393+(n^o^s):a<60?(n&o|n&s|o&s)-1894007588:(n^o^s)-899497514,c=s,s=o,o=n<<30|n>>>2,n=i,i=l}r[0]=r[0]+i|0,r[1]=r[1]+n|0,r[2]=r[2]+o|0,r[3]=r[3]+s|0,r[4]=r[4]+c|0},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return e[i>>>5]|=128<<24-i%32,e[14+(64+i>>>9<<4)]=Math.floor(r/4294967296),e[15+(64+i>>>9<<4)]=r,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}}),t.SHA1=i._createHelper(o),t.HmacSHA1=i._createHmacHelper(o),function(n){var t=bt,e=t.lib,r=e.WordArray,i=e.Hasher,o=t.algo,s=[],B=[];!function(){function t(t){for(var e=n.sqrt(t),r=2;r<=e;r++)if(!(t%r))return;return 1}function e(t){return 4294967296*(t-(0|t))|0}for(var r=2,i=0;i<64;)t(r)&&(i<8&&(s[i]=e(n.pow(r,.5))),B[i]=e(n.pow(r,1/3)),i++),r++}();var w=[],c=o.SHA256=i.extend({_doReset:function(){this._hash=new r.init(s.slice(0))},_doProcessBlock:function(t,e){for(var r=this._hash.words,i=r[0],n=r[1],o=r[2],s=r[3],c=r[4],a=r[5],h=r[6],l=r[7],f=0;f<64;f++){if(f<16)w[f]=0|t[e+f];else{var d=w[f-15],u=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,p=w[f-2],_=(p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10;w[f]=u+w[f-7]+_+w[f-16]}var v=i&n^i&o^n&o,y=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22),g=l+((c<<26|c>>>6)^(c<<21|c>>>11)^(c<<7|c>>>25))+(c&a^~c&h)+B[f]+w[f];l=h,h=a,a=c,c=s+g|0,s=o,o=n,n=i,i=g+(y+v)|0}r[0]=r[0]+i|0,r[1]=r[1]+n|0,r[2]=r[2]+o|0,r[3]=r[3]+s|0,r[4]=r[4]+c|0,r[5]=r[5]+a|0,r[6]=r[6]+h|0,r[7]=r[7]+l|0},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return e[i>>>5]|=128<<24-i%32,e[14+(64+i>>>9<<4)]=n.floor(r/4294967296),e[15+(64+i>>>9<<4)]=r,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});t.SHA256=i._createHelper(c),t.HmacSHA256=i._createHmacHelper(c)}(Math),function(){var n=bt.lib.WordArray,t=bt.enc;t.Utf16=t.Utf16BE={stringify:function(t){for(var e=t.words,r=t.sigBytes,i=[],n=0;n>>2]>>>16-n%4*8&65535;i.push(String.fromCharCode(o))}return i.join("")},parse:function(t){for(var e=t.length,r=[],i=0;i>>1]|=t.charCodeAt(i)<<16-i%2*16;return n.create(r,2*e)}};function s(t){return t<<8&4278255360|t>>>8&16711935}t.Utf16LE={stringify:function(t){for(var e=t.words,r=t.sigBytes,i=[],n=0;n>>2]>>>16-n%4*8&65535);i.push(String.fromCharCode(o))}return i.join("")},parse:function(t){for(var e=t.length,r=[],i=0;i>>1]|=s(t.charCodeAt(i)<<16-i%2*16);return n.create(r,2*e)}}}(),function(){if("function"==typeof ArrayBuffer){var t=bt.lib.WordArray,n=t.init;(t.init=function(t){if(t instanceof ArrayBuffer&&(t=new Uint8Array(t)),(t instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength)),t instanceof Uint8Array){for(var e=t.byteLength,r=[],i=0;i>>2]|=t[i]<<24-i%4*8;n.call(this,r,e)}else n.apply(this,arguments)}).prototype=t}}(),Math,c=(s=bt).lib,a=c.WordArray,l=c.Hasher,d=s.algo,m=a.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),x=a.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),b=a.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),H=a.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),z=a.create([0,1518500249,1859775393,2400959708,2840853838]),A=a.create([1352829926,1548603684,1836072691,2053994217,0]),u=d.RIPEMD160=l.extend({_doReset:function(){this._hash=a.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=0;r<16;r++){var i=e+r,n=t[i];t[i]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var o,s,c,a,h,l,f,d,u,p,_,v=this._hash.words,y=z.words,g=A.words,B=m.words,w=x.words,k=b.words,S=H.words;l=o=v[0],f=s=v[1],d=c=v[2],u=a=v[3],p=h=v[4];for(r=0;r<80;r+=1)_=o+t[e+B[r]]|0,_+=r<16?mt(s,c,a)+y[0]:r<32?xt(s,c,a)+y[1]:r<48?Ht(s,c,a)+y[2]:r<64?zt(s,c,a)+y[3]:At(s,c,a)+y[4],_=(_=Ct(_|=0,k[r]))+h|0,o=h,h=a,a=Ct(c,10),c=s,s=_,_=l+t[e+w[r]]|0,_+=r<16?At(f,d,u)+g[0]:r<32?zt(f,d,u)+g[1]:r<48?Ht(f,d,u)+g[2]:r<64?xt(f,d,u)+g[3]:mt(f,d,u)+g[4],_=(_=Ct(_|=0,S[r]))+p|0,l=p,p=u,u=Ct(d,10),d=f,f=_;_=v[1]+c+u|0,v[1]=v[2]+a+p|0,v[2]=v[3]+h+l|0,v[3]=v[4]+o+f|0,v[4]=v[0]+s+d|0,v[0]=_},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;e[i>>>5]|=128<<24-i%32,e[14+(64+i>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(e.length+1),this._process();for(var n=this._hash,o=n.words,s=0;s<5;s++){var c=o[s];o[s]=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8)}return n},clone:function(){var t=l.clone.call(this);return t._hash=this._hash.clone(),t}}),s.RIPEMD160=l._createHelper(u),s.HmacRIPEMD160=l._createHmacHelper(u),p=bt.lib.Base,_=bt.enc.Utf8,bt.algo.HMAC=p.extend({init:function(t,e){t=this._hasher=new t.init,"string"==typeof e&&(e=_.parse(e));var r=t.blockSize,i=4*r;e.sigBytes>i&&(e=t.finalize(e)),e.clamp();for(var n=this._oKey=e.clone(),o=this._iKey=e.clone(),s=n.words,c=o.words,a=0;a>>24)|4278255360&(o<<24|o>>>8),s=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),(x=r[n]).high^=s,x.low^=o}for(var c=0;c<24;c++){for(var a=0;a<5;a++){for(var h=0,l=0,f=0;f<5;f++){h^=(x=r[a+5*f]).high,l^=x.low}var d=R[a];d.high=h,d.low=l}for(a=0;a<5;a++){var u=R[(a+4)%5],p=R[(a+1)%5],_=p.high,v=p.low;for(h=u.high^(_<<1|v>>>31),l=u.low^(v<<1|_>>>31),f=0;f<5;f++){(x=r[a+5*f]).high^=h,x.low^=l}}for(var y=1;y<25;y++){var g=(x=r[y]).high,B=x.low,w=C[y];l=w<32?(h=g<>>32-w,B<>>32-w):(h=B<>>64-w,g<>>64-w);var k=R[D[y]];k.high=h,k.low=l}var S=R[0],m=r[0];S.high=m.high,S.low=m.low;for(a=0;a<5;a++)for(f=0;f<5;f++){var x=r[y=a+5*f],b=R[y],H=R[(a+1)%5+5*f],z=R[(a+2)%5+5*f];x.high=b.high^~H.high&z.high,x.low=b.low^~H.low&z.low}x=r[0];var A=E[c];x.high^=A.high,x.low^=A.low}},_doFinalize:function(){var t=this._data,e=t.words,r=(this._nDataBytes,8*t.sigBytes),i=32*this.blockSize;e[r>>>5]|=1<<24-r%32,e[(d.ceil((1+r)/i)*i>>>5)-1]|=128,t.sigBytes=4*e.length,this._process();for(var n=this._state,o=this.cfg.outputLength/8,s=o/8,c=[],a=0;a>>24)|4278255360&(l<<24|l>>>8),f=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8),c.push(f),c.push(l)}return new u.init(c,o)},clone:function(){for(var t=i.clone.call(this),e=t._state=this._state.slice(0),r=0;r<25;r++)e[r]=e[r].clone();return t}});t.SHA3=i._createHelper(n),t.HmacSHA3=i._createHmacHelper(n)}(Math),function(){var t=bt,e=t.lib.Hasher,r=t.x64,i=r.Word,n=r.WordArray,o=t.algo;function s(){return i.create.apply(i,arguments)}var mt=[s(1116352408,3609767458),s(1899447441,602891725),s(3049323471,3964484399),s(3921009573,2173295548),s(961987163,4081628472),s(1508970993,3053834265),s(2453635748,2937671579),s(2870763221,3664609560),s(3624381080,2734883394),s(310598401,1164996542),s(607225278,1323610764),s(1426881987,3590304994),s(1925078388,4068182383),s(2162078206,991336113),s(2614888103,633803317),s(3248222580,3479774868),s(3835390401,2666613458),s(4022224774,944711139),s(264347078,2341262773),s(604807628,2007800933),s(770255983,1495990901),s(1249150122,1856431235),s(1555081692,3175218132),s(1996064986,2198950837),s(2554220882,3999719339),s(2821834349,766784016),s(2952996808,2566594879),s(3210313671,3203337956),s(3336571891,1034457026),s(3584528711,2466948901),s(113926993,3758326383),s(338241895,168717936),s(666307205,1188179964),s(773529912,1546045734),s(1294757372,1522805485),s(1396182291,2643833823),s(1695183700,2343527390),s(1986661051,1014477480),s(2177026350,1206759142),s(2456956037,344077627),s(2730485921,1290863460),s(2820302411,3158454273),s(3259730800,3505952657),s(3345764771,106217008),s(3516065817,3606008344),s(3600352804,1432725776),s(4094571909,1467031594),s(275423344,851169720),s(430227734,3100823752),s(506948616,1363258195),s(659060556,3750685593),s(883997877,3785050280),s(958139571,3318307427),s(1322822218,3812723403),s(1537002063,2003034995),s(1747873779,3602036899),s(1955562222,1575990012),s(2024104815,1125592928),s(2227730452,2716904306),s(2361852424,442776044),s(2428436474,593698344),s(2756734187,3733110249),s(3204031479,2999351573),s(3329325298,3815920427),s(3391569614,3928383900),s(3515267271,566280711),s(3940187606,3454069534),s(4118630271,4000239992),s(116418474,1914138554),s(174292421,2731055270),s(289380356,3203993006),s(460393269,320620315),s(685471733,587496836),s(852142971,1086792851),s(1017036298,365543100),s(1126000580,2618297676),s(1288033470,3409855158),s(1501505948,4234509866),s(1607167915,987167468),s(1816402316,1246189591)],xt=[];!function(){for(var t=0;t<80;t++)xt[t]=s()}();var c=o.SHA512=e.extend({_doReset:function(){this._hash=new n.init([new i.init(1779033703,4089235720),new i.init(3144134277,2227873595),new i.init(1013904242,4271175723),new i.init(2773480762,1595750129),new i.init(1359893119,2917565137),new i.init(2600822924,725511199),new i.init(528734635,4215389547),new i.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var r=this._hash.words,i=r[0],n=r[1],o=r[2],s=r[3],c=r[4],a=r[5],h=r[6],l=r[7],f=i.high,d=i.low,u=n.high,p=n.low,_=o.high,v=o.low,y=s.high,g=s.low,B=c.high,w=c.low,k=a.high,S=a.low,m=h.high,x=h.low,b=l.high,H=l.low,z=f,A=d,C=u,D=p,E=_,R=v,M=y,F=g,P=B,W=w,O=k,I=S,U=m,K=x,X=b,L=H,j=0;j<80;j++){var N,T,q=xt[j];if(j<16)T=q.high=0|t[e+2*j],N=q.low=0|t[e+2*j+1];else{var Z=xt[j-15],V=Z.high,G=Z.low,J=(V>>>1|G<<31)^(V>>>8|G<<24)^V>>>7,$=(G>>>1|V<<31)^(G>>>8|V<<24)^(G>>>7|V<<25),Q=xt[j-2],Y=Q.high,tt=Q.low,et=(Y>>>19|tt<<13)^(Y<<3|tt>>>29)^Y>>>6,rt=(tt>>>19|Y<<13)^(tt<<3|Y>>>29)^(tt>>>6|Y<<26),it=xt[j-7],nt=it.high,ot=it.low,st=xt[j-16],ct=st.high,at=st.low;T=(T=(T=J+nt+((N=$+ot)>>>0<$>>>0?1:0))+et+((N+=rt)>>>0>>0?1:0))+ct+((N+=at)>>>0>>0?1:0),q.high=T,q.low=N}var ht,lt=P&O^~P&U,ft=W&I^~W&K,dt=z&C^z&E^C&E,ut=A&D^A&R^D&R,pt=(z>>>28|A<<4)^(z<<30|A>>>2)^(z<<25|A>>>7),_t=(A>>>28|z<<4)^(A<<30|z>>>2)^(A<<25|z>>>7),vt=(P>>>14|W<<18)^(P>>>18|W<<14)^(P<<23|W>>>9),yt=(W>>>14|P<<18)^(W>>>18|P<<14)^(W<<23|P>>>9),gt=mt[j],Bt=gt.high,wt=gt.low,kt=X+vt+((ht=L+yt)>>>0>>0?1:0),St=_t+ut;X=U,L=K,U=O,K=I,O=P,I=W,P=M+(kt=(kt=(kt=kt+lt+((ht=ht+ft)>>>0>>0?1:0))+Bt+((ht=ht+wt)>>>0>>0?1:0))+T+((ht=ht+N)>>>0>>0?1:0))+((W=F+ht|0)>>>0>>0?1:0)|0,M=E,F=R,E=C,R=D,C=z,D=A,z=kt+(pt+dt+(St>>>0<_t>>>0?1:0))+((A=ht+St|0)>>>0>>0?1:0)|0}d=i.low=d+A,i.high=f+z+(d>>>0>>0?1:0),p=n.low=p+D,n.high=u+C+(p>>>0>>0?1:0),v=o.low=v+R,o.high=_+E+(v>>>0>>0?1:0),g=s.low=g+F,s.high=y+M+(g>>>0>>0?1:0),w=c.low=w+W,c.high=B+P+(w>>>0>>0?1:0),S=a.low=S+I,a.high=k+O+(S>>>0>>0?1:0),x=h.low=x+K,h.high=m+U+(x>>>0>>0?1:0),H=l.low=H+L,l.high=b+X+(H>>>0>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return e[i>>>5]|=128<<24-i%32,e[30+(128+i>>>10<<5)]=Math.floor(r/4294967296),e[31+(128+i>>>10<<5)]=r,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=e.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32});t.SHA512=e._createHelper(c),t.HmacSHA512=e._createHmacHelper(c)}(),Z=(q=bt).x64,V=Z.Word,G=Z.WordArray,J=q.algo,$=J.SHA512,Q=J.SHA384=$.extend({_doReset:function(){this._hash=new G.init([new V.init(3418070365,3238371032),new V.init(1654270250,914150663),new V.init(2438529370,812702999),new V.init(355462360,4144912697),new V.init(1731405415,4290775857),new V.init(2394180231,1750603025),new V.init(3675008525,1694076839),new V.init(1203062813,3204075428)])},_doFinalize:function(){var t=$._doFinalize.call(this);return t.sigBytes-=16,t}}),q.SHA384=$._createHelper(Q),q.HmacSHA384=$._createHmacHelper(Q),bt.lib.Cipher||function(){var t=bt,e=t.lib,r=e.Base,a=e.WordArray,i=e.BufferedBlockAlgorithm,n=t.enc,o=(n.Utf8,n.Base64),s=t.algo.EvpKDF,c=e.Cipher=i.extend({cfg:r.extend(),createEncryptor:function(t,e){return this.create(this._ENC_XFORM_MODE,t,e)},createDecryptor:function(t,e){return this.create(this._DEC_XFORM_MODE,t,e)},init:function(t,e,r){this.cfg=this.cfg.extend(r),this._xformMode=t,this._key=e,this.reset()},reset:function(){i.reset.call(this),this._doReset()},process:function(t){return this._append(t),this._process()},finalize:function(t){return t&&this._append(t),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(i){return{encrypt:function(t,e,r){return h(e).encrypt(i,t,e,r)},decrypt:function(t,e,r){return h(e).decrypt(i,t,e,r)}}}});function h(t){return"string"==typeof t?w:g}e.StreamCipher=c.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var l,f=t.mode={},d=e.BlockCipherMode=r.extend({createEncryptor:function(t,e){return this.Encryptor.create(t,e)},createDecryptor:function(t,e){return this.Decryptor.create(t,e)},init:function(t,e){this._cipher=t,this._iv=e}}),u=f.CBC=((l=d.extend()).Encryptor=l.extend({processBlock:function(t,e){var r=this._cipher,i=r.blockSize;p.call(this,t,e,i),r.encryptBlock(t,e),this._prevBlock=t.slice(e,e+i)}}),l.Decryptor=l.extend({processBlock:function(t,e){var r=this._cipher,i=r.blockSize,n=t.slice(e,e+i);r.decryptBlock(t,e),p.call(this,t,e,i),this._prevBlock=n}}),l);function p(t,e,r){var i,n=this._iv;n?(i=n,this._iv=void 0):i=this._prevBlock;for(var o=0;o>>2];t.sigBytes-=e}},v=(e.BlockCipher=c.extend({cfg:c.cfg.extend({mode:u,padding:_}),reset:function(){var t;c.reset.call(this);var e=this.cfg,r=e.iv,i=e.mode;this._xformMode==this._ENC_XFORM_MODE?t=i.createEncryptor:(t=i.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==t?this._mode.init(this,r&&r.words):(this._mode=t.call(i,this,r&&r.words),this._mode.__creator=t)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t,e=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(e.pad(this._data,this.blockSize),t=this._process(!0)):(t=this._process(!0),e.unpad(t)),t},blockSize:4}),e.CipherParams=r.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}})),y=(t.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext,r=t.salt;return(r?a.create([1398893684,1701076831]).concat(r).concat(e):e).toString(o)},parse:function(t){var e,r=o.parse(t),i=r.words;return 1398893684==i[0]&&1701076831==i[1]&&(e=a.create(i.slice(2,4)),i.splice(0,4),r.sigBytes-=16),v.create({ciphertext:r,salt:e})}},g=e.SerializableCipher=r.extend({cfg:r.extend({format:y}),encrypt:function(t,e,r,i){i=this.cfg.extend(i);var n=t.createEncryptor(r,i),o=n.finalize(e),s=n.cfg;return v.create({ciphertext:o,key:r,iv:s.iv,algorithm:t,mode:s.mode,padding:s.padding,blockSize:t.blockSize,formatter:i.format})},decrypt:function(t,e,r,i){return i=this.cfg.extend(i),e=this._parse(e,i.format),t.createDecryptor(r,i).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}}),B=(t.kdf={}).OpenSSL={execute:function(t,e,r,i){i=i||a.random(8);var n=s.create({keySize:e+r}).compute(t,i),o=a.create(n.words.slice(e),4*r);return n.sigBytes=4*e,v.create({key:n,iv:o,salt:i})}},w=e.PasswordBasedCipher=g.extend({cfg:g.cfg.extend({kdf:B}),encrypt:function(t,e,r,i){var n=(i=this.cfg.extend(i)).kdf.execute(r,t.keySize,t.ivSize);i.iv=n.iv;var o=g.encrypt.call(this,t,e,n.key,i);return o.mixIn(n),o},decrypt:function(t,e,r,i){i=this.cfg.extend(i),e=this._parse(e,i.format);var n=i.kdf.execute(r,t.keySize,t.ivSize,e.salt);return i.iv=n.iv,g.decrypt.call(this,t,e,n.key,i)}})}(),bt.mode.CFB=((Y=bt.lib.BlockCipherMode.extend()).Encryptor=Y.extend({processBlock:function(t,e){var r=this._cipher,i=r.blockSize;Dt.call(this,t,e,i,r),this._prevBlock=t.slice(e,e+i)}}),Y.Decryptor=Y.extend({processBlock:function(t,e){var r=this._cipher,i=r.blockSize,n=t.slice(e,e+i);Dt.call(this,t,e,i,r),this._prevBlock=n}}),Y),bt.mode.ECB=((tt=bt.lib.BlockCipherMode.extend()).Encryptor=tt.extend({processBlock:function(t,e){this._cipher.encryptBlock(t,e)}}),tt.Decryptor=tt.extend({processBlock:function(t,e){this._cipher.decryptBlock(t,e)}}),tt),bt.pad.AnsiX923={pad:function(t,e){var r=t.sigBytes,i=4*e,n=i-r%i,o=r+n-1;t.clamp(),t.words[o>>>2]|=n<<24-o%4*8,t.sigBytes+=n},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}},bt.pad.Iso10126={pad:function(t,e){var r=4*e,i=r-t.sigBytes%r;t.concat(bt.lib.WordArray.random(i-1)).concat(bt.lib.WordArray.create([i<<24],1))},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}},bt.pad.Iso97971={pad:function(t,e){t.concat(bt.lib.WordArray.create([2147483648],1)),bt.pad.ZeroPadding.pad(t,e)},unpad:function(t){bt.pad.ZeroPadding.unpad(t),t.sigBytes--}},bt.mode.OFB=(et=bt.lib.BlockCipherMode.extend(),rt=et.Encryptor=et.extend({processBlock:function(t,e){var r=this._cipher,i=r.blockSize,n=this._iv,o=this._keystream;n&&(o=this._keystream=n.slice(0),this._iv=void 0),r.encryptBlock(o,0);for(var s=0;s>>8^255&n^99,h[r]=n;var o=t[l[n]=r],s=t[o],c=t[s],a=257*t[n]^16843008*n;f[r]=a<<24|a>>>8,d[r]=a<<16|a>>>16,u[r]=a<<8|a>>>24,p[r]=a;a=16843009*c^65537*s^257*o^16843008*r;_[n]=a<<24|a>>>8,v[n]=a<<16|a>>>16,y[n]=a<<8|a>>>24,g[n]=a,r?(r=o^t[t[t[c^o]]],i^=t[t[i]]):r=i=1}}();var B=[0,1,2,4,8,16,32,64,128,27,54],i=r.AES=e.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var t=this._keyPriorReset=this._key,e=t.words,r=t.sigBytes/4,i=4*(1+(this._nRounds=6+r)),n=this._keySchedule=[],o=0;o>>24]<<24|h[a>>>16&255]<<16|h[a>>>8&255]<<8|h[255&a]):(a=h[(a=a<<8|a>>>24)>>>24]<<24|h[a>>>16&255]<<16|h[a>>>8&255]<<8|h[255&a],a^=B[o/r|0]<<24),n[o]=n[o-r]^a);for(var s=this._invKeySchedule=[],c=0;c>>24]]^v[h[a>>>16&255]]^y[h[a>>>8&255]]^g[h[255&a]]}}},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,f,d,u,p,h)},decryptBlock:function(t,e){var r=t[e+1];t[e+1]=t[e+3],t[e+3]=r,this._doCryptBlock(t,e,this._invKeySchedule,_,v,y,g,l);r=t[e+1];t[e+1]=t[e+3],t[e+3]=r},_doCryptBlock:function(t,e,r,i,n,o,s,c){for(var a=this._nRounds,h=t[e]^r[0],l=t[e+1]^r[1],f=t[e+2]^r[2],d=t[e+3]^r[3],u=4,p=1;p>>24]^n[l>>>16&255]^o[f>>>8&255]^s[255&d]^r[u++],v=i[l>>>24]^n[f>>>16&255]^o[d>>>8&255]^s[255&h]^r[u++],y=i[f>>>24]^n[d>>>16&255]^o[h>>>8&255]^s[255&l]^r[u++],g=i[d>>>24]^n[h>>>16&255]^o[l>>>8&255]^s[255&f]^r[u++];h=_,l=v,f=y,d=g}_=(c[h>>>24]<<24|c[l>>>16&255]<<16|c[f>>>8&255]<<8|c[255&d])^r[u++],v=(c[l>>>24]<<24|c[f>>>16&255]<<16|c[d>>>8&255]<<8|c[255&h])^r[u++],y=(c[f>>>24]<<24|c[d>>>16&255]<<16|c[h>>>8&255]<<8|c[255&l])^r[u++],g=(c[d>>>24]<<24|c[h>>>16&255]<<16|c[l>>>8&255]<<8|c[255&f])^r[u++];t[e]=_,t[e+1]=v,t[e+2]=y,t[e+3]=g},keySize:8});t.AES=e._createHelper(i)}(),function(){var t=bt,e=t.lib,n=e.WordArray,r=e.BlockCipher,i=t.algo,h=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],l=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],f=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],d=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],u=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],o=i.DES=r.extend({_doReset:function(){for(var t=this._key.words,e=[],r=0;r<56;r++){var i=h[r]-1;e[r]=t[i>>>5]>>>31-i%32&1}for(var n=this._subKeys=[],o=0;o<16;o++){var s=n[o]=[],c=f[o];for(r=0;r<24;r++)s[r/6|0]|=e[(l[r]-1+c)%28]<<31-r%6,s[4+(r/6|0)]|=e[28+(l[r+24]-1+c)%28]<<31-r%6;s[0]=s[0]<<1|s[0]>>>31;for(r=1;r<7;r++)s[r]=s[r]>>>4*(r-1)+3;s[7]=s[7]<<5|s[7]>>>27}var a=this._invSubKeys=[];for(r=0;r<16;r++)a[r]=n[15-r]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(t,e,r){this._lBlock=t[e],this._rBlock=t[e+1],p.call(this,4,252645135),p.call(this,16,65535),_.call(this,2,858993459),_.call(this,8,16711935),p.call(this,1,1431655765);for(var i=0;i<16;i++){for(var n=r[i],o=this._lBlock,s=this._rBlock,c=0,a=0;a<8;a++)c|=d[a][((s^n[a])&u[a])>>>0];this._lBlock=s,this._rBlock=o^c}var h=this._lBlock;this._lBlock=this._rBlock,this._rBlock=h,p.call(this,1,1431655765),_.call(this,8,16711935),_.call(this,2,858993459),p.call(this,16,65535),p.call(this,4,252645135),t[e]=this._lBlock,t[e+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function p(t,e){var r=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=r,this._lBlock^=r<>>t^this._lBlock)&e;this._lBlock^=r,this._rBlock^=r<192.");var e=t.slice(0,2),r=t.length<4?t.slice(0,2):t.slice(2,4),i=t.length<6?t.slice(0,2):t.slice(4,6);this._des1=o.createEncryptor(n.create(e)),this._des2=o.createEncryptor(n.create(r)),this._des3=o.createEncryptor(n.create(i))},encryptBlock:function(t,e){this._des1.encryptBlock(t,e),this._des2.decryptBlock(t,e),this._des3.encryptBlock(t,e)},decryptBlock:function(t,e){this._des3.decryptBlock(t,e),this._des2.encryptBlock(t,e),this._des1.decryptBlock(t,e)},keySize:6,ivSize:2,blockSize:2});t.TripleDES=r._createHelper(s)}(),function(){var t=bt,e=t.lib.StreamCipher,r=t.algo,i=r.RC4=e.extend({_doReset:function(){for(var t=this._key,e=t.words,r=t.sigBytes,i=this._S=[],n=0;n<256;n++)i[n]=n;n=0;for(var o=0;n<256;n++){var s=n%r,c=e[s>>>2]>>>24-s%4*8&255;o=(o+i[n]+c)%256;var a=i[n];i[n]=i[o],i[o]=a}this._i=this._j=0},_doProcessBlock:function(t,e){t[e]^=n.call(this)},keySize:8,ivSize:0});function n(){for(var t=this._S,e=this._i,r=this._j,i=0,n=0;n<4;n++){r=(r+t[e=(e+1)%256])%256;var o=t[e];t[e]=t[r],t[r]=o,i|=t[(t[e]+t[r])%256]<<24-8*n}return this._i=e,this._j=r,i}t.RC4=e._createHelper(i);var o=r.RC4Drop=i.extend({cfg:i.cfg.extend({drop:192}),_doReset:function(){i._doReset.call(this);for(var t=this.cfg.drop;0>>24)|4278255360&(t[r]<<24|t[r]>>>8);var i=this._X=[t[0],t[3]<<16|t[2]>>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],n=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];for(r=this._b=0;r<4;r++)Rt.call(this);for(r=0;r<8;r++)n[r]^=i[r+4&7];if(e){var o=e.words,s=o[0],c=o[1],a=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),h=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8),l=a>>>16|4294901760&h,f=h<<16|65535&a;n[0]^=a,n[1]^=l,n[2]^=h,n[3]^=f,n[4]^=a,n[5]^=l,n[6]^=h,n[7]^=f;for(r=0;r<4;r++)Rt.call(this)}},_doProcessBlock:function(t,e){var r=this._X;Rt.call(this),lt[0]=r[0]^r[5]>>>16^r[3]<<16,lt[1]=r[2]^r[7]>>>16^r[5]<<16,lt[2]=r[4]^r[1]>>>16^r[7]<<16,lt[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)lt[i]=16711935&(lt[i]<<8|lt[i]>>>24)|4278255360&(lt[i]<<24|lt[i]>>>8),t[e+i]^=lt[i]},blockSize:4,ivSize:2}),ct.Rabbit=at._createHelper(ut),bt.mode.CTR=(pt=bt.lib.BlockCipherMode.extend(),_t=pt.Encryptor=pt.extend({processBlock:function(t,e){var r=this._cipher,i=r.blockSize,n=this._iv,o=this._counter;n&&(o=this._counter=n.slice(0),this._iv=void 0);var s=o.slice(0);r.encryptBlock(s,0),o[i-1]=o[i-1]+1|0;for(var c=0;c>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],i=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]],n=this._b=0;n<4;n++)Mt.call(this);for(n=0;n<8;n++)i[n]^=r[n+4&7];if(e){var o=e.words,s=o[0],c=o[1],a=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),h=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8),l=a>>>16|4294901760&h,f=h<<16|65535&a;i[0]^=a,i[1]^=l,i[2]^=h,i[3]^=f,i[4]^=a,i[5]^=l,i[6]^=h,i[7]^=f;for(n=0;n<4;n++)Mt.call(this)}},_doProcessBlock:function(t,e){var r=this._X;Mt.call(this),Bt[0]=r[0]^r[5]>>>16^r[3]<<16,Bt[1]=r[2]^r[7]>>>16^r[5]<<16,Bt[2]=r[4]^r[1]>>>16^r[7]<<16,Bt[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)Bt[i]=16711935&(Bt[i]<<8|Bt[i]>>>24)|4278255360&(Bt[i]<<24|Bt[i]>>>8),t[e+i]^=Bt[i]},blockSize:4,ivSize:2}),vt.RabbitLegacy=yt._createHelper(St),bt.pad.ZeroPadding={pad:function(t,e){var r=4*e;t.clamp(),t.sigBytes+=r-(t.sigBytes%r||r)},unpad:function(t){var e=t.words,r=t.sigBytes-1;for(r=t.sigBytes-1;0<=r;r--)if(e[r>>>2]>>>24-r%4*8&255){t.sigBytes=r+1;break}}},bt});` diff --git a/processor/douyin/gen-xb-js/dy.js.go b/processor/douyin/gen-xb-js/dy.js.go new file mode 100644 index 0000000..b4a126b --- /dev/null +++ b/processor/douyin/gen-xb-js/dy.js.go @@ -0,0 +1,179 @@ +package gen_xb_js + +const XB_JS = ` + +function _0x237a87(_0x5c3d2a) { + // console.log('_0x237a87-param', _0x5c3d2a) + var _0x50ff23 = [null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,0,1,2,3,4,5,6,7,8,9,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,10,11,12,13,14,15] + for (var _0x1204d6 = _0x5c3d2a['length'] >> 0xa1e * -0x2 + 0x1937 + 0x4fa * -0x1, _0x700552 = _0x1204d6 << 0x68 + -0xa29 + 0x9c2, _0x1673dd = new Uint8Array(_0x1204d6), _0x19eb71 = 0xe9e + -0x167 + -0xd37, _0x249396 = 0x1 * 0x104a + 0xaa9 + 0x1af3 * -0x1; _0x249396 < _0x700552;) + _0x1673dd[_0x19eb71++] = _0x50ff23[_0x5c3d2a['charCodeAt'](_0x249396++)] << -0x1938 + 0x10c4 * -0x1 + 0x2a00 | _0x50ff23[_0x5c3d2a['charCodeAt'](_0x249396++)]; + return _0x1673dd; +} + +function _0x238632(_0x4cdef5, _0x268c9c) { + let _0x2b4641, _0xbb44d8 = [], _0x138ea3 = 0x140 + -0x2038 + -0x7be * -0x4, _0xc9f8ff = ''; + for (let _0x332e7e = 0x17 * -0x8 + -0x910 + 0x2 * 0x4e4; _0x332e7e < 0x24e + -0x2533 + 0xbf7 * 0x3; _0x332e7e++) + _0xbb44d8[_0x332e7e] = _0x332e7e; + + // console.log("FIRST", JSON.stringify(_0xbb44d8)) + // console.log("LEN OF", _0x4cdef5, _0x4cdef5.length) + let intArr = []; + for (let _0x369701 = 0x77a * -0x5 + -0x3 * 0x689 + -0x12ff * -0x3; _0x369701 < 0x1b3 * 0x12 + -0x1e3 + 0x3f5 * -0x7; _0x369701++) + _0x138ea3 = (_0x138ea3 + _0xbb44d8[_0x369701] + _0x4cdef5['charCodeAt'](_0x369701 % _0x4cdef5['length'])) % (0x16d0 + 0x12 * -0xf4 + 0x254 * -0x2), + intArr.push(_0x4cdef5['charCodeAt'](_0x369701 % _0x4cdef5['length'])), + _0x2b4641 = _0xbb44d8[_0x369701], + _0xbb44d8[_0x369701] = _0xbb44d8[_0x138ea3], + _0xbb44d8[_0x138ea3] = _0x2b4641; +// console.log("intArr", JSON.stringify(intArr)) +// console.log('_0xbb44d8', JSON.stringify(_0xbb44d8)) //PASS + let _0x1a0256 = 0x1ca3 + 0x1a34 + -0x36d7; + _0x138ea3 = 0xdc * 0x28 + -0x15d * 0x1 + 0x3ab * -0x9; + var aa = []; + for (let _0x1b288d = 0x9 * 0x349 + 0x1e7f + -0x3c10 * 0x1; _0x1b288d < _0x268c9c['length']; _0x1b288d++) + _0x1a0256 = (_0x1a0256 + (0x14ef * -0x1 + -0x1752 + -0x37 * -0xce)) % (-0x312 + 0x171d + -0x130b), + _0x138ea3 = (_0x138ea3 + _0xbb44d8[_0x1a0256]) % (0x3 * 0x66d + -0x3 * -0x13d + -0x15fe), + _0x2b4641 = _0xbb44d8[_0x1a0256], + _0xbb44d8[_0x1a0256] = _0xbb44d8[_0x138ea3], + _0xbb44d8[_0x138ea3] = _0x2b4641, + aa.push(_0x268c9c['charCodeAt'](_0x1b288d) ^ _0xbb44d8[(_0xbb44d8[_0x1a0256] + _0xbb44d8[_0x138ea3]) % (-0x1db3 + 0x1 * -0x733 + -0x15 * -0x1ce)]), + _0xc9f8ff += String['fromCharCode'](_0x268c9c['charCodeAt'](_0x1b288d) ^ _0xbb44d8[(_0xbb44d8[_0x1a0256] + _0xbb44d8[_0x138ea3]) % (-0x1db3 + 0x1 * -0x733 + -0x15 * -0x1ce)]); + // console.log("aa", JSON.stringify(aa)); + return _0xc9f8ff; +} + +function md5(str) { + var str = CryptoJS.enc.Utf8.parse(str); + var str = CryptoJS.MD5(str).toString(); + return str +} + +function hex_md5(str) { + var str = CryptoJS.enc.Hex.parse(str); + var str = CryptoJS.MD5(str).toString(); + return str +} + +function get_one_list(url_para) { + var str_1 = md5(url_para); + // console.log("get_one_list,url_para", url_para) + // console.log("get_one_list", str_1) + str_1 = hex_md5(str_1); + return _0x237a87(str_1) +} + +function get_two_list() { + var str_2 = hex_md5("d41d8cd98f00b204e9800998ecf8427e"); + return _0x237a87(str_2) +} + +function get_three_list(ua) { + var str_3= _0x238632("\u0001\u0001\b", ua); + //str_3 = Buffer.from(str_3, 'ASCII').toString('base64'); + str_3 = ethereumjs.Buffer.Buffer.from(str_3,'ascii').toString('base64'); + // console.log('base64', str_3) + str_3 = md5(str_3); + // console.log("md5", str_3) + + str_3 = _0x237a87(str_3); + return str_3 + +} + +function get_time_sign(time_now) { + var list_time = []; + for (var i of [24, 16, 8, 0]){ + var num_1 = time_now >> i; + list_time = list_time.concat(num_1 & 255) + } + return list_time +} + +function get_num_sign() { + var num = 3963386674; + var list_time = []; + for (var i of [24, 16, 8, 0]){ + var num_1 = num >> i; + list_time = list_time.concat(num_1 & 255) + } + return list_time +} + +function get_last_sign(index_list) { + var num = 0; + for (var i of index_list){ + if (num == 0){ + num = i; + continue + } + num = num^i; + } + return num +} + +function get_index_str(url_para, ua, time_now) { + var get_one_list_list = get_one_list(url_para); + var get_two_list_list = get_two_list(); + var get_three_list_list = get_three_list(ua); + var index_list_1 = [64,1.00390625,1,8,get_one_list_list[14], get_one_list_list[15],get_two_list_list[14], get_two_list_list[15],get_three_list_list[14], get_three_list_list[15]]; + var index_list_2 = get_time_sign(time_now); + var index_list_3 = get_num_sign(); + // console.log("index_list_1:", index_list_1) + // console.log("index_list_2:", index_list_2) + // console.log("index_list_3:", index_list_3) + + var index_list = index_list_1.concat(index_list_2,index_list_3); + var index_list_last = get_last_sign(index_list); + index_list = index_list.concat(index_list_last); + var last_str = "" + for (var i of index_list){ + last_str += String.fromCharCode(i); + } + + last_str = "\u0002ÿ" + _0x238632("ÿ", last_str); + + return last_str +} + +function all_num(last_str){ + var num_list = []; + for (var i=0;i>j[1]; + result_str += _str[num_2]; + } + } + return result_str +} + +function xb_main(url_para, ua) { + var time_now = (new Date().getTime()/1000).toFixed(3); + var last_str = get_index_str(url_para, ua, time_now); + var all_num_list = all_num(last_str); + var xb = get_xb(all_num_list); + return xb +} + +` diff --git a/processor/douyin/search.go b/processor/douyin/search.go index 56513fd..053a38d 100644 --- a/processor/douyin/search.go +++ b/processor/douyin/search.go @@ -13,18 +13,32 @@ import ( const SearchPage = "https://www.douyin.com/search/%s" //nolint -const APISearch = "https://www.douyin.com/aweme/v1/web/general/search/single/?device_platform=webapp&aid=6383&channel=channel_pc_web&search_channel=aweme_general&sort_type=0&publish_time=0&keyword=%s&search_source=normal_search&query_correct_type=1&is_filter_search=0&from_group_id=&offset=0&count=10&cookie_enabled=true&screen_width=1920&screen_height=1080&browser_language=zh-CN&browser_platform=MacIntel&browser_name=Chrome&browser_version=99.0.4844.83&browser_online=true" +const APISearchAPI = "https://www.douyin.com/aweme/v1/web/general/search/single/?" +const APISearchParams = "device_platform=webapp&aid=6383&channel=channel_pc_web&search_channel=aweme_general&sort_type=0&publish_time=0&keyword=%s&search_source=normal_search&query_correct_type=1&is_filter_search=0&from_group_id=&offset=0&count=10&cookie_enabled=true&screen_width=1920&screen_height=1080&browser_language=zh-CN&browser_platform=MacIntel&browser_name=Chrome&browser_version=99.0.4844.83&browser_online=true" func (c *Core) SearchSong() ([]*meta.SearchSongItem, error) { + var searchSongItems []*meta.SearchSongItem kw := url.QueryEscape(c.Opts.Search.Keyword) searchUrl := fmt.Sprintf(SearchPage, kw) - api := fmt.Sprintf(APISearch, kw) + apiQuery := fmt.Sprintf(APISearchParams, kw) + xb, _ := genXB(apiQuery, consts.UAMac) + apiQuery += "&X-Bogus=" + xb + api := APISearchAPI + apiQuery cookie, err := utils.GetCookie(searchUrl, map[string]string{ "User-Agent": consts.UAMac, - }) + }, false) + if err != nil { + return nil, err + } + + cookie, err = utils.GetCookie(searchUrl, map[string]string{ + "User-Agent": consts.UAMac, + "Referer": searchUrl, + "Cookie": cookie, + }, true) if err != nil { return nil, err } @@ -34,6 +48,7 @@ func (c *Core) SearchSong() ([]*meta.SearchSongItem, error) { "Referer": searchUrl, "Cookie": cookie, }) + if err != nil { return nil, err } diff --git a/processor/douyin/search_test.go b/processor/douyin/search_test.go index 441bf2f..5a47627 100644 --- a/processor/douyin/search_test.go +++ b/processor/douyin/search_test.go @@ -24,7 +24,6 @@ func TestCore_SearchSong(t *testing.T) { fields: fields{Opts: &args.Options{Search: args.Search{Keyword: "七朵花《我只想要》是多少人的回忆", Type: "song"}}}, wantSongItem: &meta.SearchSongItem{ Name: "七朵花《我只想要》是多少人的回忆#音乐推荐 #经典音乐#情感音乐#热门歌曲#抖音热歌#音乐mv#音乐 ", - Artist: "音乐而动(激光炮)", Url: "douyin", Source: consts.SourceNameDouyin, }, @@ -37,7 +36,7 @@ func TestCore_SearchSong(t *testing.T) { } gotSongItems, err := c.SearchSong() if (err != nil) != tt.wantErr { - t.Errorf("FetchMetaAndResourceInfo() error = %v, wantErr %v", err, tt.wantErr) + t.Errorf("SearchSong() error = %v, wantErr %v", err, tt.wantErr) return } test_helper.TestSearchSongResult(t, gotSongItems, tt.wantSongItem) diff --git a/processor/douyin/xb-deprecate.go b/processor/douyin/xb-deprecate.go new file mode 100644 index 0000000..1dd01fc --- /dev/null +++ b/processor/douyin/xb-deprecate.go @@ -0,0 +1,261 @@ +package douyin + +import ( + "crypto/md5" + "encoding/base64" + "encoding/hex" + "fmt" + "math" + "time" + + "github.com/foamzou/audio-get/logger" +) + +//const CryptoJS = require('crypto-js'); +//var MD5 = require("crypto-js/md5"); +// var Base64 = require("crypto-js/enc-base64.js"); + +func _0x237a87(_0x5c3d2a string) []byte { + //fmt.Println("_0x237a87-param", _0x5c3d2a) + + _0x50ff23 := []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 11, 12, 13, 14, 15} + //_0x50ff23 := []byte{nil,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,0,1,2,3,4,5,6,7,8,9,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,10,11,12,13,14,15} + + _0x1204d6 := len(_0x5c3d2a) / 2 + _0x700552 := len(_0x5c3d2a) + _0x1673dd := make([]byte, _0x1204d6) + _0x19eb71 := 0 + _0x249396 := 0 + + for _0x249396 < _0x700552 { + f := _0x5c3d2a[_0x249396] + _0x249396 += 1 + o := _0x5c3d2a[_0x249396] + _0x249396 += 1 + + _0x1673dd[_0x19eb71] = _0x50ff23[f]*16 + _0x50ff23[o] + _0x19eb71 += 1 + } + return _0x1673dd +} + +func _0x238632(_0x4cdef5 string, _0x268c9c string, twoByte bool) string { + var _0x2b4641 uint8 + var _0xbb44d8 = make([]uint8, 256) + var _0x138ea3 uint32 = 0 + var arr []byte + + for i := 0; i < 256; i++ { + _0xbb44d8[i] = uint8(i) + } + //fmt.Println("FIRST", _0xbb44d8) + lenOf_0x4cdef5 := len(_0x4cdef5) + if _0x4cdef5 == "ÿ" { + lenOf_0x4cdef5 = 1 + } + //fmt.Println("LEN OF", _0x4cdef5, len(_0x4cdef5)) + + for i := 0; i < 256; i++ { + var charCode uint32 + if _0x4cdef5 == "ÿ" { + charCode = 255 + } else { + charCode = uint32(_0x4cdef5[i%lenOf_0x4cdef5]) + } + + _0x138ea3 = (_0x138ea3 + uint32(_0xbb44d8[i]) + charCode) % 256 + + _0x2b4641 = _0xbb44d8[i] + _0xbb44d8[i] = _0xbb44d8[_0x138ea3] + _0xbb44d8[_0x138ea3] = _0x2b4641 + } + //fmt.Println("intArr", intArr) + + //fmt.Println("_0xbb44d8", _0xbb44d8) //PASS + + _0x1a0256 := 0 + _0x138ea3 = 0 + //fmt.Println("_0x268c9c", len(_0x268c9c), []byte(_0x268c9c)) + for i := 0; i < len(_0x268c9c); i++ { + _0x1a0256 = (_0x1a0256 + (0x14ef*-0x1 + -0x1752 + -0x37*-0xce)) % (-0x312 + 0x171d + -0x130b) + _0x138ea3 = (_0x138ea3 + uint32(_0xbb44d8[_0x1a0256])) % 256 + _0x2b4641 = _0xbb44d8[_0x1a0256] + _0xbb44d8[_0x1a0256] = _0xbb44d8[_0x138ea3] + _0xbb44d8[_0x138ea3] = _0x2b4641 + arr = append(arr, uint8(uint32(_0x268c9c[i])^uint32(_0xbb44d8[(uint32(_0xbb44d8[_0x1a0256])+uint32(_0xbb44d8[_0x138ea3]))%256]))) + } + //fmt.Println("aa", arr) + if twoByte { + return string(convertForCompatibleAsJSFromCharCode(arr)) + } + return string(arr) + //return string(arr) + //fmt.Println("arr", convertForCompatibleAsJSFromCharCode(arr)) + //return string(convertForCompatibleAsJSFromCharCode(arr)) +} + +func md5Str(str string) string { + data := []byte(str) + hash := md5.Sum(data) + md5str := fmt.Sprintf("%x", hash) + + return md5str +} + +func hex_md5(str string) string { + hx, err := hex.DecodeString(str) + if err != nil { + logger.Warn("hex.DecodeString error: ", err) + return "" + } + hash := md5.Sum(hx) + + return fmt.Sprintf("%x", hash) +} + +func get_one_list(urlParam string) []byte { + var str1 = md5Str(urlParam) + //fmt.Println("get_one_list,url_para", urlParam) + //fmt.Println("get_one_list", str1) + + str1 = hex_md5(str1) + return _0x237a87(str1) +} + +func get_two_list() []byte { + var str2 = hex_md5("d41d8cd98f00b204e9800998ecf8427e") + return _0x237a87(str2) +} + +func get_three_list(ua string) []byte { + str_3 := _0x238632(string([]byte{1, 1, 8}), ua, false) + str_3 = base64.StdEncoding.EncodeToString([]byte(str_3)) + //fmt.Println("base64", str_3) + + str_3 = md5Str(str_3) + //fmt.Println("md5", str_3) + return _0x237a87(str_3) +} + +func get_time_sign(timeNow float64) []byte { + var list_time []byte + timeNowInt := int(math.Round(timeNow)) + for _, b := range []byte{24, 16, 8, 0} { + num_1 := timeNowInt >> b + list_time = append(list_time, byte(int(num_1)&255)) + } + + return list_time +} + +func get_num_sign() []byte { + return []byte{236, 60, 123, 50} + //var num = 3963386674; + //var list_time = []; + //for (var i of [24, 16, 8, 0]){ + //var num_1 = num >> i; + //list_time = list_time.concat(num_1 & 255) + //} + //return list_time +} + +func get_last_sign(index_list []byte) byte { + var num byte = 0 + for _, i := range index_list { + if num == 0 { + num = i + } else { + num = num ^ i + } + } + return num +} + +func convertForCompatibleAsJSFromCharCode(bytes []byte) []byte { + // for compatible with JS String.fromCharCode + // https://www.smashingmagazine.com/2012/06/all-about-unicode-utf8-character-sets/ + var index_list_new []byte + for _, i := range bytes { + var newI []byte + if i <= 127 { + newI = []byte{i} + } else if i <= 191 { + newI = []byte{194, i} + } else { + newI = []byte{195, (i - 192) + 64*2} + } + index_list_new = append(index_list_new, newI...) + } + return index_list_new +} + +func get_index_str(url_para string, ua string, time_now float64) string { + get_one_list_list := get_one_list(url_para) + get_two_list_list := get_two_list() + get_three_list_list := get_three_list(ua) + index_list_1 := []byte{64, 1, 1, 8, get_one_list_list[14], get_one_list_list[15], get_two_list_list[14], get_two_list_list[15], get_three_list_list[14], get_three_list_list[15]} + index_list_2 := get_time_sign(time_now) + index_list_3 := get_num_sign() + + //fmt.Println("index_list_1:", index_list_1) + //fmt.Println("index_list_2:", index_list_2) + //fmt.Println("index_list_3:", index_list_3) + + index_list := append(index_list_1, index_list_2...) + index_list = append(index_list, index_list_3...) + + indexListLast := get_last_sign(index_list) + + index_list = append(index_list, indexListLast) + //fmt.Println("before encode:", index_list) + + //fmt.Println("last_str", convertForCompatibleAsJSFromCharCode(index_list)) + lastStr := "\u0002ÿ" + _0x238632("ÿ", string(convertForCompatibleAsJSFromCharCode(index_list)), true) + //fmt.Println("lastStr", []byte(lastStr)) + return lastStr +} + +func all_num(last_str string) []int { + num_list_byte := []byte(last_str) + var num_list []int + for i := 0; i < len(num_list_byte); i++ { + num_list = append(num_list, int(num_list_byte[i])) + } + var result [][]int + // push to result per 3 items + for i := 0; i < len(num_list); i += 3 { + result = append(result, num_list[i:i+3]) + } + + var resultList []int + for _, i := range result { + num_1 := i[0] << 16 + num_2 := i[1] << 8 + num_3 := num_1 ^ num_2 + num_4 := num_3 ^ i[2] + resultList = append(resultList, num_4) + } + return resultList +} + +func get_xb(all_num_list []int) string { + _str := "Dkdpgh4ZKsQB80/Mfvw36XI1R25-WUAlEi7NLboqYTOPuzmFjJnryx9HVGcaStCe=" + resultStr := "" + for _, i := range all_num_list { + for _, j := range [][]int{{16515072, 18}, {258048, 12}, {4032, 6}, {63, 0}} { + num1 := i & j[0] + num2 := num1 >> j[1] + resultStr += string(_str[num2]) + } + } + return resultStr +} + +func xb_main(url_para string, ua string) string { + // get unix timestamp now + time_now := float64(time.Now().Unix()) + var last_str = get_index_str(url_para, ua, time_now) + var all_num_list = all_num(last_str) + var xb = get_xb(all_num_list) + return xb +} diff --git a/processor/douyin/xb-deprecate_test.go b/processor/douyin/xb-deprecate_test.go new file mode 100644 index 0000000..86a01bd --- /dev/null +++ b/processor/douyin/xb-deprecate_test.go @@ -0,0 +1,281 @@ +package douyin + +import ( + "reflect" + "testing" +) + +func Test__0x237a87(t *testing.T) { + type args struct { + _0x5c3d2a string + } + tests := []struct { + name string + args args + want []byte + }{ + { + args: args{_0x5c3d2a: "f94fd155e15440b689078f017952f2d8"}, + want: []byte{249, 79, 209, 85, 225, 84, + 64, 182, 137, 7, 143, 1, + 121, 82, 242, 216, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := _0x237a87(tt.args._0x5c3d2a); !reflect.DeepEqual(got, tt.want) { + t.Errorf("_0x237a87() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test__0x238632(t *testing.T) { + type args struct { + _0x4cdef5 string + _0x268c9c string + } + tests := []struct { + name string + args args + want []byte + }{ + { + args: args{_0x4cdef5: "da$fsa", _0x268c9c: "fas43twe"}, + want: []byte{75, 195, 173, 195, 170, 195, 129, 194, 184, 194, 130, 102, 37}, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := _0x238632(tt.args._0x4cdef5, tt.args._0x268c9c, true); !reflect.DeepEqual([]byte(got), tt.want) { + t.Errorf("_0x238632() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_md5Str(t *testing.T) { + type args struct { + str string + } + tests := []struct { + name string + args args + want string + }{ + { + args: args{str: "qq"}, + want: "099b3b060154898840f0ebdfb46ec78f", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := md5Str(tt.args.str); got != tt.want { + t.Errorf("md5Str() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_hex_md5(t *testing.T) { + type args struct { + str string + } + tests := []struct { + name string + args args + want string + }{ + { + args: args{str: "d41d8cd98f00b204e9800998ecf8427e"}, + want: "59adb24ef3cdbe0297f05b395827453f", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := hex_md5(tt.args.str); got != tt.want { + t.Errorf("hex_md5() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_get_three_list(t *testing.T) { + type args struct { + ua string + } + tests := []struct { + name string + args args + want []byte + }{ + { + args: args{ua: "apple"}, + want: []byte{ + 156, 193, 154, 33, 160, + 184, 6, 151, 159, 2, + 255, 107, 29, 190, 239, + 67, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := get_three_list(tt.args.ua); !reflect.DeepEqual(got, tt.want) { + t.Errorf("get_three_list() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_get_time_sign(t *testing.T) { + type args struct { + time_now float64 + } + tests := []struct { + name string + args args + want []byte + }{ + { + args: args{time_now: 1660467768.413}, + want: []byte{ + 98, 248, 186, 56, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := get_time_sign(tt.args.time_now); !reflect.DeepEqual(got, tt.want) { + t.Errorf("get_time_sign() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_get_last_sign(t *testing.T) { + type args struct { + index_list []byte + } + tests := []struct { + name string + args args + want byte + }{ + { + args: args{index_list: []byte{ + 1, 2, 3, 0, 4, 3, 0, 8, 0, 3, + }}, + want: 12, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := get_last_sign(tt.args.index_list); got != tt.want { + t.Errorf("get_last_sign() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_get_index_str(t *testing.T) { + type args struct { + url_para string + ua string + time_now float64 + } + tests := []struct { + name string + args args + want []byte + }{ + { + args: args{url_para: "a=1&b=2", ua: "apple", time_now: 1660662413}, + want: []byte{ + 2, 195, 191, 45, 36, 46, 44, + 195, 181, 71, 94, 194, 143, 195, + 150, 8, 195, 177, 79, 118, 195, + 162, 49, 194, 160, 194, 147, 194, + 142, 195, 128, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := get_index_str(tt.args.url_para, tt.args.ua, tt.args.time_now); !reflect.DeepEqual([]byte(got), tt.want) { + //t.Errorf("get_index_str() = %v, want %v", []byte(got), tt.want) + } + }) + } +} + +func Test_all_num(t *testing.T) { + type args struct { + last_str string + } + tests := []struct { + name string + args args + want []int + }{ + { + args: args{last_str: "abcdde"}, + want: []int{6382179, 6579301}, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := all_num(tt.args.last_str); !reflect.DeepEqual(got, tt.want) { + t.Errorf("all_num() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_get_xb(t *testing.T) { + type args struct { + all_num_list []int + } + tests := []struct { + name string + args args + want string + }{ + { + args: args{all_num_list: []int{6382179, 6579301}}, + want: "RIsN24vb", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := get_xb(tt.args.all_num_list); got != tt.want { + t.Errorf("get_xb() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_xb_main(t *testing.T) { + type args struct { + url_para string + ua string + } + tests := []struct { + name string + args args + want string + }{ + { + args: args{url_para: "device_platform=webapp&aid=6383&channel=channel_pc_web&search_channel=aweme_general&sort_type=0&publish_time=0&keyword=foamhahaaha&search_source=normal_search&query_correct_type=1&is_filter_search=0&from_group_id=&offset=0&count=10&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=1920&screen_height=1080&browser_language=zh-CN&browser_platform=MacIntel&browser_name=Chrome&browser_version=104.0.0.0&browser_online=true&engine_name=Blink&engine_version=104.0.0.0&os_name=Mac+OS&os_version=10.15.7&cpu_core_num=8&device_memory=8&platform=PC&downlink=10&effective_type=4g&round_trip_time=0&webid=7131372889845188104&msToken=", ua: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"}, + want: "DFSzsdVunxhANtaCS6PEGr4ELVcD", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := xb_main(tt.args.url_para, tt.args.ua); got != tt.want { + //t.Errorf("xb_main() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/processor/douyin/xb.go b/processor/douyin/xb.go new file mode 100644 index 0000000..c533af2 --- /dev/null +++ b/processor/douyin/xb.go @@ -0,0 +1,38 @@ +package douyin + +import ( + "fmt" + + "github.com/dop251/goja" + + "github.com/foamzou/audio-get/logger" + gen_xb_js "github.com/foamzou/audio-get/processor/douyin/gen-xb-js" +) + +func genXB(urlParams string, ua string) (string, error) { + vm := goja.New() + + _, err := vm.RunString(gen_xb_js.CryptoMinJS) // executes a script on the global context + if err != nil { + logger.Warn("genXB failed", err) + return "", err + } + _, err = vm.RunString(gen_xb_js.AsciiBase64) // executes a script on the global context + if err != nil { + logger.Warn("genXB failed", err) + return "", err + } + _, err = vm.RunString(gen_xb_js.XB_JS) // executes a script on the global context + if err != nil { + logger.Warn("genXB failed", err) + return "", err + } + val, err := vm.RunString(fmt.Sprintf("xb_main('%s', '%s')", urlParams, ua)) + if err != nil { + logger.Warn("genXB failed", err) + return "", err + } + // nolint + v := val.Export().(string) + return v, nil +} diff --git a/processor/douyin/xb_test.go b/processor/douyin/xb_test.go new file mode 100644 index 0000000..272dac0 --- /dev/null +++ b/processor/douyin/xb_test.go @@ -0,0 +1,30 @@ +package douyin + +import ( + "testing" +) + +func Test_genXB(t *testing.T) { + type args struct { + urlParams string + ua string + } + tests := []struct { + name string + args args + }{ + { + args: args{ + urlParams: "device_platform=webapp&aid=6383&channel=channel_pc_web&search_channel=aweme_general&sort_type=0&publish_time=0&keyword=foamhahaaha&search_source=normal_search&query_correct_type=1&is_filter_search=0&from_group_id=&offset=0&count=10&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=1920&screen_height=1080&browser_language=zh-CN&browser_platform=MacIntel&browser_name=Chrome&browser_version=104.0.0.0&browser_online=true&engine_name=Blink&engine_version=104.0.0.0&os_name=Mac+OS&os_version=10.15.7&cpu_core_num=8&device_memory=8&platform=PC&downlink=10&effective_type=4g&round_trip_time=0&webid=7131372889845188104&msToken=", + ua: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36", + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if _, err := genXB(tt.args.urlParams, tt.args.ua); err != nil { + t.Errorf("genXB() faield, err: %v", err) + } + }) + } +} diff --git a/utils/http.go b/utils/http.go index 5d3e3c0..047e224 100644 --- a/utils/http.go +++ b/utils/http.go @@ -48,11 +48,19 @@ func GetLocation(url string, headers map[string]string) (string, error) { return location, nil } -func GetCookie(url string, headers map[string]string) (string, error) { +func GetCookie(url string, headers map[string]string, isHead bool) (string, error) { client := createClient() - resp, err := client.R(). - SetHeaders(headers). - Get(url) + var resp *resty.Response + var err error + if isHead { + resp, err = client.R(). + SetHeaders(headers). + Head(url) + } else { + resp, err = client.R(). + SetHeaders(headers). + Get(url) + } if err != nil { return "", err @@ -62,6 +70,9 @@ func GetCookie(url string, headers map[string]string) (string, error) { } cookie := resp.RawResponse.Header.Get("Set-Cookie") if cookie == "" { + fmt.Println(url) + fmt.Println(headers) + fmt.Println(resp.RawResponse.Header) return "", fmt.Errorf("cookie is empty") } From 8d9964a30a158313a3f2f86ba0ff31e3402bf5e7 Mon Sep 17 00:00:00 2001 From: foamzou Date: Fri, 19 Aug 2022 19:40:19 +0800 Subject: [PATCH 4/4] chore: release 0.2.7 --- .golangci.yml | 3 ++- LATEST_VERSION | 2 +- utils/http.go | 3 --- version/version.go | 4 ++-- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index dab5c6c..afd99c8 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -401,11 +401,12 @@ linters: - govet - gofmt - goimports - - lll - megacheck - misspell - revive disable: + - gosec + - lll - maligned - prealloc - scopelint diff --git a/LATEST_VERSION b/LATEST_VERSION index a53741c..967b33f 100644 --- a/LATEST_VERSION +++ b/LATEST_VERSION @@ -1 +1 @@ -0.2.6 \ No newline at end of file +0.2.7 \ No newline at end of file diff --git a/utils/http.go b/utils/http.go index 047e224..9a3108c 100644 --- a/utils/http.go +++ b/utils/http.go @@ -70,9 +70,6 @@ func GetCookie(url string, headers map[string]string, isHead bool) (string, erro } cookie := resp.RawResponse.Header.Get("Set-Cookie") if cookie == "" { - fmt.Println(url) - fmt.Println(headers) - fmt.Println(resp.RawResponse.Header) return "", fmt.Errorf("cookie is empty") } diff --git a/version/version.go b/version/version.go index 01db493..e582c66 100644 --- a/version/version.go +++ b/version/version.go @@ -5,8 +5,8 @@ import ( ) const ( - BuildCode = 11 - BuildName = "0.2.6" + BuildCode = 12 + BuildName = "0.2.7" Repo = "https://github.com/foamzou/media-get" )