import { CIRCOM_P as e } from "../constants/protocol.constants.mjs";
import { mod as t, modpow as n } from "../functions/utils/bigint-math.utils.mjs";
//#region libs/shared/common/src/crypto/BabyJubRN.ts
var r = e, i = {
	p: r,
	zero: 0n,
	one: 1n,
	e: (e) => t(BigInt(e)),
	add: (e, n) => t(e + n),
	sub: (e, n) => t(e - n),
	mul: (e, n) => t(e * n),
	div: (e, i) => {
		if (i === 0n) throw Error("Division by zero in BabyJub field");
		return t(e * n(i, r - 2n, r));
	},
	toString: (e) => t(e).toString()
}, a = class {
	F = i;
	A = i.e("168700");
	D = i.e("168696");
	Base8 = [i.e("5299619240641551281634865583518297030282874472190772894086521144482721001553"), i.e("16950150798460657717958625567821834550301663161624707787222815936182638968203")];
	addPoint(e, t) {
		let n = i.mul(e[0], t[1]), r = i.mul(e[1], t[0]), a = i.mul(i.sub(e[1], i.mul(this.A, e[0])), i.add(t[0], t[1])), o = i.mul(n, r), s = i.mul(this.D, o);
		return [i.div(i.add(n, r), i.add(i.one, s)), i.div(i.add(a, i.sub(i.mul(this.A, n), r)), i.sub(i.one, s))];
	}
	mulPointEscalar(e, t) {
		let n = [i.zero, i.one], r = BigInt(t), a = e;
		for (; r !== 0n;) r % 2n == 1n && (n = this.addPoint(n, a)), a = this.addPoint(a, a), r /= 2n;
		return n;
	}
};
//#endregion
export { a as BabyJubRN };
