starknet 9.4.0 → 9.4.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/dist/index.mjs CHANGED
@@ -5313,6 +5313,7 @@ __export(stark_exports, {
5313
5313
  decompressProgram: () => decompressProgram,
5314
5314
  formatSignature: () => formatSignature,
5315
5315
  getFullPublicKey: () => getFullPublicKey,
5316
+ getSharedSecret: () => getSharedSecret,
5316
5317
  intDAM: () => intDAM,
5317
5318
  randomAddress: () => randomAddress,
5318
5319
  resourceBoundsToBigInt: () => resourceBoundsToBigInt,
@@ -5361,6 +5362,17 @@ function signatureToDecimalArray(sig) {
5361
5362
  function signatureToHexArray(sig) {
5362
5363
  return bigNumberishArrayToHexadecimalStringArray(formatSignature(sig));
5363
5364
  }
5365
+ function getSharedSecret(privateKey, fullPublicKey) {
5366
+ const privK = toHex(privateKey);
5367
+ const fullPubKHex = removeHexPrefix(toHex(fullPublicKey)).padStart(130, "0");
5368
+ if (fullPubKHex.length !== 130 || !fullPubKHex.startsWith("04")) {
5369
+ throw new Error(
5370
+ "fullPublicKey must be an uncompressed public key (starting with 04, 65 bytes total)"
5371
+ );
5372
+ }
5373
+ const sharedSecret = buf2hex(starkCurve.getSharedSecret(privK, fullPubKHex));
5374
+ return addHexPrefix(sharedSecret);
5375
+ }
5364
5376
  function zeroResourceBounds() {
5365
5377
  return toOverheadResourceBounds(ZeroFeeEstimate(), false);
5366
5378
  }