@vizor-vr/vue 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/VzCinema.vue.d.ts +9 -0
- package/dist/VzCinema.vue.d.ts.map +1 -1
- package/dist/VzLive.vue.d.ts +9 -0
- package/dist/VzLive.vue.d.ts.map +1 -1
- package/dist/VzVideo.vue.d.ts +9 -0
- package/dist/VzVideo.vue.d.ts.map +1 -1
- package/dist/dash-adapter-BMpHWcBA-B1de3T0m.js +70 -0
- package/dist/hls-adapter-C_a65zia-DZrg_yeD.js +134 -0
- package/dist/index.js +5935 -4924
- package/dist/use-vizor.d.ts +4 -0
- package/dist/use-vizor.d.ts.map +1 -1
- package/package.json +6 -3
- package/dist/dash-adapter-tid9ZyhO-4XHuq5__.js +0 -63
- package/dist/hls-adapter-BivH46L_-BkyufEEx.js +0 -84
- package/dist/index-a2S14O1a.js +0 -283
package/dist/use-vizor.d.ts
CHANGED
|
@@ -67,6 +67,10 @@ export declare const vizorProps: {
|
|
|
67
67
|
readonly type: StringConstructor;
|
|
68
68
|
readonly default: undefined;
|
|
69
69
|
};
|
|
70
|
+
readonly lensAngle: {
|
|
71
|
+
readonly type: NumberConstructor;
|
|
72
|
+
readonly default: undefined;
|
|
73
|
+
};
|
|
70
74
|
readonly collabServer: {
|
|
71
75
|
readonly type: StringConstructor;
|
|
72
76
|
readonly default: undefined;
|
package/dist/use-vizor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-vizor.d.ts","sourceRoot":"","sources":["../src/use-vizor.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,KAAK,GAAG,EAAE,MAAM,KAAK,CAAC;AAIvE,OAAO,2BAA2B,CAAC;AA2BnC;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,EAC9B,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,QAgClD;AAED,mDAAmD;AACnD,wBAAgB,WAAW,gDAE1B;AAED,oDAAoD;AACpD,eAAO,MAAM,UAAU,EAAE,MAAM,EAgB9B,CAAC;AAEF,kDAAkD;AAClD,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;uBAMM,MAAM,MAAM,GAAG,UAAU,GAAG,MAAM;;;;;;;;;;;;;;;;;;;;;;;;uBAO3C,MAAM,UAAU,GAAG,QAAQ,GAAG,SAAS
|
|
1
|
+
{"version":3,"file":"use-vizor.d.ts","sourceRoot":"","sources":["../src/use-vizor.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,KAAK,GAAG,EAAE,MAAM,KAAK,CAAC;AAIvE,OAAO,2BAA2B,CAAC;AA2BnC;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,EAC9B,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,QAgClD;AAED,mDAAmD;AACnD,wBAAgB,WAAW,gDAE1B;AAED,oDAAoD;AACpD,eAAO,MAAM,UAAU,EAAE,MAAM,EAgB9B,CAAC;AAEF,kDAAkD;AAClD,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;uBAMM,MAAM,MAAM,GAAG,UAAU,GAAG,MAAM;;;;;;;;;;;;;;;;;;;;;;;;uBAO3C,MAAM,UAAU,GAAG,QAAQ,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;uBAQ3B,MAAM,MAAM,GAAG,QAAQ;;;;;;;;;;;;;;;CAI7C,CAAC;AAEX,qDAAqD;AACrD,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAfN,MAAM,UAAU,GAAG,QAAQ,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;uBAQ3B,MAAM,MAAM,GAAG,QAAQ;;;;;;;;;;;;;;;CAyB7C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizor-vr/vue",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Vue 3 wrappers for Vizor VR Player",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "UTG Networks",
|
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
"url": "git+https://github.com/vizor-vr/vizor-vr.git",
|
|
11
11
|
"directory": "packages/vue"
|
|
12
12
|
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/vizor-vr/vizor-vr/issues"
|
|
15
|
+
},
|
|
13
16
|
"keywords": [
|
|
14
17
|
"vue",
|
|
15
18
|
"vue3",
|
|
@@ -36,10 +39,10 @@
|
|
|
36
39
|
"vue": ">=3.3.0"
|
|
37
40
|
},
|
|
38
41
|
"dependencies": {
|
|
39
|
-
"@vizor-vr/player": "0.2.
|
|
42
|
+
"@vizor-vr/player": "0.2.1"
|
|
40
43
|
},
|
|
41
44
|
"devDependencies": {
|
|
42
|
-
"@vitejs/plugin-vue": "^
|
|
45
|
+
"@vitejs/plugin-vue": "^6.0.7",
|
|
43
46
|
"@vitest/coverage-v8": "^3.0.0",
|
|
44
47
|
"typescript": "^5.7.0",
|
|
45
48
|
"vite": "^6.0.0",
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
var d = Object.defineProperty;
|
|
2
|
-
var o = (i, t, e) => t in i ? d(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
|
|
3
|
-
var s = (i, t, e) => o(i, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
-
class c {
|
|
5
|
-
constructor() {
|
|
6
|
-
s(this, "videoElement", null);
|
|
7
|
-
s(this, "player", null);
|
|
8
|
-
s(this, "_isAttached", !1);
|
|
9
|
-
s(this, "levels", []);
|
|
10
|
-
}
|
|
11
|
-
get supportsABR() {
|
|
12
|
-
return !0;
|
|
13
|
-
}
|
|
14
|
-
get isAttached() {
|
|
15
|
-
return this._isAttached;
|
|
16
|
-
}
|
|
17
|
-
attach(t) {
|
|
18
|
-
this.videoElement = t, this._isAttached = !0;
|
|
19
|
-
}
|
|
20
|
-
async load(t) {
|
|
21
|
-
if (this.videoElement)
|
|
22
|
-
try {
|
|
23
|
-
const e = await import("./dash.all.min-DJEXrg26.js").then((r) => r.d);
|
|
24
|
-
this.player && this.player.destroy();
|
|
25
|
-
const l = e.MediaPlayer().create();
|
|
26
|
-
l.initialize(this.videoElement, t, !1), l.on("streamInitialized", () => {
|
|
27
|
-
try {
|
|
28
|
-
const r = l.getBitrateInfoListFor("video");
|
|
29
|
-
this.levels = r.map(
|
|
30
|
-
(a, h) => ({
|
|
31
|
-
label: a.height ? `${a.height}p` : `Level ${h}`,
|
|
32
|
-
width: a.width,
|
|
33
|
-
height: a.height,
|
|
34
|
-
bitrate: a.bitrate,
|
|
35
|
-
active: !1
|
|
36
|
-
})
|
|
37
|
-
);
|
|
38
|
-
} catch {
|
|
39
|
-
}
|
|
40
|
-
}), this.player = l;
|
|
41
|
-
} catch (e) {
|
|
42
|
-
console.error("[Vizor] Failed to load dashjs:", e);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
getQualityLevels() {
|
|
46
|
-
return this.levels;
|
|
47
|
-
}
|
|
48
|
-
setQualityLevel(t) {
|
|
49
|
-
if (!this.player) return;
|
|
50
|
-
const e = this.player;
|
|
51
|
-
t === -1 ? e.updateSettings({
|
|
52
|
-
streaming: { abr: { autoSwitchBitrate: { video: !0 } } }
|
|
53
|
-
}) : (e.updateSettings({
|
|
54
|
-
streaming: { abr: { autoSwitchBitrate: { video: !1 } } }
|
|
55
|
-
}), e.setQualityFor("video", t));
|
|
56
|
-
}
|
|
57
|
-
destroy() {
|
|
58
|
-
this.player && this.player.destroy(), this.player = null, this.videoElement = null, this._isAttached = !1, this.levels = [];
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
export {
|
|
62
|
-
c as DashAdapter
|
|
63
|
-
};
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
var h = Object.defineProperty;
|
|
2
|
-
var n = (r, e, t) => e in r ? h(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
-
var l = (r, e, t) => n(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
class d {
|
|
5
|
-
constructor() {
|
|
6
|
-
l(this, "videoElement", null);
|
|
7
|
-
l(this, "hls", null);
|
|
8
|
-
l(this, "_isAttached", !1);
|
|
9
|
-
l(this, "_isNative", !1);
|
|
10
|
-
l(this, "levels", []);
|
|
11
|
-
/** Enable low-latency mode for live streams */
|
|
12
|
-
l(this, "lowLatencyMode", !1);
|
|
13
|
-
}
|
|
14
|
-
get supportsABR() {
|
|
15
|
-
return !this._isNative;
|
|
16
|
-
}
|
|
17
|
-
get isAttached() {
|
|
18
|
-
return this._isAttached;
|
|
19
|
-
}
|
|
20
|
-
attach(e) {
|
|
21
|
-
this.videoElement = e, this._isAttached = !0;
|
|
22
|
-
}
|
|
23
|
-
async load(e) {
|
|
24
|
-
if (this.videoElement) {
|
|
25
|
-
if (this.videoElement.canPlayType("application/vnd.apple.mpegurl")) {
|
|
26
|
-
this.videoElement.src = e, this._isNative = !0;
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
try {
|
|
30
|
-
const o = (await import("./hls-CxmYC9fy.js")).default;
|
|
31
|
-
if (!o.isSupported()) {
|
|
32
|
-
console.error("[Vizor] HLS.js is not supported in this browser");
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
this.hls && this.hls.destroy();
|
|
36
|
-
const s = new o({
|
|
37
|
-
enableWorker: !0,
|
|
38
|
-
lowLatencyMode: this.lowLatencyMode,
|
|
39
|
-
...this.lowLatencyMode ? { liveSyncDurationCount: 3, liveMaxLatencyDurationCount: 6 } : {}
|
|
40
|
-
});
|
|
41
|
-
s.attachMedia(this.videoElement), s.loadSource(e), s.on(o.Events.MANIFEST_PARSED, () => {
|
|
42
|
-
this.levels = s.levels.map(
|
|
43
|
-
(a, i) => ({
|
|
44
|
-
label: a.height ? `${a.height}p` : `Level ${i}`,
|
|
45
|
-
width: a.width,
|
|
46
|
-
height: a.height,
|
|
47
|
-
bitrate: a.bitrate,
|
|
48
|
-
active: i === s.currentLevel
|
|
49
|
-
})
|
|
50
|
-
);
|
|
51
|
-
}), s.on(o.Events.ERROR, (a, i) => {
|
|
52
|
-
if (i.fatal)
|
|
53
|
-
switch (console.error("[Vizor] Fatal HLS error:", i.type, i.details), i.type) {
|
|
54
|
-
case o.ErrorTypes.NETWORK_ERROR:
|
|
55
|
-
s.startLoad();
|
|
56
|
-
break;
|
|
57
|
-
case o.ErrorTypes.MEDIA_ERROR:
|
|
58
|
-
s.recoverMediaError();
|
|
59
|
-
break;
|
|
60
|
-
default:
|
|
61
|
-
this.destroy();
|
|
62
|
-
break;
|
|
63
|
-
}
|
|
64
|
-
}), this.hls = s;
|
|
65
|
-
} catch (t) {
|
|
66
|
-
console.error("[Vizor] Failed to load hls.js:", t);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
getQualityLevels() {
|
|
71
|
-
return this.levels;
|
|
72
|
-
}
|
|
73
|
-
setQualityLevel(e) {
|
|
74
|
-
if (!this.hls || this._isNative) return;
|
|
75
|
-
const t = this.hls;
|
|
76
|
-
t.currentLevel = e;
|
|
77
|
-
}
|
|
78
|
-
destroy() {
|
|
79
|
-
this.hls && !this._isNative && this.hls.destroy(), this.hls = null, this.videoElement = null, this._isAttached = !1, this._isNative = !1, this.levels = [];
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
export {
|
|
83
|
-
d as HlsAdapter
|
|
84
|
-
};
|
package/dist/index-a2S14O1a.js
DELETED
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
var Zt = Object.defineProperty;
|
|
2
|
-
var _t = (t, n, s) => n in t ? Zt(t, n, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[n] = s;
|
|
3
|
-
var Z = (t, n, s) => _t(t, typeof n != "symbol" ? n + "" : n, s);
|
|
4
|
-
/*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) */
|
|
5
|
-
const Rt = {
|
|
6
|
-
p: 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,
|
|
7
|
-
n: 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,
|
|
8
|
-
h: 8n,
|
|
9
|
-
a: 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,
|
|
10
|
-
d: 0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,
|
|
11
|
-
Gx: 0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,
|
|
12
|
-
Gy: 0x6666666666666666666666666666666666666666666666666666666666666658n
|
|
13
|
-
}, { p: h, n: H, Gx: tt, Gy: nt, a: q, d: G } = Rt, zt = 8n, B = 32, X = 64, b = (t = "") => {
|
|
14
|
-
throw new Error(t);
|
|
15
|
-
}, St = (t) => typeof t == "bigint", rt = (t) => typeof t == "string", Tt = (t) => t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array", R = (t, n) => !Tt(t) || typeof n == "number" && n > 0 && t.length !== n ? b("Uint8Array expected") : t, U = (t) => new Uint8Array(t), V = (t) => Uint8Array.from(t), it = (t, n) => t.toString(16).padStart(n, "0"), N = (t) => Array.from(R(t)).map((n) => it(n, 2)).join(""), A = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 }, st = (t) => {
|
|
16
|
-
if (t >= A._0 && t <= A._9)
|
|
17
|
-
return t - A._0;
|
|
18
|
-
if (t >= A.A && t <= A.F)
|
|
19
|
-
return t - (A.A - 10);
|
|
20
|
-
if (t >= A.a && t <= A.f)
|
|
21
|
-
return t - (A.a - 10);
|
|
22
|
-
}, k = (t) => {
|
|
23
|
-
const n = "hex invalid";
|
|
24
|
-
if (!rt(t))
|
|
25
|
-
return b(n);
|
|
26
|
-
const s = t.length, e = s / 2;
|
|
27
|
-
if (s % 2)
|
|
28
|
-
return b(n);
|
|
29
|
-
const f = U(e);
|
|
30
|
-
for (let c = 0, r = 0; c < e; c++, r += 2) {
|
|
31
|
-
const l = st(t.charCodeAt(r)), i = st(t.charCodeAt(r + 1));
|
|
32
|
-
if (l === void 0 || i === void 0)
|
|
33
|
-
return b(n);
|
|
34
|
-
f[c] = l * 16 + i;
|
|
35
|
-
}
|
|
36
|
-
return f;
|
|
37
|
-
}, v = (t, n) => R(rt(t) ? k(t) : V(R(t)), n), at = () => globalThis == null ? void 0 : globalThis.crypto, Xt = () => {
|
|
38
|
-
var t;
|
|
39
|
-
return ((t = at()) == null ? void 0 : t.subtle) ?? b("crypto.subtle must be defined");
|
|
40
|
-
}, Y = (...t) => {
|
|
41
|
-
const n = U(t.reduce((e, f) => e + R(f).length, 0));
|
|
42
|
-
let s = 0;
|
|
43
|
-
return t.forEach((e) => {
|
|
44
|
-
n.set(e, s), s += e.length;
|
|
45
|
-
}), n;
|
|
46
|
-
}, lt = (t = B) => at().getRandomValues(U(t)), O = BigInt, _ = (t, n, s, e = "bad number: out of range") => St(t) && n <= t && t < s ? t : b(e), o = (t, n = h) => {
|
|
47
|
-
const s = t % n;
|
|
48
|
-
return s >= 0n ? s : n + s;
|
|
49
|
-
}, ut = (t) => o(t, H), dt = (t, n) => {
|
|
50
|
-
(t === 0n || n <= 0n) && b("no inverse n=" + t + " mod=" + n);
|
|
51
|
-
let s = o(t, n), e = n, f = 0n, c = 1n;
|
|
52
|
-
for (; s !== 0n; ) {
|
|
53
|
-
const r = e / s, l = e % s, i = f - c * r;
|
|
54
|
-
e = s, s = l, f = c, c = i;
|
|
55
|
-
}
|
|
56
|
-
return e === 1n ? o(f, n) : b("no inverse");
|
|
57
|
-
}, Yt = (t) => {
|
|
58
|
-
const n = mt[t];
|
|
59
|
-
return typeof n != "function" && b("hashes." + t + " not set"), n;
|
|
60
|
-
}, et = (t) => t instanceof g ? t : b("Point expected"), K = 2n ** 256n, m = class m {
|
|
61
|
-
constructor(n, s, e, f) {
|
|
62
|
-
Z(this, "ex");
|
|
63
|
-
Z(this, "ey");
|
|
64
|
-
Z(this, "ez");
|
|
65
|
-
Z(this, "et");
|
|
66
|
-
const c = K;
|
|
67
|
-
this.ex = _(n, 0n, c), this.ey = _(s, 0n, c), this.ez = _(e, 1n, c), this.et = _(f, 0n, c), Object.freeze(this);
|
|
68
|
-
}
|
|
69
|
-
static fromAffine(n) {
|
|
70
|
-
return new m(n.x, n.y, 1n, o(n.x * n.y));
|
|
71
|
-
}
|
|
72
|
-
/** RFC8032 5.1.3: Uint8Array to Point. */
|
|
73
|
-
static fromBytes(n, s = !1) {
|
|
74
|
-
const e = G, f = V(R(n, B)), c = n[31];
|
|
75
|
-
f[31] = c & -129;
|
|
76
|
-
const r = M(f);
|
|
77
|
-
_(r, 0n, s ? K : h);
|
|
78
|
-
const i = o(r * r), a = o(i - 1n), u = o(e * i + 1n);
|
|
79
|
-
let { isValid: d, value: y } = Ht(a, u);
|
|
80
|
-
d || b("bad point: y not sqrt");
|
|
81
|
-
const p = (y & 1n) === 1n, x = (c & 128) !== 0;
|
|
82
|
-
return !s && y === 0n && x && b("bad point: x==0, isLastByteOdd"), x !== p && (y = o(-y)), new m(y, r, 1n, o(y * r));
|
|
83
|
-
}
|
|
84
|
-
/** Checks if the point is valid and on-curve. */
|
|
85
|
-
assertValidity() {
|
|
86
|
-
const n = q, s = G, e = this;
|
|
87
|
-
if (e.is0())
|
|
88
|
-
throw new Error("bad point: ZERO");
|
|
89
|
-
const { ex: f, ey: c, ez: r, et: l } = e, i = o(f * f), a = o(c * c), u = o(r * r), d = o(u * u), y = o(i * n), p = o(u * o(y + a)), x = o(d + o(s * o(i * a)));
|
|
90
|
-
if (p !== x)
|
|
91
|
-
throw new Error("bad point: equation left != right (1)");
|
|
92
|
-
const z = o(f * c), S = o(r * l);
|
|
93
|
-
if (z !== S)
|
|
94
|
-
throw new Error("bad point: equation left != right (2)");
|
|
95
|
-
return this;
|
|
96
|
-
}
|
|
97
|
-
/** Equality check: compare points P&Q. */
|
|
98
|
-
equals(n) {
|
|
99
|
-
const { ex: s, ey: e, ez: f } = this, { ex: c, ey: r, ez: l } = et(n), i = o(s * l), a = o(c * f), u = o(e * l), d = o(r * f);
|
|
100
|
-
return i === a && u === d;
|
|
101
|
-
}
|
|
102
|
-
is0() {
|
|
103
|
-
return this.equals(T);
|
|
104
|
-
}
|
|
105
|
-
/** Flip point over y coordinate. */
|
|
106
|
-
negate() {
|
|
107
|
-
return new m(o(-this.ex), this.ey, this.ez, o(-this.et));
|
|
108
|
-
}
|
|
109
|
-
/** Point doubling. Complete formula. Cost: `4M + 4S + 1*a + 6add + 1*2`. */
|
|
110
|
-
double() {
|
|
111
|
-
const { ex: n, ey: s, ez: e } = this, f = q, c = o(n * n), r = o(s * s), l = o(2n * o(e * e)), i = o(f * c), a = n + s, u = o(o(a * a) - c - r), d = i + r, y = d - l, p = i - r, x = o(u * y), z = o(d * p), S = o(u * p), C = o(y * d);
|
|
112
|
-
return new m(x, z, C, S);
|
|
113
|
-
}
|
|
114
|
-
/** Point addition. Complete formula. Cost: `8M + 1*k + 8add + 1*2`. */
|
|
115
|
-
add(n) {
|
|
116
|
-
const { ex: s, ey: e, ez: f, et: c } = this, { ex: r, ey: l, ez: i, et: a } = et(n), u = q, d = G, y = o(s * r), p = o(e * l), x = o(c * d * a), z = o(f * i), S = o((s + e) * (r + l) - y - p), C = o(z - x), Q = o(z + x), $ = o(p - u * y), At = o(S * C), gt = o(Q * $), Et = o(S * $), vt = o(C * Q);
|
|
117
|
-
return new m(At, gt, vt, Et);
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Point-by-scalar multiplication. Scalar must be in range 1 <= n < CURVE.n.
|
|
121
|
-
* Uses {@link wNAF} for base point.
|
|
122
|
-
* Uses fake point to mitigate side-channel leakage.
|
|
123
|
-
* @param n scalar by which point is multiplied
|
|
124
|
-
* @param safe safe mode guards against timing attacks; unsafe mode is faster
|
|
125
|
-
*/
|
|
126
|
-
multiply(n, s = !0) {
|
|
127
|
-
if (!s && (n === 0n || this.is0()))
|
|
128
|
-
return T;
|
|
129
|
-
if (_(n, 1n, H), n === 1n)
|
|
130
|
-
return this;
|
|
131
|
-
if (this.equals(E))
|
|
132
|
-
return Pt(n).p;
|
|
133
|
-
let e = T, f = E;
|
|
134
|
-
for (let c = this; n > 0n; c = c.double(), n >>= 1n)
|
|
135
|
-
n & 1n ? e = e.add(c) : s && (f = f.add(c));
|
|
136
|
-
return e;
|
|
137
|
-
}
|
|
138
|
-
/** Convert point to 2d xy affine point. (X, Y, Z) ∋ (x=X/Z, y=Y/Z) */
|
|
139
|
-
toAffine() {
|
|
140
|
-
const { ex: n, ey: s, ez: e } = this;
|
|
141
|
-
if (this.equals(T))
|
|
142
|
-
return { x: 0n, y: 1n };
|
|
143
|
-
const f = dt(e, h);
|
|
144
|
-
return o(e * f) !== 1n && b("invalid inverse"), { x: o(n * f), y: o(s * f) };
|
|
145
|
-
}
|
|
146
|
-
toBytes() {
|
|
147
|
-
const { x: n, y: s } = this.assertValidity().toAffine(), e = yt(s);
|
|
148
|
-
return e[31] |= n & 1n ? 128 : 0, e;
|
|
149
|
-
}
|
|
150
|
-
toHex() {
|
|
151
|
-
return N(this.toBytes());
|
|
152
|
-
}
|
|
153
|
-
// encode to hex string
|
|
154
|
-
clearCofactor() {
|
|
155
|
-
return this.multiply(O(zt), !1);
|
|
156
|
-
}
|
|
157
|
-
isSmallOrder() {
|
|
158
|
-
return this.clearCofactor().is0();
|
|
159
|
-
}
|
|
160
|
-
isTorsionFree() {
|
|
161
|
-
let n = this.multiply(H / 2n, !1).double();
|
|
162
|
-
return H % 2n && (n = n.add(this)), n.is0();
|
|
163
|
-
}
|
|
164
|
-
static fromHex(n, s) {
|
|
165
|
-
return m.fromBytes(v(n), s);
|
|
166
|
-
}
|
|
167
|
-
get x() {
|
|
168
|
-
return this.toAffine().x;
|
|
169
|
-
}
|
|
170
|
-
get y() {
|
|
171
|
-
return this.toAffine().y;
|
|
172
|
-
}
|
|
173
|
-
toRawBytes() {
|
|
174
|
-
return this.toBytes();
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
Z(m, "BASE"), Z(m, "ZERO");
|
|
178
|
-
let g = m;
|
|
179
|
-
const E = new g(tt, nt, 1n, o(tt * nt)), T = new g(0n, 1n, 1n, 0n);
|
|
180
|
-
g.BASE = E;
|
|
181
|
-
g.ZERO = T;
|
|
182
|
-
const yt = (t) => k(it(_(t, 0n, K), X)).reverse(), M = (t) => O("0x" + N(V(R(t)).reverse())), w = (t, n) => {
|
|
183
|
-
let s = t;
|
|
184
|
-
for (; n-- > 0n; )
|
|
185
|
-
s *= s, s %= h;
|
|
186
|
-
return s;
|
|
187
|
-
}, Ct = (t) => {
|
|
188
|
-
const s = t * t % h * t % h, e = w(s, 2n) * s % h, f = w(e, 1n) * t % h, c = w(f, 5n) * f % h, r = w(c, 10n) * c % h, l = w(r, 20n) * r % h, i = w(l, 40n) * l % h, a = w(i, 80n) * i % h, u = w(a, 80n) * i % h, d = w(u, 10n) * c % h;
|
|
189
|
-
return { pow_p_5_8: w(d, 2n) * t % h, b2: s };
|
|
190
|
-
}, ot = 0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n, Ht = (t, n) => {
|
|
191
|
-
const s = o(n * n * n), e = o(s * s * n), f = Ct(t * e).pow_p_5_8;
|
|
192
|
-
let c = o(t * s * f);
|
|
193
|
-
const r = o(n * c * c), l = c, i = o(c * ot), a = r === t, u = r === o(-t), d = r === o(-t * ot);
|
|
194
|
-
return a && (c = l), (u || d) && (c = i), (o(c) & 1n) === 1n && (c = o(-c)), { isValid: a || u, value: c };
|
|
195
|
-
}, F = (t) => ut(M(t)), j = (...t) => mt.sha512Async(...t), D = (...t) => Yt("sha512Sync")(...t), ht = (t) => {
|
|
196
|
-
const n = t.slice(0, B);
|
|
197
|
-
n[0] &= 248, n[31] &= 127, n[31] |= 64;
|
|
198
|
-
const s = t.slice(B, X), e = F(n), f = E.multiply(e), c = f.toBytes();
|
|
199
|
-
return { head: n, prefix: s, scalar: e, point: f, pointBytes: c };
|
|
200
|
-
}, I = (t) => j(v(t, B)).then(ht), W = (t) => ht(D(v(t, B))), qt = (t) => I(t).then((n) => n.pointBytes), Gt = (t) => W(t).pointBytes, bt = (t) => j(t.hashable).then(t.finish), pt = (t) => t.finish(D(t.hashable)), xt = (t, n, s) => {
|
|
201
|
-
const { pointBytes: e, scalar: f } = t, c = F(n), r = E.multiply(c).toBytes();
|
|
202
|
-
return { hashable: Y(r, e, s), finish: (a) => {
|
|
203
|
-
const u = ut(c + F(a) * f);
|
|
204
|
-
return R(Y(r, yt(u)), X);
|
|
205
|
-
} };
|
|
206
|
-
}, Kt = async (t, n) => {
|
|
207
|
-
const s = v(t), e = await I(n), f = await j(e.prefix, s);
|
|
208
|
-
return bt(xt(e, f, s));
|
|
209
|
-
}, Lt = (t, n) => {
|
|
210
|
-
const s = v(t), e = W(n), f = D(e.prefix, s);
|
|
211
|
-
return pt(xt(e, f, s));
|
|
212
|
-
}, J = { zip215: !0 }, wt = (t, n, s, e = J) => {
|
|
213
|
-
t = v(t, X), n = v(n), s = v(s, B);
|
|
214
|
-
const { zip215: f } = e;
|
|
215
|
-
let c, r, l, i, a = Uint8Array.of();
|
|
216
|
-
try {
|
|
217
|
-
c = g.fromHex(s, f), r = g.fromHex(t.slice(0, B), f), l = M(t.slice(B, X)), i = E.multiply(l, !1), a = Y(r.toBytes(), c.toBytes(), n);
|
|
218
|
-
} catch {
|
|
219
|
-
}
|
|
220
|
-
return { hashable: a, finish: (d) => {
|
|
221
|
-
if (i == null || !f && c.isSmallOrder())
|
|
222
|
-
return !1;
|
|
223
|
-
const y = F(d);
|
|
224
|
-
return r.add(c.multiply(y, !1)).add(i.negate()).clearCofactor().is0();
|
|
225
|
-
} };
|
|
226
|
-
}, Vt = async (t, n, s, e = J) => bt(wt(t, n, s, e)), Nt = (t, n, s, e = J) => pt(wt(t, n, s, e)), mt = {
|
|
227
|
-
sha512Async: async (...t) => {
|
|
228
|
-
const n = Xt(), s = Y(...t);
|
|
229
|
-
return U(await n.digest("SHA-512", s.buffer));
|
|
230
|
-
},
|
|
231
|
-
sha512Sync: void 0,
|
|
232
|
-
bytesToHex: N,
|
|
233
|
-
hexToBytes: k,
|
|
234
|
-
concatBytes: Y,
|
|
235
|
-
mod: o,
|
|
236
|
-
invert: dt,
|
|
237
|
-
randomBytes: lt
|
|
238
|
-
}, kt = {
|
|
239
|
-
getExtendedPublicKeyAsync: I,
|
|
240
|
-
getExtendedPublicKey: W,
|
|
241
|
-
randomPrivateKey: () => lt(B),
|
|
242
|
-
precompute: (t = 8, n = E) => (n.multiply(3n), n)
|
|
243
|
-
// no-op
|
|
244
|
-
}, P = 8, Ot = 256, Bt = Math.ceil(Ot / P) + 1, L = 2 ** (P - 1), Ft = () => {
|
|
245
|
-
const t = [];
|
|
246
|
-
let n = E, s = n;
|
|
247
|
-
for (let e = 0; e < Bt; e++) {
|
|
248
|
-
s = n, t.push(s);
|
|
249
|
-
for (let f = 1; f < L; f++)
|
|
250
|
-
s = s.add(n), t.push(s);
|
|
251
|
-
n = s.double();
|
|
252
|
-
}
|
|
253
|
-
return t;
|
|
254
|
-
};
|
|
255
|
-
let ct;
|
|
256
|
-
const ft = (t, n) => {
|
|
257
|
-
const s = n.negate();
|
|
258
|
-
return t ? s : n;
|
|
259
|
-
}, Pt = (t) => {
|
|
260
|
-
const n = ct || (ct = Ft());
|
|
261
|
-
let s = T, e = E;
|
|
262
|
-
const f = 2 ** P, c = f, r = O(f - 1), l = O(P);
|
|
263
|
-
for (let i = 0; i < Bt; i++) {
|
|
264
|
-
let a = Number(t & r);
|
|
265
|
-
t >>= l, a > L && (a -= c, t += 1n);
|
|
266
|
-
const u = i * L, d = u, y = u + Math.abs(a) - 1, p = i % 2 !== 0, x = a < 0;
|
|
267
|
-
a === 0 ? e = e.add(ft(p, n[d])) : s = s.add(ft(x, n[y]));
|
|
268
|
-
}
|
|
269
|
-
return { p: s, f: e };
|
|
270
|
-
};
|
|
271
|
-
export {
|
|
272
|
-
Rt as CURVE,
|
|
273
|
-
g as ExtendedPoint,
|
|
274
|
-
g as Point,
|
|
275
|
-
mt as etc,
|
|
276
|
-
Gt as getPublicKey,
|
|
277
|
-
qt as getPublicKeyAsync,
|
|
278
|
-
Lt as sign,
|
|
279
|
-
Kt as signAsync,
|
|
280
|
-
kt as utils,
|
|
281
|
-
Nt as verify,
|
|
282
|
-
Vt as verifyAsync
|
|
283
|
-
};
|