@toon-protocol/core 2.1.0 → 3.1.0
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/README.md +1 -1
- package/dist/index.d.ts +2 -92
- package/dist/index.js +16 -74
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Peer discovery, bootstrap, settlement negotiation, and TOON event encoding for the TOON Protocol network.
|
|
4
4
|
|
|
5
|
-
> This is an internal package. Most users should start with [`@toon-protocol/client`](
|
|
5
|
+
> This is an internal package. Most users should start with [`@toon-protocol/client`](https://github.com/toon-protocol/toon-client) or [`@toon-protocol/sdk`](../sdk).
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { I as InvalidEventError, P as PeerDiscoveryError, a as ToonDecodeError,
|
|
|
3
3
|
import { NostrEvent, Event } from 'nostr-tools/pure';
|
|
4
4
|
import { SimplePool } from 'nostr-tools/pool';
|
|
5
5
|
import { TurboAuthenticatedClient } from '@ardrive/turbo-sdk';
|
|
6
|
+
export { balanceProofFieldsMina, balanceProofHashEvm, balanceProofHashSolana, bigintToBytes32BE, concatBytes, coopCloseHashEvm, eip712DomainSeparatorEvm, hexToBytes, minaHashToField } from '@toon-protocol/settlement-digest';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Nostr event kind constants for ILP-related events.
|
|
@@ -2483,97 +2484,6 @@ declare function negotiateSettlementChain(requesterChains: string[], responderCh
|
|
|
2483
2484
|
*/
|
|
2484
2485
|
declare function resolveTokenForChain(chain: string, requesterPreferredTokens?: Record<string, string>, responderPreferredTokens?: Record<string, string>): string | undefined;
|
|
2485
2486
|
|
|
2486
|
-
/**
|
|
2487
|
-
* Shared balance-proof hash helpers — the single source of truth for the
|
|
2488
|
-
* byte/field layout that ALL signers and verifiers across the monorepo depend
|
|
2489
|
-
* on:
|
|
2490
|
-
* - the Swap-side signer (`packages/swap/src/payment-channel-signer.ts`)
|
|
2491
|
-
* - the sender-side settlement verifier (`packages/sdk/src/settlement/{evm,solana,mina}.ts`)
|
|
2492
|
-
* - the client-side balance-proof signers (`packages/client/src/signing/{solana,mina}-signer.ts`)
|
|
2493
|
-
*
|
|
2494
|
-
* Originally extracted from the Swap signer (Story 12.4) into `@toon-protocol/sdk`
|
|
2495
|
-
* (Story 12.6 AC-6). Relocated here to `@toon-protocol/core` so the client can
|
|
2496
|
-
* consume the canonical hashes WITHOUT taking a dependency on `@toon-protocol/sdk`
|
|
2497
|
-
* (the client only depends on core). `@toon-protocol/sdk` re-exports these names
|
|
2498
|
-
* unchanged, so Swap and existing SDK consumers are unaffected.
|
|
2499
|
-
*
|
|
2500
|
-
* Any change to a hash layout here automatically applies to every signer AND
|
|
2501
|
-
* verifier — they cannot drift.
|
|
2502
|
-
*
|
|
2503
|
-
* @module
|
|
2504
|
-
*/
|
|
2505
|
-
/**
|
|
2506
|
-
* Convert a hex string (with or without `0x` prefix) to bytes. Rejects
|
|
2507
|
-
* odd-length and non-hex input.
|
|
2508
|
-
*/
|
|
2509
|
-
declare function hexToBytes(hex: string): Uint8Array;
|
|
2510
|
-
/**
|
|
2511
|
-
* Encode a non-negative bigint as 32-byte big-endian. Throws if negative or
|
|
2512
|
-
* exceeds 256 bits.
|
|
2513
|
-
*/
|
|
2514
|
-
declare function bigintToBytes32BE(x: bigint): Uint8Array;
|
|
2515
|
-
/**
|
|
2516
|
-
* Concat N Uint8Arrays into one new Uint8Array.
|
|
2517
|
-
*/
|
|
2518
|
-
declare function concatBytes(...parts: Uint8Array[]): Uint8Array;
|
|
2519
|
-
/**
|
|
2520
|
-
* Compute the EVM balance-proof message hash:
|
|
2521
|
-
* keccak256(channelId || cumulativeAmount(32BE) || nonce(32BE) || recipient)
|
|
2522
|
-
*
|
|
2523
|
-
* `channelIdBytes` MUST be 32 bytes. `recipientBytes` MUST be 20 bytes.
|
|
2524
|
-
* This hash is what `EvmPaymentChannelSigner.signBalanceProof` signs and
|
|
2525
|
-
* what `recoverEvmSignerAddress` recovers against.
|
|
2526
|
-
*
|
|
2527
|
-
* @stable — signer and verifier depend on the exact byte layout.
|
|
2528
|
-
*/
|
|
2529
|
-
declare function balanceProofHashEvm(channelIdBytes: Uint8Array, cumulativeAmount: bigint, nonce: bigint, recipientBytes: Uint8Array): Uint8Array;
|
|
2530
|
-
/**
|
|
2531
|
-
* Compute the Solana balance-proof message hash:
|
|
2532
|
-
* sha256(utf8(channelId) || cumulativeAmount(32BE) || nonce(32BE) || utf8(recipient))
|
|
2533
|
-
*
|
|
2534
|
-
* `channelId` and `recipient` are base58-encoded strings (ASCII-subset of
|
|
2535
|
-
* UTF-8). This hash is what `SolanaPaymentChannelSigner.signBalanceProof`
|
|
2536
|
-
* signs and what `verifyEd25519Signature` verifies against.
|
|
2537
|
-
*
|
|
2538
|
-
* @stable — signer and verifier depend on the exact byte layout.
|
|
2539
|
-
*/
|
|
2540
|
-
declare function balanceProofHashSolana(channelId: string, cumulativeAmount: bigint, nonce: bigint, recipient: string): Uint8Array;
|
|
2541
|
-
/**
|
|
2542
|
-
* Hash an arbitrary string to a Pallas-field-safe bigint.
|
|
2543
|
-
*
|
|
2544
|
-
* The Pallas base field order is slightly below 2^254, so we take the first
|
|
2545
|
-
* 240 bits (60 hex chars / 30 bytes) of `sha256(utf8(s))` as a conservative,
|
|
2546
|
-
* guaranteed-in-field representation. Used to fold the variable-length
|
|
2547
|
-
* `channelId` / `recipient` strings into the fixed field-element array a Mina
|
|
2548
|
-
* Schnorr signature is computed over.
|
|
2549
|
-
*
|
|
2550
|
-
* @stable — Swap signer and SDK verifier depend on the exact derivation.
|
|
2551
|
-
*/
|
|
2552
|
-
declare function minaHashToField(s: string): bigint;
|
|
2553
|
-
/**
|
|
2554
|
-
* Compute the Mina balance-proof field-element message:
|
|
2555
|
-
* [ minaHashToField(channelId),
|
|
2556
|
-
* cumulativeAmount,
|
|
2557
|
-
* nonce,
|
|
2558
|
-
* minaHashToField(recipient) ]
|
|
2559
|
-
*
|
|
2560
|
-
* This is the EXACT `fields` array that the Swap's `MinaPaymentChannelSigner`
|
|
2561
|
-
* passes to `mina-signer`'s `signFields(...)`, and that the sender-side
|
|
2562
|
-
* `verifyMinaSignature` re-derives and passes to `verifyFields(...)`. Keeping
|
|
2563
|
-
* the derivation here (shared across `@toon-protocol/swap`, `@toon-protocol/sdk`,
|
|
2564
|
-
* and `@toon-protocol/client`) prevents signer/verifier drift — mirroring the
|
|
2565
|
-
* EVM/Solana hash helpers above.
|
|
2566
|
-
*
|
|
2567
|
-
* NOTE: this is the Swap↔sender wire contract (a Schnorr signature over four
|
|
2568
|
-
* field elements), NOT the connector's on-chain `MinaPaymentChannelSDK`
|
|
2569
|
-
* Poseidon-commitment proof shape. The two are distinct; see
|
|
2570
|
-
* `packages/sdk/src/settlement/mina.ts` for the relationship + the
|
|
2571
|
-
* remaining on-chain-settlement gap.
|
|
2572
|
-
*
|
|
2573
|
-
* @stable — Swap signer and SDK verifier depend on the exact byte layout.
|
|
2574
|
-
*/
|
|
2575
|
-
declare function balanceProofFieldsMina(channelId: string, cumulativeAmount: bigint, nonce: bigint, recipient: string): bigint[];
|
|
2576
|
-
|
|
2577
2487
|
/**
|
|
2578
2488
|
* Base58 (Bitcoin/Solana alphabet) encode/decode.
|
|
2579
2489
|
*
|
|
@@ -4645,4 +4555,4 @@ declare function selectLatestAddressable<T extends Event>(events: T[]): T | unde
|
|
|
4645
4555
|
*/
|
|
4646
4556
|
declare const VERSION = "0.1.0";
|
|
4647
4557
|
|
|
4648
|
-
export { AddressRegistry, type AgentRuntimeClient, ArDrivePeerRegistry, AttestationBootstrap, type AttestationBootstrapConfig, type AttestationBootstrapEvent, type AttestationBootstrapEventListener, type AttestationBootstrapResult, type AttestationEventOptions, AttestationState, AttestationVerifier, type AttestationVerifierConfig, type AttestedResultVerificationOptions, type AttestedResultVerificationResult, AttestedResultVerifier, BLOB_STORAGE_REQUEST_KIND, BLOB_STORAGE_RESULT_KIND, type BlobStorageRequestParams, type BootstrapConfig, BootstrapError, type BootstrapEvent, type BootstrapEventListener, type BootstrapPhase, type BootstrapResult, BootstrapService, type BootstrapServiceConfig, type BtpHandshakeExtension, type BuildIlpPeerInfoOptions, type BuildIlpPrepareParams, CHAIN_PRESETS, type CalculateRouteAmountParams, type ChainName, type ChainPreset, type ChainProviderConfigEntry, type ChainType, type ChannelState, type ClientNetworkPresets, type ConnectorAdminClient, type ConnectorAdminLike, type ConnectorChannelClient, type ConnectorChannelLike, type ConnectorNodeLike, type CustomEndpoints, type DeriveFromKmsSeedOptions, type DeterminismReport, type DirectRuntimeClientConfig, type DiscoveredPeer, type DiscoveryTracker, type DiscoveryTrackerConfig, type DvmJobStatus, type EVMProviderConfigEntry, EXPIRATION_TAG, type EmbeddableConnectorLike, type ForbiddenPattern, type GenesisPeer, GenesisPeerLoader, type HandlePacketAcceptResponse, type HandlePacketRejectResponse, type HandlePacketRequest, type HandlePacketResponse, ILP_PEER_INFO_KIND, ILP_ROOT_PREFIX, ILP_TO_SEMANTIC, IMAGE_GENERATION_KIND, type IlpClient, type IlpPeerInfo, type IlpPreparePacket, type IlpSendResult, JOB_FEEDBACK_KIND, JOB_REQUEST_KIND_BASE, JOB_RESULT_KIND_BASE, JOB_REVIEW_KIND, type JobFeedbackParams, type JobRequestParams, type JobResultParams, type JobReviewParams, KmsIdentityError, type KmsKeypair, type KnownPeer, type LogEntry, type LogLevel, type Logger, type LoggerConfig, MINA_CHAIN_PRESETS, MOCK_USDC_ADDRESS, MOCK_USDC_CONFIG, type MinaChainName, type MinaChainPreset, type MinaProviderConfigEntry, type MockUsdcConfig, type MultiChainName, type NetworkFamilyStatus, type NetworkMode, type NetworkNodeEnv, type NetworkProfile, type NixBuildResult, NixBuilder, type NixBuilderConfig, NostrPeerDiscovery, type OpenChannelParams, type OpenChannelResult, PET_INTERACTION_EVENT_KIND, PET_INTERACTION_REQUEST_KIND, PET_INTERACTION_RESULT_KIND, PREFIX_CLAIM_KIND, PREFIX_GRANT_KIND, type PacketHandler, type ParsedAttestation, type ParsedBlobStorageRequest, type ParsedJobFeedback, type ParsedJobRequest, type ParsedJobResult, type ParsedJobReview, type ParsedSwarmRequest, type ParsedSwarmSelection, type ParsedWorkflowDefinition, type ParsedWotDeclaration, PcrReproducibilityError, type PcrReproducibilityResult, type PeerDescriptor, type PrefixClaimContent, type PrefixGrantContent, type PrefixValidationResult, type PublishSeedRelayConfig, RELAY_ONLY_CHAIN, type RegisterPeerParams, type ReputationScore, ReputationScoreCalculator, type ReputationSignals, type ResolveRouteFeesParams, type ResolveRouteFeesResult, SEED_RELAY_LIST_KIND, SERVICE_DISCOVERY_KIND, SOLANA_CHAIN_PRESETS, SeedRelayDiscovery, type SeedRelayDiscoveryConfig, type SeedRelayDiscoveryResult, type SeedRelayEntry, type SendPacketParams, type SendPacketResult, type ServiceDiscoveryContent, type SettlementConfig, type SkillDescriptor, type SocialDiscoveryEvent, type SocialDiscoveryEventListener, SocialPeerDiscovery, type SocialPeerDiscoveryConfig, type SolanaChainName, type SolanaChainPreset, type SolanaProviderConfigEntry, type Subscription, type SwapPair, type SwarmRequestParams, type SwarmSelectionParams, TEE_ATTESTATION_KIND, TEXT_GENERATION_KIND, TEXT_TO_SPEECH_KIND, TRANSLATION_KIND, type TeeAttestation, ToonError, type ToonNode, type ToonNodeConfig, type ToonNodeStartResult, UI_RENDERER_KIND, UI_TAG, USDC_DECIMALS, USDC_NAME, USDC_SYMBOL, type UiCoordinate, VERSION, type VerificationResult, type VerifyOptions, type Violation, WEB_OF_TRUST_KIND, WORKFLOW_CHAIN_KIND, type WorkflowDefinitionParams, type WorkflowStep, type WotDeclarationParams, analyzeDockerfileForNonDeterminism, assignAddressFromHandshake,
|
|
4558
|
+
export { AddressRegistry, type AgentRuntimeClient, ArDrivePeerRegistry, AttestationBootstrap, type AttestationBootstrapConfig, type AttestationBootstrapEvent, type AttestationBootstrapEventListener, type AttestationBootstrapResult, type AttestationEventOptions, AttestationState, AttestationVerifier, type AttestationVerifierConfig, type AttestedResultVerificationOptions, type AttestedResultVerificationResult, AttestedResultVerifier, BLOB_STORAGE_REQUEST_KIND, BLOB_STORAGE_RESULT_KIND, type BlobStorageRequestParams, type BootstrapConfig, BootstrapError, type BootstrapEvent, type BootstrapEventListener, type BootstrapPhase, type BootstrapResult, BootstrapService, type BootstrapServiceConfig, type BtpHandshakeExtension, type BuildIlpPeerInfoOptions, type BuildIlpPrepareParams, CHAIN_PRESETS, type CalculateRouteAmountParams, type ChainName, type ChainPreset, type ChainProviderConfigEntry, type ChainType, type ChannelState, type ClientNetworkPresets, type ConnectorAdminClient, type ConnectorAdminLike, type ConnectorChannelClient, type ConnectorChannelLike, type ConnectorNodeLike, type CustomEndpoints, type DeriveFromKmsSeedOptions, type DeterminismReport, type DirectRuntimeClientConfig, type DiscoveredPeer, type DiscoveryTracker, type DiscoveryTrackerConfig, type DvmJobStatus, type EVMProviderConfigEntry, EXPIRATION_TAG, type EmbeddableConnectorLike, type ForbiddenPattern, type GenesisPeer, GenesisPeerLoader, type HandlePacketAcceptResponse, type HandlePacketRejectResponse, type HandlePacketRequest, type HandlePacketResponse, ILP_PEER_INFO_KIND, ILP_ROOT_PREFIX, ILP_TO_SEMANTIC, IMAGE_GENERATION_KIND, type IlpClient, type IlpPeerInfo, type IlpPreparePacket, type IlpSendResult, JOB_FEEDBACK_KIND, JOB_REQUEST_KIND_BASE, JOB_RESULT_KIND_BASE, JOB_REVIEW_KIND, type JobFeedbackParams, type JobRequestParams, type JobResultParams, type JobReviewParams, KmsIdentityError, type KmsKeypair, type KnownPeer, type LogEntry, type LogLevel, type Logger, type LoggerConfig, MINA_CHAIN_PRESETS, MOCK_USDC_ADDRESS, MOCK_USDC_CONFIG, type MinaChainName, type MinaChainPreset, type MinaProviderConfigEntry, type MockUsdcConfig, type MultiChainName, type NetworkFamilyStatus, type NetworkMode, type NetworkNodeEnv, type NetworkProfile, type NixBuildResult, NixBuilder, type NixBuilderConfig, NostrPeerDiscovery, type OpenChannelParams, type OpenChannelResult, PET_INTERACTION_EVENT_KIND, PET_INTERACTION_REQUEST_KIND, PET_INTERACTION_RESULT_KIND, PREFIX_CLAIM_KIND, PREFIX_GRANT_KIND, type PacketHandler, type ParsedAttestation, type ParsedBlobStorageRequest, type ParsedJobFeedback, type ParsedJobRequest, type ParsedJobResult, type ParsedJobReview, type ParsedSwarmRequest, type ParsedSwarmSelection, type ParsedWorkflowDefinition, type ParsedWotDeclaration, PcrReproducibilityError, type PcrReproducibilityResult, type PeerDescriptor, type PrefixClaimContent, type PrefixGrantContent, type PrefixValidationResult, type PublishSeedRelayConfig, RELAY_ONLY_CHAIN, type RegisterPeerParams, type ReputationScore, ReputationScoreCalculator, type ReputationSignals, type ResolveRouteFeesParams, type ResolveRouteFeesResult, SEED_RELAY_LIST_KIND, SERVICE_DISCOVERY_KIND, SOLANA_CHAIN_PRESETS, SeedRelayDiscovery, type SeedRelayDiscoveryConfig, type SeedRelayDiscoveryResult, type SeedRelayEntry, type SendPacketParams, type SendPacketResult, type ServiceDiscoveryContent, type SettlementConfig, type SkillDescriptor, type SocialDiscoveryEvent, type SocialDiscoveryEventListener, SocialPeerDiscovery, type SocialPeerDiscoveryConfig, type SolanaChainName, type SolanaChainPreset, type SolanaProviderConfigEntry, type Subscription, type SwapPair, type SwarmRequestParams, type SwarmSelectionParams, TEE_ATTESTATION_KIND, TEXT_GENERATION_KIND, TEXT_TO_SPEECH_KIND, TRANSLATION_KIND, type TeeAttestation, ToonError, type ToonNode, type ToonNodeConfig, type ToonNodeStartResult, UI_RENDERER_KIND, UI_TAG, USDC_DECIMALS, USDC_NAME, USDC_SYMBOL, type UiCoordinate, VERSION, type VerificationResult, type VerifyOptions, type Violation, WEB_OF_TRUST_KIND, WORKFLOW_CHAIN_KIND, type WorkflowDefinitionParams, type WorkflowStep, type WotDeclarationParams, analyzeDockerfileForNonDeterminism, assignAddressFromHandshake, base58Decode, base58Encode, buildAttestationEvent, buildBlobStorageRequest, buildEip712Domain, buildEvmProviderEntry, buildIlpPeerInfoEvent, buildIlpPrepare, buildJobFeedbackEvent, buildJobRequestEvent, buildJobResultEvent, buildJobReviewEvent, buildMinaProviderEntry, buildPrefixClaimEvent, buildPrefixGrantEvent, buildPrefixHandshakeData, buildSeedRelayListEvent, buildServiceDiscoveryEvent, buildSolanaProviderEntry, buildSwarmRequestEvent, buildSwarmSelectionEvent, buildUiCoordinate, buildWorkflowDefinitionEvent, buildWotDeclarationEvent, calculateRouteAmount, checkAddressCollision, createAgentRuntimeClient, createDirectChannelClient, createDirectConnectorAdmin, createDirectIlpClient, createDirectRuntimeClient, createDiscoveryTracker, createHttpChannelClient, createHttpConnectorAdmin, createHttpIlpClient$1 as createHttpIlpClient, createHttpRuntimeClient, createHttpIlpClient as createHttpRuntimeClientV2, createLogger, createToonNode, deriveChildAddress, deriveFromKmsSeed, deriveMinaPublicKeyBase58, extractPrefixFromHandshake, getEventExpiration, getUiCoordinate, hasMinReputation, hasRequireAttestation, hexToMinaBase58PrivateKey, ilpCodeToSemantic, isEventExpired, isGenesisNode, isValidIlpAddressStructure, negotiateSettlementChain, parseAttestation, parseBlobStorageRequest, parseIlpPeerInfo, parseJobFeedback, parseJobRequest, parseJobResult, parseJobReview, parsePrefixClaimEvent, parsePrefixGrantEvent, parseSeedRelayList, parseServiceDiscovery, parseSwarmRequest, parseSwarmSelection, parseUiCoordinate, parseWorkflowDefinition, parseWotDeclaration, publishSeedRelayEntry, readDockerfileNix, resolveChainConfig, resolveClientNetwork, resolveMinaChainConfig, resolveNetworkProfile, resolveRouteFees, resolveSolanaChainConfig, resolveTokenForChain, selectLatestAddressable, validateChainId, validateIlpAddress, validatePrefix, validatePrefixConsistency, verifyPcrReproducibility };
|
package/dist/index.js
CHANGED
|
@@ -2948,77 +2948,17 @@ function resolveTokenForChain(chain, requesterPreferredTokens, responderPreferre
|
|
|
2948
2948
|
}
|
|
2949
2949
|
|
|
2950
2950
|
// src/settlement/hashes.ts
|
|
2951
|
-
import { keccak_256 } from "@noble/hashes/sha3.js";
|
|
2952
|
-
import { sha256 } from "@noble/hashes/sha2.js";
|
|
2953
2951
|
import {
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
}
|
|
2964
|
-
function bigintToBytes32BE(x) {
|
|
2965
|
-
if (x < 0n) {
|
|
2966
|
-
throw new Error("bigint must be non-negative for balance-proof encoding");
|
|
2967
|
-
}
|
|
2968
|
-
const out = new Uint8Array(32);
|
|
2969
|
-
let v = x;
|
|
2970
|
-
for (let i = 31; i >= 0; i--) {
|
|
2971
|
-
out[i] = Number(v & 0xffn);
|
|
2972
|
-
v >>= 8n;
|
|
2973
|
-
}
|
|
2974
|
-
if (v !== 0n) {
|
|
2975
|
-
throw new Error("bigint exceeds 256 bits");
|
|
2976
|
-
}
|
|
2977
|
-
return out;
|
|
2978
|
-
}
|
|
2979
|
-
function concatBytes(...parts) {
|
|
2980
|
-
let len = 0;
|
|
2981
|
-
for (const p of parts) len += p.length;
|
|
2982
|
-
const out = new Uint8Array(len);
|
|
2983
|
-
let o = 0;
|
|
2984
|
-
for (const p of parts) {
|
|
2985
|
-
out.set(p, o);
|
|
2986
|
-
o += p.length;
|
|
2987
|
-
}
|
|
2988
|
-
return out;
|
|
2989
|
-
}
|
|
2990
|
-
function balanceProofHashEvm(channelIdBytes, cumulativeAmount, nonce, recipientBytes) {
|
|
2991
|
-
return keccak_256(
|
|
2992
|
-
concatBytes(
|
|
2993
|
-
channelIdBytes,
|
|
2994
|
-
bigintToBytes32BE(cumulativeAmount),
|
|
2995
|
-
bigintToBytes32BE(nonce),
|
|
2996
|
-
recipientBytes
|
|
2997
|
-
)
|
|
2998
|
-
);
|
|
2999
|
-
}
|
|
3000
|
-
function balanceProofHashSolana(channelId, cumulativeAmount, nonce, recipient) {
|
|
3001
|
-
return sha256(
|
|
3002
|
-
concatBytes(
|
|
3003
|
-
new TextEncoder().encode(channelId),
|
|
3004
|
-
bigintToBytes32BE(cumulativeAmount),
|
|
3005
|
-
bigintToBytes32BE(nonce),
|
|
3006
|
-
new TextEncoder().encode(recipient)
|
|
3007
|
-
)
|
|
3008
|
-
);
|
|
3009
|
-
}
|
|
3010
|
-
function minaHashToField(s) {
|
|
3011
|
-
const digestHex = bytesToHex(sha256(new TextEncoder().encode(s)));
|
|
3012
|
-
return BigInt("0x" + digestHex.slice(0, 60));
|
|
3013
|
-
}
|
|
3014
|
-
function balanceProofFieldsMina(channelId, cumulativeAmount, nonce, recipient) {
|
|
3015
|
-
return [
|
|
3016
|
-
minaHashToField(channelId),
|
|
3017
|
-
cumulativeAmount,
|
|
3018
|
-
nonce,
|
|
3019
|
-
minaHashToField(recipient)
|
|
3020
|
-
];
|
|
3021
|
-
}
|
|
2952
|
+
hexToBytes,
|
|
2953
|
+
bigintToBytes32BE,
|
|
2954
|
+
concatBytes,
|
|
2955
|
+
eip712DomainSeparatorEvm,
|
|
2956
|
+
balanceProofHashEvm,
|
|
2957
|
+
coopCloseHashEvm,
|
|
2958
|
+
balanceProofHashSolana,
|
|
2959
|
+
minaHashToField,
|
|
2960
|
+
balanceProofFieldsMina
|
|
2961
|
+
} from "@toon-protocol/settlement-digest";
|
|
3022
2962
|
|
|
3023
2963
|
// src/settlement/base58.ts
|
|
3024
2964
|
var BASE58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
@@ -3060,7 +3000,7 @@ function base58Decode(str) {
|
|
|
3060
3000
|
}
|
|
3061
3001
|
|
|
3062
3002
|
// src/settlement/mina-key.ts
|
|
3063
|
-
import { sha256
|
|
3003
|
+
import { sha256 } from "@noble/hashes/sha2.js";
|
|
3064
3004
|
var MINA_PRIVATE_KEY_VERSION = 90;
|
|
3065
3005
|
function hexToMinaBase58PrivateKey(privateKey) {
|
|
3066
3006
|
if (!/^(0x)?[0-9a-fA-F]{64}$/.test(privateKey)) {
|
|
@@ -3072,7 +3012,7 @@ function hexToMinaBase58PrivateKey(privateKey) {
|
|
|
3072
3012
|
Uint8Array.from([MINA_PRIVATE_KEY_VERSION, 1]),
|
|
3073
3013
|
leScalar
|
|
3074
3014
|
);
|
|
3075
|
-
const checksum =
|
|
3015
|
+
const checksum = sha256(sha256(payload)).slice(0, 4);
|
|
3076
3016
|
return base58Encode(concatBytes(payload, checksum));
|
|
3077
3017
|
}
|
|
3078
3018
|
async function deriveMinaPublicKeyBase58(privateKey) {
|
|
@@ -5153,8 +5093,8 @@ var NixBuilder = class {
|
|
|
5153
5093
|
);
|
|
5154
5094
|
}
|
|
5155
5095
|
const imageData = await readFile(imagePath);
|
|
5156
|
-
const
|
|
5157
|
-
const imageHash = `sha256:${
|
|
5096
|
+
const sha2562 = createHash("sha256").update(imageData).digest("hex");
|
|
5097
|
+
const imageHash = `sha256:${sha2562}`;
|
|
5158
5098
|
const pcr0 = createHash("sha384").update(imageData).digest("hex");
|
|
5159
5099
|
const KERNEL_REGION_SIZE = 1024 * 1024;
|
|
5160
5100
|
const kernelRegion = imageData.subarray(
|
|
@@ -5514,6 +5454,7 @@ export {
|
|
|
5514
5454
|
calculateRouteAmount,
|
|
5515
5455
|
checkAddressCollision,
|
|
5516
5456
|
concatBytes,
|
|
5457
|
+
coopCloseHashEvm,
|
|
5517
5458
|
createAgentRuntimeClient,
|
|
5518
5459
|
createDirectChannelClient,
|
|
5519
5460
|
createDirectConnectorAdmin,
|
|
@@ -5531,6 +5472,7 @@ export {
|
|
|
5531
5472
|
deriveChildAddress,
|
|
5532
5473
|
deriveFromKmsSeed,
|
|
5533
5474
|
deriveMinaPublicKeyBase58,
|
|
5475
|
+
eip712DomainSeparatorEvm,
|
|
5534
5476
|
encodeEventToToon,
|
|
5535
5477
|
encodeEventToToonString,
|
|
5536
5478
|
extractPrefixFromHandshake,
|