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.js CHANGED
@@ -5486,6 +5486,7 @@ __export(stark_exports, {
5486
5486
  decompressProgram: () => decompressProgram,
5487
5487
  formatSignature: () => formatSignature,
5488
5488
  getFullPublicKey: () => getFullPublicKey,
5489
+ getSharedSecret: () => getSharedSecret,
5489
5490
  intDAM: () => intDAM,
5490
5491
  randomAddress: () => randomAddress,
5491
5492
  resourceBoundsToBigInt: () => resourceBoundsToBigInt,
@@ -5534,6 +5535,17 @@ function signatureToDecimalArray(sig) {
5534
5535
  function signatureToHexArray(sig) {
5535
5536
  return bigNumberishArrayToHexadecimalStringArray(formatSignature(sig));
5536
5537
  }
5538
+ function getSharedSecret(privateKey, fullPublicKey) {
5539
+ const privK = toHex(privateKey);
5540
+ const fullPubKHex = removeHexPrefix(toHex(fullPublicKey)).padStart(130, "0");
5541
+ if (fullPubKHex.length !== 130 || !fullPubKHex.startsWith("04")) {
5542
+ throw new Error(
5543
+ "fullPublicKey must be an uncompressed public key (starting with 04, 65 bytes total)"
5544
+ );
5545
+ }
5546
+ const sharedSecret = buf2hex(starkCurve.getSharedSecret(privK, fullPubKHex));
5547
+ return addHexPrefix(sharedSecret);
5548
+ }
5537
5549
  function zeroResourceBounds() {
5538
5550
  return toOverheadResourceBounds(ZeroFeeEstimate(), false);
5539
5551
  }