@toon-protocol/sdk 3.0.0 → 3.1.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
@@ -2364,9 +2364,9 @@ function validateConfig(config) {
2364
2364
  }
2365
2365
 
2366
2366
  // src/settlement/evm.ts
2367
- import { secp256k1 } from "@noble/curves/secp256k1.js";
2368
2367
  import { keccak_256 } from "@noble/hashes/sha3.js";
2369
2368
  import { bytesToHex } from "@noble/hashes/utils.js";
2369
+ import { recoverEvmSigner } from "@toon-protocol/settlement-digest";
2370
2370
 
2371
2371
  // src/settlement/hashes.ts
2372
2372
  import {
@@ -2422,10 +2422,6 @@ function recoverEvmSignerAddress(claim, chainId, verifyingContract) {
2422
2422
  `EVM signature v must be 27 or 28, got ${v}`
2423
2423
  );
2424
2424
  }
2425
- const recovery = v - 27;
2426
- const compactRS = claim.claimBytes.slice(0, 64);
2427
- let msgHash;
2428
- let uncompressedPubkey;
2429
2425
  try {
2430
2426
  const channelIdBytes = hexToBytes2(claim.channelId);
2431
2427
  const recipientBytes = hexToBytes2(claim.recipient);
@@ -2445,7 +2441,7 @@ function recoverEvmSignerAddress(claim, chainId, verifyingContract) {
2445
2441
  `verifyingContract must be 20 bytes (got ${verifyingContractBytes.length})`
2446
2442
  );
2447
2443
  }
2448
- msgHash = balanceProofHashEvm(
2444
+ const msgHash = balanceProofHashEvm(
2449
2445
  channelIdBytes,
2450
2446
  BigInt(claim.cumulativeAmount),
2451
2447
  BigInt(claim.nonce),
@@ -2453,12 +2449,7 @@ function recoverEvmSignerAddress(claim, chainId, verifyingContract) {
2453
2449
  BigInt(chainId),
2454
2450
  verifyingContractBytes
2455
2451
  );
2456
- const sig = secp256k1.Signature.fromBytes(
2457
- compactRS,
2458
- "compact"
2459
- ).addRecoveryBit(recovery);
2460
- const point = sig.recoverPublicKey(msgHash);
2461
- uncompressedPubkey = point.toBytes(false);
2452
+ return recoverEvmSigner(msgHash, claim.claimBytes);
2462
2453
  } catch (err) {
2463
2454
  throw new SettlementTxError(
2464
2455
  "ENCODING_FAILED",
@@ -2466,8 +2457,6 @@ function recoverEvmSignerAddress(claim, chainId, verifyingContract) {
2466
2457
  { cause: err }
2467
2458
  );
2468
2459
  }
2469
- const addrHash = keccak_256(uncompressedPubkey.slice(1));
2470
- return "0x" + bytesToHex(addrHash.slice(-20)).toLowerCase();
2471
2460
  }
2472
2461
  function padLeft32(bytes) {
2473
2462
  if (bytes.length > 32) {