starknet 11.0.0-beta.13 → 11.0.0-beta.14

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/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # [11.0.0-beta.14](https://github.com/starknet-io/starknet.js/compare/v11.0.0-beta.13...v11.0.0-beta.14) (2026-09-10)
2
+
3
+ ### Bug Fixes
4
+
5
+ - **deps:** bump @noble/[@scure](https://github.com/scure) crypto libs to 2.4.0 ([5c448fe](https://github.com/starknet-io/starknet.js/commit/5c448febcbd16e2d1e27a4f32ec09cfd83e35dca))
6
+
1
7
  # [11.0.0-beta.13](https://github.com/starknet-io/starknet.js/compare/v11.0.0-beta.12...v11.0.0-beta.13) (2026-09-03)
2
8
 
3
9
  ### Features
@@ -2369,6 +2369,14 @@ ${indent}}` : "}";
2369
2369
  if (value === null || typeof value !== "object" || Array.isArray(value))
2370
2370
  throw new TypeError((label === "object" ? "" : `"${label}" `) + "expected object, got type=" + typeof value);
2371
2371
  };
2372
+ var aopts = (value, label) => {
2373
+ aobject(value, label);
2374
+ const proto = Object.getPrototypeOf(value);
2375
+ if (proto !== Object.prototype && proto !== null)
2376
+ throw new TypeError(`"${label}" expected plain object`);
2377
+ if (Object.hasOwn(value, "__proto__"))
2378
+ throw new TypeError(`"${label}.__proto__" is not allowed`);
2379
+ };
2372
2380
  function aexists(instance, checkFinished = true) {
2373
2381
  if (instance.destroyed)
2374
2382
  throw new Error("hash was destroyed");
@@ -2457,7 +2465,12 @@ ${indent}}` : "}";
2457
2465
  function utf8ToBytes(str) {
2458
2466
  if (typeof str !== "string")
2459
2467
  throw new TypeError("string expected");
2460
- return new Uint8Array(new TextEncoder().encode(str));
2468
+ const encoded = new TextEncoder().encode(str);
2469
+ try {
2470
+ return new Uint8Array(encoded);
2471
+ } finally {
2472
+ clean(encoded);
2473
+ }
2461
2474
  }
2462
2475
  function concatBytes(...arrays) {
2463
2476
  let sum = 0;
@@ -2475,10 +2488,10 @@ ${indent}}` : "}";
2475
2488
  return res;
2476
2489
  }
2477
2490
  function checkOpts(defaults, opts, title = "opts") {
2478
- aobject(defaults, "defaults");
2491
+ aopts(defaults, "defaults");
2479
2492
  if (opts !== void 0)
2480
- aobject(opts, title);
2481
- const merged = Object.assign(defaults, opts);
2493
+ aopts(opts, title);
2494
+ const merged = Object.assign(/* @__PURE__ */ Object.create(null), defaults, opts);
2482
2495
  return merged;
2483
2496
  }
2484
2497
  function createHasher(hashCons, info = {}) {
@@ -4728,8 +4741,13 @@ ${indent}}` : "}";
4728
4741
  return bytesToNumberBE(data);
4729
4742
  }
4730
4743
  },
4731
- toSig(bytes) {
4744
+ toSig(bytes, maxScalarBytes) {
4732
4745
  const { Err: E, _int: int, _tlv: tlv } = _DER;
4746
+ if (maxScalarBytes !== void 0) {
4747
+ asafenumber(maxScalarBytes, "maxScalarBytes");
4748
+ if (maxScalarBytes < 1)
4749
+ throw new E("invalid signature: maxScalarBytes must be positive");
4750
+ }
4733
4751
  const data = abytes3(bytes, void 0, "signature");
4734
4752
  const { v: seqBytes, l: seqLeftBytes } = tlv.decode(48, data);
4735
4753
  if (seqLeftBytes.length)
@@ -4738,6 +4756,8 @@ ${indent}}` : "}";
4738
4756
  const { v: sBytes, l: sLeftBytes } = tlv.decode(2, rLeftBytes);
4739
4757
  if (sLeftBytes.length)
4740
4758
  throw new E("invalid signature: left bytes after parsing");
4759
+ if (maxScalarBytes !== void 0 && (rBytes.length > maxScalarBytes || sBytes.length > maxScalarBytes))
4760
+ throw new E("invalid signature: integer too large");
4741
4761
  return { r: int.decode(rBytes), s: int.decode(sBytes) };
4742
4762
  },
4743
4763
  hexFromSig(sig) {
@@ -4813,21 +4833,28 @@ ${indent}}` : "}";
4813
4833
  endo: "object",
4814
4834
  randomBytes: "function"
4815
4835
  });
4816
- const { endo, allowInfinityPoint } = extraOpts;
4836
+ const { endo: endoOpts, allowInfinityPoint, clearCofactor, isTorsionFree, fromBytes, toBytes: toBytes2 } = extraOpts;
4817
4837
  const randomBytes3 = extraOpts.randomBytes === void 0 ? randomBytes2 : extraOpts.randomBytes;
4818
- if (endo) {
4819
- if (!Fp.is0(CURVE.a) || typeof endo.beta !== "bigint" || !Array.isArray(endo.basises)) {
4838
+ if (endoOpts) {
4839
+ if (!Fp.is0(CURVE.a) || typeof endoOpts.beta !== "bigint" || !Array.isArray(endoOpts.basises)) {
4820
4840
  throw new Error('invalid endo: expected "beta": bigint and "basises": array');
4821
4841
  }
4822
4842
  }
4843
+ const endo = endoOpts ? {
4844
+ beta: endoOpts.beta,
4845
+ basises: endoOpts.basises.map((basis) => [...basis])
4846
+ } : void 0;
4823
4847
  const lengths = getWLengths(Fp, Fn);
4824
4848
  function assertCompressionIsSupported() {
4825
4849
  if (!Fp.isOdd)
4826
4850
  throw new Error("compression is not supported: Field does not have .isOdd()");
4827
4851
  }
4828
4852
  function pointToBytes(_c, point, isCompressed) {
4829
- if (allowInfinityPoint && point.is0())
4853
+ if (point.is0()) {
4854
+ if (!allowInfinityPoint)
4855
+ throw new Error("bad point: ZERO");
4830
4856
  return Uint8Array.of(0);
4857
+ }
4831
4858
  const { x, y } = point.toAffine();
4832
4859
  const bx = Fp.toBytes(x);
4833
4860
  abool2(isCompressed, "isCompressed");
@@ -4876,8 +4903,8 @@ ${indent}}` : "}";
4876
4903
  throw new Error(`bad point: got length ${length}, expected compressed=${comp} or uncompressed=${uncomp}`);
4877
4904
  }
4878
4905
  }
4879
- const encodePoint = extraOpts.toBytes === void 0 ? pointToBytes : extraOpts.toBytes;
4880
- const decodePoint = extraOpts.fromBytes === void 0 ? pointFromBytes : extraOpts.fromBytes;
4906
+ const encodePoint = toBytes2 === void 0 ? pointToBytes : toBytes2;
4907
+ const decodePoint = fromBytes === void 0 ? pointFromBytes : fromBytes;
4881
4908
  const b3 = Fp.mul(CURVE.b, _3n2);
4882
4909
  const mulA = Fp.is0(CURVE.a) ? (_) => Fp.ZERO : (x) => Fp.mul(CURVE.a, x);
4883
4910
  function weierstrassEquation(x) {
@@ -4899,7 +4926,7 @@ ${indent}}` : "}";
4899
4926
  function acoord(title, n, banZero = false) {
4900
4927
  if (!Fp.isValid(n) || banZero && Fp.is0(n))
4901
4928
  throw new Error(`bad point coordinate ${title}`);
4902
- return n;
4929
+ return typeof n === "object" && n !== null ? Fp.create(n) : n;
4903
4930
  }
4904
4931
  function aprjpoint(other) {
4905
4932
  if (!(other instanceof Point2))
@@ -4981,7 +5008,7 @@ ${indent}}` : "}";
4981
5008
  assertValidity() {
4982
5009
  const p = this;
4983
5010
  if (p.is0()) {
4984
- if (extraOpts.allowInfinityPoint && Fp.is0(p.X) && Fp.eql(p.Y, Fp.ONE) && Fp.is0(p.Z))
5011
+ if (allowInfinityPoint && Fp.is0(p.X) && Fp.eql(p.Y, Fp.ONE) && Fp.is0(p.Z))
4985
5012
  return;
4986
5013
  throw new Error("bad point: ZERO");
4987
5014
  }
@@ -5193,7 +5220,6 @@ ${indent}}` : "}";
5193
5220
  * Always torsion-free for cofactor=1 curves.
5194
5221
  */
5195
5222
  isTorsionFree() {
5196
- const { isTorsionFree } = extraOpts;
5197
5223
  if (cofactor === _1n4)
5198
5224
  return true;
5199
5225
  if (isTorsionFree)
@@ -5201,7 +5227,6 @@ ${indent}}` : "}";
5201
5227
  return wnaf.mulUnsafe(this, CURVE_ORDER2).is0();
5202
5228
  }
5203
5229
  clearCofactor() {
5204
- const { clearCofactor } = extraOpts;
5205
5230
  if (cofactor === _1n4)
5206
5231
  return this;
5207
5232
  if (clearCofactor)
@@ -5270,7 +5295,7 @@ ${indent}}` : "}";
5270
5295
  return false;
5271
5296
  if (isCompressed === false && l !== publicKeyUncompressed)
5272
5297
  return false;
5273
- return !!Point2.fromBytes(publicKey);
5298
+ return !Point2.fromBytes(publicKey).is0();
5274
5299
  } catch (error) {
5275
5300
  return false;
5276
5301
  }
@@ -5301,6 +5326,8 @@ ${indent}}` : "}";
5301
5326
  throw new Error("second arg must be public key");
5302
5327
  const s = Fn.fromBytes(secretKeyA);
5303
5328
  const b = Point2.fromBytes(publicKeyB);
5329
+ if (b.is0())
5330
+ throw new Error("invalid public key: point at infinity");
5304
5331
  return b.multiply(s).toBytes(isCompressed);
5305
5332
  }
5306
5333
  const utils2 = {
@@ -5385,7 +5412,9 @@ ${indent}}` : "}";
5385
5412
  validateSigLength(bytes, format);
5386
5413
  let recid;
5387
5414
  if (format === "der") {
5388
- const { r: r2, s: s2 } = DER.toSig(abytes3(bytes));
5415
+ if (bytes.length > 2 * Fn.BYTES + 16)
5416
+ throw new DER.Err("invalid signature: DER signature too long");
5417
+ const { r: r2, s: s2 } = DER.toSig(abytes3(bytes), Fn.BYTES + 1);
5389
5418
  return new Signature2(r2, s2);
5390
5419
  }
5391
5420
  if (format === "recovered") {
@@ -5535,6 +5564,8 @@ ${indent}}` : "}";
5535
5564
  try {
5536
5565
  const sig = Signature2.fromBytes(signature, format);
5537
5566
  const P = Point2.fromBytes(publicKey);
5567
+ if (P.is0())
5568
+ return false;
5538
5569
  if (lowS && sig.hasHighS())
5539
5570
  return false;
5540
5571
  const { r, s } = sig;