@zelana/sdk 0.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.
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Zelana Keypair - Ed25519 key management and signing
3
+ *
4
+ * Provides key generation, import/export, and transaction signing.
5
+ */
6
+ import type { Bytes32, TransferRequest, WithdrawRequest } from './types';
7
+ /**
8
+ * Zelana Keypair for L2 transactions
9
+ *
10
+ * Wraps an Ed25519 keypair and provides signing methods for
11
+ * transfers, withdrawals, and other L2 operations.
12
+ */
13
+ export declare class Keypair {
14
+ private readonly secretKey;
15
+ private readonly _publicKey;
16
+ private constructor();
17
+ /**
18
+ * Generate a new random keypair
19
+ */
20
+ static generate(): Keypair;
21
+ /**
22
+ * Create keypair from a 32-byte secret key (seed)
23
+ */
24
+ static fromSecretKey(secretKey: Uint8Array): Keypair;
25
+ /**
26
+ * Create keypair from hex-encoded secret key
27
+ */
28
+ static fromHex(hex: string): Keypair;
29
+ /**
30
+ * Create keypair from base58-encoded secret key
31
+ */
32
+ static fromBase58(base58: string): Keypair;
33
+ /**
34
+ * Get the public key as Uint8Array
35
+ */
36
+ get publicKey(): Bytes32;
37
+ /**
38
+ * Get the public key as hex string
39
+ */
40
+ get publicKeyHex(): string;
41
+ /**
42
+ * Get the public key as base58 string (Solana format)
43
+ */
44
+ get publicKeyBase58(): string;
45
+ /**
46
+ * Get the secret key as hex string (be careful with this!)
47
+ */
48
+ get secretKeyHex(): string;
49
+ /**
50
+ * Get the secret key as base58 string
51
+ */
52
+ get secretKeyBase58(): string;
53
+ /**
54
+ * Sign arbitrary message bytes
55
+ */
56
+ sign(message: Uint8Array): Uint8Array;
57
+ /**
58
+ * Verify a signature (static method)
59
+ */
60
+ static verify(signature: Uint8Array, message: Uint8Array, publicKey: Uint8Array): boolean;
61
+ /**
62
+ * Sign a transfer transaction
63
+ *
64
+ * The message format matches the Rust TransactionData wincode serialization:
65
+ * - from: [u8; 32]
66
+ * - to: [u8; 32]
67
+ * - amount: u64 (little-endian)
68
+ * - nonce: u64 (little-endian)
69
+ * - chain_id: u64 (little-endian)
70
+ */
71
+ signTransfer(to: Bytes32, amount: bigint, nonce: bigint, chainId?: bigint): TransferRequest;
72
+ /**
73
+ * Sign a withdrawal request
74
+ *
75
+ * The message format matches the Rust withdrawal verification:
76
+ * - from: [u8; 32]
77
+ * - to_l1_address: [u8; 32]
78
+ * - amount: u64 (little-endian)
79
+ * - nonce: u64 (little-endian)
80
+ */
81
+ signWithdrawal(toL1Address: Bytes32, amount: bigint, nonce: bigint): WithdrawRequest;
82
+ }
83
+ /**
84
+ * PublicKey wrapper for address representation
85
+ */
86
+ export declare class PublicKey {
87
+ private readonly bytes;
88
+ constructor(input: Uint8Array | string);
89
+ /**
90
+ * Get bytes representation
91
+ */
92
+ toBytes(): Bytes32;
93
+ /**
94
+ * Get hex string representation
95
+ */
96
+ toHex(): string;
97
+ /**
98
+ * Get base58 representation (Solana format)
99
+ */
100
+ toBase58(): string;
101
+ /**
102
+ * Default string representation is base58
103
+ */
104
+ toString(): string;
105
+ /**
106
+ * Check equality with another public key
107
+ */
108
+ equals(other: PublicKey | Uint8Array): boolean;
109
+ }
110
+ //# sourceMappingURL=keypair.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keypair.d.ts","sourceRoot":"","sources":["../src/keypair.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAaH,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAKzE;;;;;GAKG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAa;IACvC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IAExC,OAAO;IAKP;;OAEG;IACH,MAAM,CAAC,QAAQ,IAAI,OAAO;IAM1B;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,UAAU,GAAG,OAAO;IAQpD;;OAEG;I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y-preserving transactions using note-based commitments.
5
+ *
6
+ * Note: This is a client-side helper. The actual ZK proof generation
7
+ * must be done by a separate prover (either WASM or native).
8
+ */
9
+ import type { Bytes32 } from './types';
10
+ /**
11
+ * A shielded note representing privately held value
12
+ */
13
+ export interface Note {
14
+ /** The value held in this note */
15
+ value: bigint;
16
+ /** Random blinding factor (32 bytes) */
17
+ randomness: Bytes32;
18
+ /** Owner's shielded public key (32 bytes) */
19
+ ownerPk: Bytes32;
20
+ /** Position in the commitment tree (set after insertion) */
21
+ position?: bigint;
22
+ }
23
+ /**
24
+ * Encrypted note data (sent on-chain)
25
+ */
26
+ export interface EncryptedNote {
27
+ /** Ephemeral public key for ECDH (32 bytes) */
28
+ ephemeralPk: Bytes32;
29
+ /** Nonce for ChaCha20-Poly1305 (12 bytes) */
30
+ nonce: Uint8Array;
31
+ /** Encrypted note data with authentication tag */
32
+ ciphertext: Uint8Array;
33
+ }
34
+ /**
35
+ * Merkle path for proving note membership
36
+ */
37
+ export interface MerklePath {
38
+ /** Sibling hashes from leaf to root */
39
+ siblings: Bytes32[];
40
+ /** Bit indicating left (0) or right (1) for each level */
41
+ indices: boolean[];
42
+ }
43
+ /**
44
+ * Shielded spending key bundle
45
+ */
46
+ export interface ShieldedKeys {
47
+ /** Spending key - allows spending notes (keep secret!) */
48
+ spendingKey: Bytes32;
49
+ /** Viewing key - allows viewing notes (for auditors) */
50
+ viewingKey: Bytes32;
51
+ /** Public key / address (can be shared) */
52
+ publicKey: Bytes32;
53
+ }
54
+ /**
55
+ * Input for a shielded transaction (spending a note)
56
+ */
57
+ export interface ShieldedInput {
58
+ /** The note being spent */
59
+ note: Note;
60
+ /** Merkle path proving note is in the tree */
61
+ merklePath: MerklePath;
62
+ /** Spending key for this note */
63
+ spendingKey: Bytes32;
64
+ }
65
+ /**
66
+ * Output for a shielded transaction (creating a note)
67
+ */
68
+ export interface ShieldedOutput {
69
+ /** Recipient's shielded public key */
70
+ recipientPk: Bytes32;
71
+ /** Amount to send */
72
+ value: bigint;
73
+ /** Optional memo (max 512 bytes) */
74
+ memo?: Uint8Array;
75
+ }
76
+ /**
77
+ * Prepared shielded transaction (ready for proving)
78
+ */
79
+ export interface PreparedShieldedTx {
80
+ /** Nullifiers for spent notes */
81
+ nullifiers: Bytes32[];
82
+ /** Commitments for new notes */
83
+ commitments: Bytes32[];
84
+ /** Encrypted outputs for recipients */
85
+ encryptedOutputs: EncryptedNote[];
86
+ /** Merkle root being referenced */
87
+ merkleRoot: Bytes32;
88
+ /** Witness data for ZK proof (internal) */
89
+ witness: ShieldedWitness;
90
+ }
91
+ /**
92
+ * Witness data for ZK proof generation
93
+ */
94
+ export interface ShieldedWitness {
95
+ inputs: Array<{
96
+ note: Note;
97
+ merklePath: MerklePath;
98
+ spendingKey: Bytes32;
99
+ nullifier: Bytes32;
100
+ }>;
101
+ outputs: Array<{
102
+ note: Note;
103
+ commitment: Bytes32;
104
+ }>;
105
+ }
106
+ /**
107
+ * Shielded transaction ready for submission
108
+ */
109
+ export interface ShieldedTransaction {
110
+ /** ZK proof bytes (Groth16) */
111
+ proof: Uint8Array;
112
+ /** Nullifiers (spent note identifiers) */
113
+ nullifiers: Bytes32[];
114
+ /** Commitments (new note identifiers) */
115
+ commitments: Bytes32[];
116
+ /** Encrypted notes for recipients */
117
+ encryptedOutputs: EncryptedNote[];
118
+ }
119
+ /**
120
+ * Generate a new shielded key bundle
121
+ *
122
+ * Warning: In production, use a proper key derivation from a master seed.
123
+ */
124
+ export declare function generateShieldedKeys(): ShieldedKeys;
125
+ /**
126
+ * Restore shielded keys from spending key
127
+ */
128
+ export declare function shieldedKeysFromSpendingKey(spendingKey: Bytes32): ShieldedKeys;
129
+ /**
130
+ * Create a new note with random blinding
131
+ */
132
+ export declare function createNote(value: bigint, ownerPk: Bytes32, position?: bigint): Note;
133
+ /**
134
+ * Create a note with explicit randomness (for testing/recovery)
135
+ */
136
+ export declare function noteWithRandomness(value: bigint, ownerPk: Bytes32, randomness: Bytes32, position?: bigint): Note;
137
+ /**
138
+ * Compute commitment for a note
139
+ *
140
+ * commitment = Hash(value || randomness || owner_pk)
141
+ *
142
+ * Note: Rust uses Poseidon hash - this uses SHA-512 for simplicity.
143
+ * For production, this should match the circuit's hash function.
144
+ */
145
+ export declare function computeCommitment(note: Note): Bytes32;
146
+ /**
147
+ * Derive nullifier for spending a note
148
+ *
149
+ * nullifier = Hash(nk || commitment || position)
150
+ *
151
+ * Requires the note to have a position set.
152
+ */
153
+ export declare function computeNullifier(note: Note, spendingKey: Bytes32): Bytes32 | null;
154
+ /**
155
+ * ShieldedTransactionBuilder helps construct shielded transactions
156
+ */
157
+ export declare class ShieldedTransactionBuilder {
158
+ private inputs;
159
+ private outputs;
160
+ private merkleRoot;
161
+ /**
162
+ * Add an input (note to spend)
163
+ */
164
+ addInput(input: ShieldedInput): this;
165
+ /**
166
+ * Add an output (note to create)
167
+ */
168
+ addOutput(output: ShieldedOutput): this;
169
+ /**
170
+ * Set the merkle root being referenced
171
+ */
172
+ setMerkleRoot(root: Bytes32): this;
173
+ /**
174
+ * Validate the transaction
175
+ * - Sum of inputs must equal sum of outputs
176
+ * - All inputs must have positions
177
+ * - Merkle root must be set
178
+ */
179
+ validate(): {
180
+ valid: boolean;
181
+ error?: string;
182
+ };
183
+ /**
184
+ * Prepare the transaction for proving
185
+ *
186
+ * Returns all the data needed to generate a ZK proof.
187
+ */
188
+ prepare(): PreparedShieldedTx;
189
+ /**
190
+ * Clear the builder for reuse
191
+ */
192
+ clear(): this;
193
+ }
194
+ /**
195
+ * Scan encrypted notes for ones belonging to a viewing key
196
+ *
197
+ * This is used by wallets to find owned notes.
198
+ */
199
+ export interface ScanResult {
200
+ /** Position in the commitment tree */
201
+ position: bigint;
202
+ /** Decrypted note */
203
+ note: Note;
204
+ /** Commitment (for verification) */
205
+ commitment: Bytes32;
206
+ /** Decrypted memo */
207
+ memo?: Uint8Array;
208
+ }
209
+ /**
210
+ * Try to decrypt an encrypted note
211
+ *
212
+ * Returns the note if decryption succeeds, null otherwise.
213
+ *
214
+ * Note: This is a placeholder - real implementation needs the
215
+ * recipient's X25519 secret key for ECDH.
216
+ */
217
+ export declare function tryDecryptNote(encrypted: EncryptedNote, viewingKey: Bytes32, ownerPk: Bytes32, position: bigint): Note | null;
218
+ export declare const shielded: {
219
+ generateKeys: typeof generateShieldedKeys;
220
+ keysFromSpendingKey: typeof shieldedKeysFromSpendingKey;
221
+ createNote: typeof createNote;
222
+ noteWithRandomness: typeof noteWithRandomness;
223
+ computeCommitment: typeof computeCommitment;
224
+ computeNullifier: typeof computeNullifier;
225
+ TransactionBuilder: typeof ShieldedTransactionBuilder;
226
+ };
227
+ //# sourceMappingURL=shielded.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shielded.d.ts","sourceRoot":"","sources":["../src/shielded.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAMvC;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,UAAU,EAAE,OAAO,CAAC;IACpB,6CAA6C;IAC7C,OAAO,EAAE,OAAO,CAAC;IACjB,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,+CAA+C;IAC/C,WAAW,EAAE,OAAO,CAAC;IACrB,6CAA6C;IAC7C,KAAK,EAAE,UAAU,CAAC;IAClB,kDAAkD;IAClD,UAAU,EAAE,UAAU,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,uCAAuC;IACvC,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,0DAA0D;IAC1D,OAAO,EAAE,OAAO,EAAE,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,0DAA0D;IAC1D,WAAW,EAAE,OAAO,CAAC;IACr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ACzB,sCAAsC;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,qBAAqB;IACrB,IAAI,EAAE,IAAI,CAAC;IACX,oCAAoC;IACpC,UAAU,EAAE,OAAO,CAAC;IACpB,qBAAqB;IACrB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,OAAO,EACnB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,GACf,IAAI,GAAG,IAAI,CAKb;AAMD,eAAO,MAAM,QAAQ;;;;;;;;CAQpB,CAAC"}
@@ -0,0 +1,221 @@
1
+ /**
2
+ * Zelana SDK Type Definitions
3
+ *
4
+ * These types mirror the Rust API types in core/src/api/types.rs
5
+ */
6
+ /** 32-byte array represented as Uint8Array */
7
+ export type Bytes32 = Uint8Array;
8
+ /** Account state on L2 */
9
+ export interface AccountState {
10
+ accountId: string;
11
+ balance: bigint;
12
+ nonce: bigint;
13
+ }
14
+ /** Transaction type enumeration */
15
+ export type TxType = 'deposit' | 'transfer' | 'shielded' | 'withdrawal';
16
+ /** Transaction status */
17
+ export type TxStatus = 'pending' | 'included' | 'executed' | 'settled' | 'failed';
18
+ /** Batch status */
19
+ export type BatchStatus = 'building' | 'proving' | 'pending_settlement' | 'settled' | 'failed';
20
+ /** Transaction summary */
21
+ export interface TxSummary {
22
+ txHash: string;
23
+ txType: TxType;
24
+ batchId?: bigint;
25
+ status: TxStatus;
26
+ receivedAt: bigint;
27
+ executedAt?: bigint;
28
+ amount?: bigint;
29
+ from?: string;
30
+ to?: string;
31
+ }
32
+ /** Batch summary */
33
+ export interface BatchSummary {
34
+ batchId: bigint;
35
+ txCount: number;
36
+ stateRoot: string;
37
+ shieldedRoot: string;
38
+ l1TxSig?: string;
39
+ status: BatchStatus;
40
+ createdAt: bigint;
41
+ settledAt?: bigint;
42
+ }
43
+ /** Transfer request */
44
+ export interface TransferRequest {
45
+ from: Bytes32;
46
+ to: Bytes32;
47
+ amount: bigint;
48
+ nonce: bigint;
49
+ chainId: bigint;
50
+ signature: Uint8Array;
51
+ signerPubkey: Bytes32;
52
+ }
53
+ /** Transfer response */
54
+ export interface TransferResponse {
55
+ txHash: string;
56
+ accepted: boolean;
57
+ message: string;
58
+ }
59
+ /** Withdrawal request */
60
+ export interface WithdrawRequest {
61
+ from: Bytes32;
62
+ toL1Address: Bytes32;
63
+ amount: bigint;
64
+ nonce: bigint;
65
+ signature: Uint8Array;
66
+ signerPubkey: Bytes32;
67
+ }
68
+ /** Withdrawal response */
69
+ export interface WithdrawResponse {
70
+ txHash: string;
71
+ accepted: boolean;
72
+ estimatedCompletion?: string;
73
+ message: string;
74
+ }
75
+ /** Withdrawal status */
76
+ export interface WithdrawalStatus {
77
+ txHash: string;
78
+ state: string;
79
+ amount: bigint;
80
+ toL1Address: string;
81
+ l1TxSig?: string;
82
+ }
83
+ /** Shielded transaction request */
84
+ export interface ShieldedRequest {
85
+ proof: Uint8Array;
86
+ nullifier: Bytes32;
87
+ commitment: Bytes32;
88
+ ciphertext: Uint8Array;
89
+ ephemeralKey: Bytes32;
90
+ }
91
+ /** Shielded transaction response */
92
+ export interface ShieldedResponse {
93
+ txHash: string;
94
+ accepted: boolean;
95
+ position?: number;
96
+ message: string;
97
+ }
98
+ /** State roots response */
99
+ export interface StateRoots {
100
+ batchId: bigint;
101
+ stateRoot: string;
102
+ shieldedRoot: string;
103
+ commitmentCount: bigint;
104
+ }
105
+ /** Batch status response */
106
+ export interface BatchStatusInfo {
107
+ currentBatchId: bigint;
108
+ currentBatchTxs: number;
109
+ provingCount: number;
110
+ pendingSettlement: number;
111
+ }
112
+ /** Health response */
113
+ export interface HealthInfo {
114
+ healthy: boolean;
115
+ version: string;
116
+ uptimeSecs: bigint;
117
+ }
118
+ /** Global statistics */
119
+ export interface GlobalStats {
120
+ totalBatches: bigint;
121
+ totalTransactions: bigint;
122
+ totalDeposited: bigint;
123
+ totalWithdrawn: bigint;
124
+ currentBatchId: bigint;
125
+ activeAccounts: bigint;
126
+ shieldedCommitments: bigint;
127
+ uptimeSecs: bigint;
128
+ }
129
+ /** Fast withdrawal quote */
130
+ export interface FastWithdrawQuote {
131
+ available: boolean;
132
+ amount: bigint;
133
+ fee: bigint;
134
+ amountReceived: bigint;
135
+ feeBps: number;
136
+ lpAddress?: string;
137
+ }
138
+ /** Committee member info */
139
+ export interface CommitteeMemberInfo {
140
+ id: number;
141
+ publicKey: string;
142
+ endpoint?: string;
143
+ }
144
+ /** Committee info */
145
+ export interface CommitteeInfo {
146
+ enabled: boolean;
147
+ threshold: number;
148
+ totalMembers: number;
149
+ epoch: bigint;
150
+ members: CommitteeMemberInfo[];
151
+ pendingCount: number;
152
+ }
153
+ /** Merkle path response */
154
+ export interface MerklePath {
155
+ position: number;
156
+ path: string[];
157
+ root: string;
158
+ }
159
+ /** Scanned note */
160
+ export interface ScannedNote {
161
+ position: number;
162
+ commitment: string;
163
+ value: bigint;
164
+ memo?: string;
165
+ }
166
+ /** Pagination parameters */
167
+ export interface PaginationParams {
168
+ offset?: number;
169
+ limit?: number;
170
+ }
171
+ /** Paginated response */
172
+ export interface PaginatedResponse<T> {
173
+ items: T[];
174
+ total: number;
175
+ offset: number;
176
+ limit: number;
177
+ }
178
+ /** API error response */
179
+ export interface ApiError {
180
+ error: string;
181
+ code: string;
182
+ }
183
+ /** SDK error class */
184
+ export declare class ZelanaError extends Error {
185
+ code: string;
186
+ cause?: unknown | undefined;
187
+ constructor(message: string, code: string, cause?: unknown | undefined);
188
+ }
189
+ /** Dev deposit request - simulates L1 deposit without real indexer */
190
+ export interface DevDepositRequest {
191
+ /** Recipient account (hex-encoded 32-byte public key) */
192
+ to: string;
193
+ /** Amount in lamports */
194
+ amount: bigint;
195
+ }
196
+ /** Dev deposit response */
197
+ export interface DevDepositResponse {
198
+ /** Transaction hash */
199
+ txHash: string;
200
+ /** Whether the deposit was accepted */
201
+ accepted: boolean;
202
+ /** New balance after deposit */
203
+ newBalance: bigint;
204
+ /** Status message */
205
+ message: string;
206
+ }
207
+ /** Dev seal request - forces current batch to seal */
208
+ export interface DevSealRequest {
209
+ /** Whether to wait for proof generation (default: false) */
210
+ waitForProof?: boolean;
211
+ }
212
+ /** Dev seal response */
213
+ export interface DevSealResponse {
214
+ /** Sealed batch ID */
215
+ batchId: bigint;
216
+ /** Number of transactions in the sealed batch */
217
+ txCount: number;
218
+ /** Status message */
219
+ message: string;
220
+ }
221
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,8CAA8C;AAC9C,MAAM,MAAM,OAAO,GAAG,UAAU,CAAC;AAEjC,0BAA0B;AAC1B,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAMD,mCAAmC;AACnC,MAAM,MAAM,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,YAAY,CAAC;AAExE,yBAAyB;AACzB,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,GAAG,QAAQ,CAAC;AAElF,mBAAmB;AACnB,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,SAAS,GAAG,oBAAoB,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE/F,0BAA0B;AAC1B,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,QAAQ,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd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WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,sBAAsB;AACtB,qBAAa,WAAY,SAAQ,KAAK;IAG3B,IAAI,EAAE,MAAM;IACZ,KAAK,CAAC,EAAE,OAAO;gBAFtB,OAAO,EAAE,MAAM,EACR,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,OAAO,YAAA;CAKzB;AAMD,sEAAsE;AACtE,MAAM,WAAW,iBAAiB;IAChC,yDAAyD;IACzD,EAAE,EAAE,MAAM,CAAC;IACX,yBAAyB;IACzB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,2BAA2B;AAC3B,MAAM,WAAW,kBAAkB;IACjC,uBAAuB;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,QAAQ,EAAE,OAAO,CAAC;IAClB,gCAAgC;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,sDAAsD;AACtD,MAAM,WAAW,cAAc;IAC7B,4DAA4D;IAC5D,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,wBAAwB;AACxB,MAAM,WAAW,eAAe;IAC9B,sBAAsB;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Utility functions for encoding, hashing, and byte manipulation
3
+ */
4
+ /**
5
+ * Convert bytes to hex string
6
+ */
7
+ export declare function bytesToHex(bytes: Uint8Array): string;
8
+ /**
9
+ * Convert hex string to bytes
10
+ */
11
+ export declare function hexToBytes(hex: string): Uint8Array;
12
+ /**
13
+ * Encode bytes to base58 string
14
+ */
15
+ export declare function bytesToBase58(bytes: Uint8Array): string;
16
+ /**
17
+ * Decode base58 string to bytes
18
+ */
19
+ export declare function base58ToBytes(str: string): Uint8Array;
20
+ /**
21
+ * Encode u64 as little-endian bytes
22
+ */
23
+ export declare function u64ToLeBytes(value: bigint): Uint8Array;
24
+ /**
25
+ * Decode little-endian bytes to u64
26
+ */
27
+ export declare function leBytesToU64(bytes: Uint8Array): bigint;
28
+ /**
29
+ * Encode u32 as little-endian bytes
30
+ */
31
+ export declare function u32ToLeBytes(value: number): Uint8Array;
32
+ /**
33
+ * Concatenate multiple Uint8Arrays
34
+ */
35
+ export declare function concatBytes(...arrays: Uint8Array[]): Uint8Array;
36
+ /**
37
+ * Check if two byte arrays are equal
38
+ */
39
+ export declare function bytesEqual(a: Uint8Array, b: Uint8Array): boolean;
40
+ /**
41
+ * Create a zero-filled Uint8Array of specified length
42
+ */
43
+ export declare function zeroBytes(length: number): Uint8Array;
44
+ /**
45
+ * Generate random bytes
46
+ */
47
+ export declare function randomBytes(length: number): Uint8Array;
48
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAQH;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAOpD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAiBlD;AAYD;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAuCvD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAyCrD;AAMD;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAMtD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAStD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAOtD;AAMD;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,GAAG,UAAU,CAS/D;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,OAAO,CAMhE;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAEpD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAWtD"}