@degenerate/generic 0.4.0 → 0.6.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/dist/_settings/cryptography-settings.d.ts +5 -1
- package/dist/_settings/cryptography-settings.d.ts.map +1 -1
- package/dist/_settings/cryptography-settings.js +5 -1
- package/dist/crypto/index.d.ts +5 -9
- package/dist/crypto/index.d.ts.map +1 -1
- package/dist/crypto/index.js +7 -9
- package/dist/crypto/private-public-keys/create-ed25519-keys-from-mnemonic.d.ts +22 -0
- package/dist/crypto/private-public-keys/create-ed25519-keys-from-mnemonic.d.ts.map +1 -0
- package/dist/crypto/private-public-keys/create-ed25519-keys-from-mnemonic.js +65 -0
- package/dist/crypto/private-public-keys/get-ed25519-public-key-from-private-key.d.ts +11 -0
- package/dist/crypto/private-public-keys/get-ed25519-public-key-from-private-key.d.ts.map +1 -0
- package/dist/crypto/private-public-keys/get-ed25519-public-key-from-private-key.js +15 -0
- package/dist/crypto/signature/create-ed25519-signature.d.ts +16 -0
- package/dist/crypto/signature/create-ed25519-signature.d.ts.map +1 -0
- package/dist/crypto/signature/create-ed25519-signature.js +26 -0
- package/dist/crypto/signature/ed25519-primitives.d.ts +25 -0
- package/dist/crypto/signature/ed25519-primitives.d.ts.map +1 -0
- package/dist/crypto/signature/ed25519-primitives.js +65 -0
- package/dist/crypto/signature/verify-ed25519-signature.d.ts +13 -0
- package/dist/crypto/signature/verify-ed25519-signature.d.ts.map +1 -0
- package/dist/crypto/signature/verify-ed25519-signature.js +31 -0
- package/dist/errors/index.d.ts +1 -0
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +1 -0
- package/dist/errors/settlement/settlement-errors.d.ts +74 -0
- package/dist/errors/settlement/settlement-errors.d.ts.map +1 -0
- package/dist/errors/settlement/settlement-errors.js +93 -0
- package/dist/models/index.d.ts +1 -0
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +1 -0
- package/dist/models/safe/transactions/sharedata-transactions-models.d.ts +5 -0
- package/dist/models/safe/transactions/sharedata-transactions-models.d.ts.map +1 -1
- package/dist/models/settlement/settlement-models.d.ts +221 -0
- package/dist/models/settlement/settlement-models.d.ts.map +1 -0
- package/dist/models/settlement/settlement-models.js +152 -0
- package/dist/models/share-data/share-data-persistence-models.d.ts +3 -0
- package/dist/models/share-data/share-data-persistence-models.d.ts.map +1 -1
- package/dist/models/shareblock/shareblock-models.d.ts +179 -3
- package/dist/models/shareblock/shareblock-models.d.ts.map +1 -1
- package/dist/models/shareblock/shareblock-models.js +95 -3
- package/package.json +3 -4
- package/dist/crypto/private-public-keys/create-key-pair-from-mnemonic.d.ts +0 -12
- package/dist/crypto/private-public-keys/create-key-pair-from-mnemonic.d.ts.map +0 -1
- package/dist/crypto/private-public-keys/create-key-pair-from-mnemonic.js +0 -54
- package/dist/crypto/private-public-keys/create-key-pair-from-private-key.d.ts +0 -11
- package/dist/crypto/private-public-keys/create-key-pair-from-private-key.d.ts.map +0 -1
- package/dist/crypto/private-public-keys/create-key-pair-from-private-key.js +0 -50
- package/dist/crypto/private-public-keys/create-key-pair-from-public-key.d.ts +0 -11
- package/dist/crypto/private-public-keys/create-key-pair-from-public-key.d.ts.map +0 -1
- package/dist/crypto/private-public-keys/create-key-pair-from-public-key.js +0 -51
- package/dist/crypto/private-public-keys/generation/create-entropy-for-elliptical-curve.d.ts +0 -10
- package/dist/crypto/private-public-keys/generation/create-entropy-for-elliptical-curve.d.ts.map +0 -1
- package/dist/crypto/private-public-keys/generation/create-entropy-for-elliptical-curve.js +0 -51
- package/dist/crypto/private-public-keys/generation/generate-key-pair.d.ts +0 -11
- package/dist/crypto/private-public-keys/generation/generate-key-pair.d.ts.map +0 -1
- package/dist/crypto/private-public-keys/generation/generate-key-pair.js +0 -49
- package/dist/crypto/private-public-keys/generation/get-private-public-key-from-keypair.d.ts +0 -15
- package/dist/crypto/private-public-keys/generation/get-private-public-key-from-keypair.d.ts.map +0 -1
- package/dist/crypto/private-public-keys/generation/get-private-public-key-from-keypair.js +0 -21
- package/dist/crypto/signature/create-crypto-signature.d.ts +0 -20
- package/dist/crypto/signature/create-crypto-signature.d.ts.map +0 -1
- package/dist/crypto/signature/create-crypto-signature.js +0 -26
- package/dist/crypto/signature/verify-crypto-signature-by-data.d.ts +0 -17
- package/dist/crypto/signature/verify-crypto-signature-by-data.d.ts.map +0 -1
- package/dist/crypto/signature/verify-crypto-signature-by-data.js +0 -61
- package/dist/crypto/signature/verify-crypto-signature-by-hash.d.ts +0 -17
- package/dist/crypto/signature/verify-crypto-signature-by-hash.d.ts.map +0 -1
- package/dist/crypto/signature/verify-crypto-signature-by-hash.js +0 -58
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
2
|
/**
|
|
3
|
-
* The
|
|
4
|
-
*
|
|
3
|
+
* The ShareBlock specializations the platform uses to move money through a
|
|
4
|
+
* loan's lifecycle, plus the cross-block settlement coordinator.
|
|
5
5
|
*
|
|
6
6
|
* - `Clearing` — neutral holding spot funds pass through before they're
|
|
7
7
|
* committed to either side of a deal. Used to net
|
|
@@ -17,6 +17,11 @@ import z from 'zod';
|
|
|
17
17
|
* allocation when the borrower pays. Terminal state is
|
|
18
18
|
* either `fullyRepaid: true` OR `defaulted: true`,
|
|
19
19
|
* mutually exclusive.
|
|
20
|
+
* - `Settlement` — a cross-block atomic-settlement coordinator. Not a
|
|
21
|
+
* money-holding block: its state is the settlement
|
|
22
|
+
* plan + per-leg status + two-phase-commit phase, and
|
|
23
|
+
* its append-only history is the recovery journal that
|
|
24
|
+
* drives funds across the blocks above all-or-nothing.
|
|
20
25
|
*
|
|
21
26
|
* New ShareBlock variants should be additive — never re-use a value with new
|
|
22
27
|
* semantics, since downstream rule libraries pattern-match on the literal.
|
|
@@ -25,14 +30,42 @@ export declare enum ShareBlockType {
|
|
|
25
30
|
Clearing = "Clearing",
|
|
26
31
|
Funding = "Funding",
|
|
27
32
|
Distribution = "Distribution",
|
|
28
|
-
GraceRepayment = "GraceRepayment"
|
|
33
|
+
GraceRepayment = "GraceRepayment",
|
|
34
|
+
Settlement = "Settlement"
|
|
29
35
|
}
|
|
30
36
|
export declare const ShareBlockTypeSchema: z.ZodEnum<{
|
|
31
37
|
Clearing: "Clearing";
|
|
32
38
|
Funding: "Funding";
|
|
33
39
|
Distribution: "Distribution";
|
|
34
40
|
GraceRepayment: "GraceRepayment";
|
|
41
|
+
Settlement: "Settlement";
|
|
35
42
|
}>;
|
|
43
|
+
/**
|
|
44
|
+
* Direction of a settlement leg relative to one participating block:
|
|
45
|
+
*
|
|
46
|
+
* - `debit` — funds leave this block (it is the source). On reserve the
|
|
47
|
+
* amount is removed from spendable `balance` and held.
|
|
48
|
+
* - `credit` — funds arrive at this block (it is the destination). On
|
|
49
|
+
* reserve nothing moves yet; the amount lands at commit.
|
|
50
|
+
*
|
|
51
|
+
* Shared by the per-block reservation bucket and the coordinator's leg list.
|
|
52
|
+
*/
|
|
53
|
+
export declare const SettlementLegDirectionSchema: z.ZodEnum<{
|
|
54
|
+
debit: "debit";
|
|
55
|
+
credit: "credit";
|
|
56
|
+
}>;
|
|
57
|
+
export type SettlementLegDirection = z.infer<typeof SettlementLegDirectionSchema>;
|
|
58
|
+
/**
|
|
59
|
+
* Lifecycle of one block's reservation for a settlement. Advances forward
|
|
60
|
+
* only: `reserved → committed` (finalized) or `reserved → released` (unwound
|
|
61
|
+
* on abort). A standard rule enforces the monotonicity.
|
|
62
|
+
*/
|
|
63
|
+
export declare const ReservationStatusSchema: z.ZodEnum<{
|
|
64
|
+
reserved: "reserved";
|
|
65
|
+
committed: "committed";
|
|
66
|
+
released: "released";
|
|
67
|
+
}>;
|
|
68
|
+
export type ReservationStatus = z.infer<typeof ReservationStatusSchema>;
|
|
36
69
|
/**
|
|
37
70
|
* Roles a participant plays inside a ShareBlock. A single party may hold
|
|
38
71
|
* multiple roles across different ShareBlocks (e.g. the same uid is `Lender`
|
|
@@ -68,6 +101,37 @@ export declare const IShareBlockParticipantSchema: z.ZodObject<{
|
|
|
68
101
|
settledAmount: z.ZodNumber;
|
|
69
102
|
}, z.core.$strip>;
|
|
70
103
|
export type IShareBlockParticipant = z.infer<typeof IShareBlockParticipantSchema>;
|
|
104
|
+
/**
|
|
105
|
+
* One block's record of funds it is holding for an in-flight settlement,
|
|
106
|
+
* stored under `settlementId` in the block's `reservations` bucket. The
|
|
107
|
+
* per-block half of the two-phase-commit money model:
|
|
108
|
+
*
|
|
109
|
+
* - debit leg — `amountCents` is already removed from `balance` and held
|
|
110
|
+
* here until the settlement commits (finalized out) or aborts
|
|
111
|
+
* (returned to `balance`).
|
|
112
|
+
* - credit leg — pending incoming funds; `balance` is unchanged until the
|
|
113
|
+
* settlement commits, at which point `amountCents` lands.
|
|
114
|
+
*
|
|
115
|
+
* `againstHash` pins the leg to the block's current-state hash at sign time
|
|
116
|
+
* (D5 drift guard): if the block advanced since the leg was signed, the
|
|
117
|
+
* reserve proof fails at the transaction boundary and the settlement aborts.
|
|
118
|
+
*/
|
|
119
|
+
export declare const IReservedLegSchema: z.ZodObject<{
|
|
120
|
+
settlementId: z.ZodString;
|
|
121
|
+
direction: z.ZodEnum<{
|
|
122
|
+
debit: "debit";
|
|
123
|
+
credit: "credit";
|
|
124
|
+
}>;
|
|
125
|
+
amountCents: z.ZodNumber;
|
|
126
|
+
currency: z.ZodString;
|
|
127
|
+
againstHash: z.ZodString;
|
|
128
|
+
status: z.ZodEnum<{
|
|
129
|
+
reserved: "reserved";
|
|
130
|
+
committed: "committed";
|
|
131
|
+
released: "released";
|
|
132
|
+
}>;
|
|
133
|
+
}, z.core.$strip>;
|
|
134
|
+
export type IReservedLeg = z.infer<typeof IReservedLegSchema>;
|
|
71
135
|
/**
|
|
72
136
|
* The mutable state carried inside a ShareBlock's `_currentState`. This is
|
|
73
137
|
* the canonical shape rules and functions inspect when proposing changes.
|
|
@@ -80,6 +144,11 @@ export type IShareBlockParticipant = z.infer<typeof IShareBlockParticipantSchema
|
|
|
80
144
|
* - `participants` — committed parties keyed by `userId`. Adding a
|
|
81
145
|
* participant goes through a rule-gated function so the
|
|
82
146
|
* participant list itself is auditable.
|
|
147
|
+
* - `reservations` — in-flight settlement holds keyed by `settlementId`.
|
|
148
|
+
* Optional and absent by default; a block only carries this
|
|
149
|
+
* once it opts into the settlement capability and a settlement
|
|
150
|
+
* reserves against it. Funds held here are excluded from
|
|
151
|
+
* spendable `balance` (debit legs are already deducted).
|
|
83
152
|
*/
|
|
84
153
|
export declare const IShareBlockStateSchema: z.ZodObject<{
|
|
85
154
|
blockType: z.ZodEnum<{
|
|
@@ -87,6 +156,7 @@ export declare const IShareBlockStateSchema: z.ZodObject<{
|
|
|
87
156
|
Funding: "Funding";
|
|
88
157
|
Distribution: "Distribution";
|
|
89
158
|
GraceRepayment: "GraceRepayment";
|
|
159
|
+
Settlement: "Settlement";
|
|
90
160
|
}>;
|
|
91
161
|
balance: z.ZodNumber;
|
|
92
162
|
currency: z.ZodString;
|
|
@@ -102,6 +172,21 @@ export declare const IShareBlockStateSchema: z.ZodObject<{
|
|
|
102
172
|
committedAmount: z.ZodNumber;
|
|
103
173
|
settledAmount: z.ZodNumber;
|
|
104
174
|
}, z.core.$strip>>;
|
|
175
|
+
reservations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
176
|
+
settlementId: z.ZodString;
|
|
177
|
+
direction: z.ZodEnum<{
|
|
178
|
+
debit: "debit";
|
|
179
|
+
credit: "credit";
|
|
180
|
+
}>;
|
|
181
|
+
amountCents: z.ZodNumber;
|
|
182
|
+
currency: z.ZodString;
|
|
183
|
+
againstHash: z.ZodString;
|
|
184
|
+
status: z.ZodEnum<{
|
|
185
|
+
reserved: "reserved";
|
|
186
|
+
committed: "committed";
|
|
187
|
+
released: "released";
|
|
188
|
+
}>;
|
|
189
|
+
}, z.core.$strip>>>;
|
|
105
190
|
}, z.core.$strip>;
|
|
106
191
|
export type IShareBlockState = z.infer<typeof IShareBlockStateSchema>;
|
|
107
192
|
/**
|
|
@@ -130,6 +215,21 @@ export declare const IFundingShareBlockStateSchema: z.ZodObject<{
|
|
|
130
215
|
committedAmount: z.ZodNumber;
|
|
131
216
|
settledAmount: z.ZodNumber;
|
|
132
217
|
}, z.core.$strip>>;
|
|
218
|
+
reservations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
219
|
+
settlementId: z.ZodString;
|
|
220
|
+
direction: z.ZodEnum<{
|
|
221
|
+
debit: "debit";
|
|
222
|
+
credit: "credit";
|
|
223
|
+
}>;
|
|
224
|
+
amountCents: z.ZodNumber;
|
|
225
|
+
currency: z.ZodString;
|
|
226
|
+
againstHash: z.ZodString;
|
|
227
|
+
status: z.ZodEnum<{
|
|
228
|
+
reserved: "reserved";
|
|
229
|
+
committed: "committed";
|
|
230
|
+
released: "released";
|
|
231
|
+
}>;
|
|
232
|
+
}, z.core.$strip>>>;
|
|
133
233
|
blockType: z.ZodLiteral<"Funding">;
|
|
134
234
|
committed: z.ZodBoolean;
|
|
135
235
|
committedBy: z.ZodOptional<z.ZodString>;
|
|
@@ -163,6 +263,21 @@ export declare const IDistributionShareBlockStateSchema: z.ZodObject<{
|
|
|
163
263
|
committedAmount: z.ZodNumber;
|
|
164
264
|
settledAmount: z.ZodNumber;
|
|
165
265
|
}, z.core.$strip>>;
|
|
266
|
+
reservations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
267
|
+
settlementId: z.ZodString;
|
|
268
|
+
direction: z.ZodEnum<{
|
|
269
|
+
debit: "debit";
|
|
270
|
+
credit: "credit";
|
|
271
|
+
}>;
|
|
272
|
+
amountCents: z.ZodNumber;
|
|
273
|
+
currency: z.ZodString;
|
|
274
|
+
againstHash: z.ZodString;
|
|
275
|
+
status: z.ZodEnum<{
|
|
276
|
+
reserved: "reserved";
|
|
277
|
+
committed: "committed";
|
|
278
|
+
released: "released";
|
|
279
|
+
}>;
|
|
280
|
+
}, z.core.$strip>>>;
|
|
166
281
|
blockType: z.ZodLiteral<"Distribution">;
|
|
167
282
|
distributed: z.ZodBoolean;
|
|
168
283
|
distributedBy: z.ZodOptional<z.ZodString>;
|
|
@@ -251,6 +366,21 @@ export declare const IGraceRepaymentShareBlockStateSchema: z.ZodObject<{
|
|
|
251
366
|
balance: z.ZodNumber;
|
|
252
367
|
currency: z.ZodString;
|
|
253
368
|
isOpen: z.ZodBoolean;
|
|
369
|
+
reservations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
370
|
+
settlementId: z.ZodString;
|
|
371
|
+
direction: z.ZodEnum<{
|
|
372
|
+
debit: "debit";
|
|
373
|
+
credit: "credit";
|
|
374
|
+
}>;
|
|
375
|
+
amountCents: z.ZodNumber;
|
|
376
|
+
currency: z.ZodString;
|
|
377
|
+
againstHash: z.ZodString;
|
|
378
|
+
status: z.ZodEnum<{
|
|
379
|
+
reserved: "reserved";
|
|
380
|
+
committed: "committed";
|
|
381
|
+
released: "released";
|
|
382
|
+
}>;
|
|
383
|
+
}, z.core.$strip>>>;
|
|
254
384
|
blockType: z.ZodLiteral<"GraceRepayment">;
|
|
255
385
|
participants: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
256
386
|
userId: z.ZodString;
|
|
@@ -301,6 +431,7 @@ export declare const IShareBlockMetadataSchema: z.ZodObject<{
|
|
|
301
431
|
Funding: "Funding";
|
|
302
432
|
Distribution: "Distribution";
|
|
303
433
|
GraceRepayment: "GraceRepayment";
|
|
434
|
+
Settlement: "Settlement";
|
|
304
435
|
}>;
|
|
305
436
|
relatedLoanApplicationId: z.ZodOptional<z.ZodString>;
|
|
306
437
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -486,4 +617,49 @@ export declare const IShareBlockMarkDefaultedInputSchema: z.ZodObject<{
|
|
|
486
617
|
asOf: z.ZodNumber;
|
|
487
618
|
}, z.core.$strip>;
|
|
488
619
|
export type IShareBlockMarkDefaultedInput = z.infer<typeof IShareBlockMarkDefaultedInputSchema>;
|
|
620
|
+
/**
|
|
621
|
+
* Input for the generic `reserveForSettlement` function (any block that opted
|
|
622
|
+
* into the settlement capability). Phase-1 (PREPARE) of the two-phase commit:
|
|
623
|
+
* holds `amountCents` for `settlementId`. `direction` selects debit (deduct
|
|
624
|
+
* from `balance`) vs credit (pending incoming, no balance change).
|
|
625
|
+
* `expectedHash` is the block's current-state hash the leg was signed against
|
|
626
|
+
* — the function rejects if it does not match, backing up the proof-chain
|
|
627
|
+
* drift guard (D5). Idempotent: a second reserve for the same `settlementId`
|
|
628
|
+
* is a no-op.
|
|
629
|
+
*/
|
|
630
|
+
export declare const IShareBlockReserveForSettlementInputSchema: z.ZodObject<{
|
|
631
|
+
userId: z.ZodString;
|
|
632
|
+
settlementId: z.ZodString;
|
|
633
|
+
direction: z.ZodEnum<{
|
|
634
|
+
debit: "debit";
|
|
635
|
+
credit: "credit";
|
|
636
|
+
}>;
|
|
637
|
+
amountCents: z.ZodNumber;
|
|
638
|
+
currency: z.ZodString;
|
|
639
|
+
expectedHash: z.ZodString;
|
|
640
|
+
}, z.core.$strip>;
|
|
641
|
+
export type IShareBlockReserveForSettlementInput = z.infer<typeof IShareBlockReserveForSettlementInputSchema>;
|
|
642
|
+
/**
|
|
643
|
+
* Input for the generic `commitSettlement` function. Phase-2 finalize for one
|
|
644
|
+
* leg: credit legs add the held amount to `balance`; both directions then
|
|
645
|
+
* clear the reservation. Carries only the settlement id — amount and
|
|
646
|
+
* direction are read from the stored reservation. Idempotent: a second call
|
|
647
|
+
* once the reservation is gone is a no-op.
|
|
648
|
+
*/
|
|
649
|
+
export declare const IShareBlockCommitSettlementInputSchema: z.ZodObject<{
|
|
650
|
+
userId: z.ZodString;
|
|
651
|
+
settlementId: z.ZodString;
|
|
652
|
+
}, z.core.$strip>;
|
|
653
|
+
export type IShareBlockCommitSettlementInput = z.infer<typeof IShareBlockCommitSettlementInputSchema>;
|
|
654
|
+
/**
|
|
655
|
+
* Input for the generic `releaseSettlement` function. Abort-path unwind for
|
|
656
|
+
* one leg: debit legs return the held amount to `balance`; both directions
|
|
657
|
+
* delete the reservation. Idempotent: releasing an absent reservation is a
|
|
658
|
+
* no-op.
|
|
659
|
+
*/
|
|
660
|
+
export declare const IShareBlockReleaseSettlementInputSchema: z.ZodObject<{
|
|
661
|
+
userId: z.ZodString;
|
|
662
|
+
settlementId: z.ZodString;
|
|
663
|
+
}, z.core.$strip>;
|
|
664
|
+
export type IShareBlockReleaseSettlementInput = z.infer<typeof IShareBlockReleaseSettlementInputSchema>;
|
|
489
665
|
//# sourceMappingURL=shareblock-models.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shareblock-models.d.ts","sourceRoot":"","sources":["../../../src/models/shareblock/shareblock-models.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAIpB
|
|
1
|
+
{"version":3,"file":"shareblock-models.d.ts","sourceRoot":"","sources":["../../../src/models/shareblock/shareblock-models.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAIpB;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,oBAAY,cAAc;IACtB,QAAQ,aAAa;IACrB,OAAO,YAAY;IACnB,YAAY,iBAAiB;IAC7B,cAAc,mBAAmB;IACjC,UAAU,eAAe;CAC5B;AAED,eAAO,MAAM,oBAAoB;;;;;;EAM/B,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,4BAA4B;;;EAA8B,CAAC;AACxE,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAElF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB;;;;EAAgD,CAAC;AACrF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAMxE;;;;GAIG;AACH,oBAAY,yBAAyB;IACjC,QAAQ,aAAa;IACrB,MAAM,WAAW;IACjB,QAAQ,aAAa;IACr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;;;;;GAMG;AACH,eAAO,MAAM,sCAAsC;;;iBAGjD,CAAC;AACH,MAAM,MAAM,gCAAgC,GACxC,CAAC,CAAC,KAAK,CAAC,OAAO,sCAAsC,CAAC,CAAC;AAE3D;;;;;GAKG;AACH,eAAO,MAAM,uCAAuC;;;iBAGlD,CAAC;AACH,MAAM,MAAM,iCAAiC,GACzC,CAAC,CAAC,KAAK,CAAC,OAAO,uCAAuC,CAAC,CAAC"}
|
|
@@ -3,12 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.IShareBlockMarkDefaultedInputSchema = exports.IShareBlockMarkFullyRepaidInputSchema = exports.IShareBlockRecordRepaymentInputSchema = exports.IShareBlockSnapshotForRepaymentInputSchema = exports.IShareBlockSetLenderGraceDecisionInputSchema = exports.IShareBlockMarkFullyDistributedInputSchema = exports.IShareBlockDisburseInputSchema = exports.IShareBlockFundInputSchema = exports.IShareBlockRegisterLenderInputSchema = exports.IShareBlockCommitInputSchema = exports.IShareBlockCloseInputSchema = exports.IShareBlockWithdrawInputSchema = exports.IShareBlockDepositInputSchema = exports.IShareBlockInitialStateInputSchema = exports.IShareBlockMetadataSchema = exports.IGraceRepaymentShareBlockStateSchema = exports.IGraceRepaymentParticipantSchema = exports.IDistributionShareBlockStateSchema = exports.IFundingShareBlockStateSchema = exports.IShareBlockStateSchema = exports.IShareBlockParticipantSchema = exports.ShareBlockParticipantRoleSchema = exports.ShareBlockParticipantRole = exports.ShareBlockTypeSchema = exports.ShareBlockType = void 0;
|
|
6
|
+
exports.IShareBlockReleaseSettlementInputSchema = exports.IShareBlockCommitSettlementInputSchema = exports.IShareBlockReserveForSettlementInputSchema = exports.IShareBlockMarkDefaultedInputSchema = exports.IShareBlockMarkFullyRepaidInputSchema = exports.IShareBlockRecordRepaymentInputSchema = exports.IShareBlockSnapshotForRepaymentInputSchema = exports.IShareBlockSetLenderGraceDecisionInputSchema = exports.IShareBlockMarkFullyDistributedInputSchema = exports.IShareBlockDisburseInputSchema = exports.IShareBlockFundInputSchema = exports.IShareBlockRegisterLenderInputSchema = exports.IShareBlockCommitInputSchema = exports.IShareBlockCloseInputSchema = exports.IShareBlockWithdrawInputSchema = exports.IShareBlockDepositInputSchema = exports.IShareBlockInitialStateInputSchema = exports.IShareBlockMetadataSchema = exports.IGraceRepaymentShareBlockStateSchema = exports.IGraceRepaymentParticipantSchema = exports.IDistributionShareBlockStateSchema = exports.IFundingShareBlockStateSchema = exports.IShareBlockStateSchema = exports.IReservedLegSchema = exports.IShareBlockParticipantSchema = exports.ShareBlockParticipantRoleSchema = exports.ShareBlockParticipantRole = exports.ReservationStatusSchema = exports.SettlementLegDirectionSchema = exports.ShareBlockTypeSchema = exports.ShareBlockType = void 0;
|
|
7
7
|
const zod_1 = __importDefault(require("zod"));
|
|
8
8
|
//#region Enums
|
|
9
9
|
/**
|
|
10
|
-
* The
|
|
11
|
-
*
|
|
10
|
+
* The ShareBlock specializations the platform uses to move money through a
|
|
11
|
+
* loan's lifecycle, plus the cross-block settlement coordinator.
|
|
12
12
|
*
|
|
13
13
|
* - `Clearing` — neutral holding spot funds pass through before they're
|
|
14
14
|
* committed to either side of a deal. Used to net
|
|
@@ -24,6 +24,11 @@ const zod_1 = __importDefault(require("zod"));
|
|
|
24
24
|
* allocation when the borrower pays. Terminal state is
|
|
25
25
|
* either `fullyRepaid: true` OR `defaulted: true`,
|
|
26
26
|
* mutually exclusive.
|
|
27
|
+
* - `Settlement` — a cross-block atomic-settlement coordinator. Not a
|
|
28
|
+
* money-holding block: its state is the settlement
|
|
29
|
+
* plan + per-leg status + two-phase-commit phase, and
|
|
30
|
+
* its append-only history is the recovery journal that
|
|
31
|
+
* drives funds across the blocks above all-or-nothing.
|
|
27
32
|
*
|
|
28
33
|
* New ShareBlock variants should be additive — never re-use a value with new
|
|
29
34
|
* semantics, since downstream rule libraries pattern-match on the literal.
|
|
@@ -34,13 +39,32 @@ var ShareBlockType;
|
|
|
34
39
|
ShareBlockType["Funding"] = "Funding";
|
|
35
40
|
ShareBlockType["Distribution"] = "Distribution";
|
|
36
41
|
ShareBlockType["GraceRepayment"] = "GraceRepayment";
|
|
42
|
+
ShareBlockType["Settlement"] = "Settlement";
|
|
37
43
|
})(ShareBlockType || (exports.ShareBlockType = ShareBlockType = {}));
|
|
38
44
|
exports.ShareBlockTypeSchema = zod_1.default.enum([
|
|
39
45
|
'Clearing',
|
|
40
46
|
'Funding',
|
|
41
47
|
'Distribution',
|
|
42
48
|
'GraceRepayment',
|
|
49
|
+
'Settlement',
|
|
43
50
|
]);
|
|
51
|
+
/**
|
|
52
|
+
* Direction of a settlement leg relative to one participating block:
|
|
53
|
+
*
|
|
54
|
+
* - `debit` — funds leave this block (it is the source). On reserve the
|
|
55
|
+
* amount is removed from spendable `balance` and held.
|
|
56
|
+
* - `credit` — funds arrive at this block (it is the destination). On
|
|
57
|
+
* reserve nothing moves yet; the amount lands at commit.
|
|
58
|
+
*
|
|
59
|
+
* Shared by the per-block reservation bucket and the coordinator's leg list.
|
|
60
|
+
*/
|
|
61
|
+
exports.SettlementLegDirectionSchema = zod_1.default.enum(['debit', 'credit']);
|
|
62
|
+
/**
|
|
63
|
+
* Lifecycle of one block's reservation for a settlement. Advances forward
|
|
64
|
+
* only: `reserved → committed` (finalized) or `reserved → released` (unwound
|
|
65
|
+
* on abort). A standard rule enforces the monotonicity.
|
|
66
|
+
*/
|
|
67
|
+
exports.ReservationStatusSchema = zod_1.default.enum(['reserved', 'committed', 'released']);
|
|
44
68
|
//#endregion Enums
|
|
45
69
|
//#region Participant
|
|
46
70
|
/**
|
|
@@ -75,6 +99,29 @@ exports.IShareBlockParticipantSchema = zod_1.default.object({
|
|
|
75
99
|
});
|
|
76
100
|
//#endregion Participant
|
|
77
101
|
//#region State
|
|
102
|
+
/**
|
|
103
|
+
* One block's record of funds it is holding for an in-flight settlement,
|
|
104
|
+
* stored under `settlementId` in the block's `reservations` bucket. The
|
|
105
|
+
* per-block half of the two-phase-commit money model:
|
|
106
|
+
*
|
|
107
|
+
* - debit leg — `amountCents` is already removed from `balance` and held
|
|
108
|
+
* here until the settlement commits (finalized out) or aborts
|
|
109
|
+
* (returned to `balance`).
|
|
110
|
+
* - credit leg — pending incoming funds; `balance` is unchanged until the
|
|
111
|
+
* settlement commits, at which point `amountCents` lands.
|
|
112
|
+
*
|
|
113
|
+
* `againstHash` pins the leg to the block's current-state hash at sign time
|
|
114
|
+
* (D5 drift guard): if the block advanced since the leg was signed, the
|
|
115
|
+
* reserve proof fails at the transaction boundary and the settlement aborts.
|
|
116
|
+
*/
|
|
117
|
+
exports.IReservedLegSchema = zod_1.default.object({
|
|
118
|
+
settlementId: zod_1.default.string(),
|
|
119
|
+
direction: exports.SettlementLegDirectionSchema,
|
|
120
|
+
amountCents: zod_1.default.number().int().positive(),
|
|
121
|
+
currency: zod_1.default.string(),
|
|
122
|
+
againstHash: zod_1.default.string(),
|
|
123
|
+
status: exports.ReservationStatusSchema,
|
|
124
|
+
});
|
|
78
125
|
/**
|
|
79
126
|
* The mutable state carried inside a ShareBlock's `_currentState`. This is
|
|
80
127
|
* the canonical shape rules and functions inspect when proposing changes.
|
|
@@ -87,6 +134,11 @@ exports.IShareBlockParticipantSchema = zod_1.default.object({
|
|
|
87
134
|
* - `participants` — committed parties keyed by `userId`. Adding a
|
|
88
135
|
* participant goes through a rule-gated function so the
|
|
89
136
|
* participant list itself is auditable.
|
|
137
|
+
* - `reservations` — in-flight settlement holds keyed by `settlementId`.
|
|
138
|
+
* Optional and absent by default; a block only carries this
|
|
139
|
+
* once it opts into the settlement capability and a settlement
|
|
140
|
+
* reserves against it. Funds held here are excluded from
|
|
141
|
+
* spendable `balance` (debit legs are already deducted).
|
|
90
142
|
*/
|
|
91
143
|
exports.IShareBlockStateSchema = zod_1.default.object({
|
|
92
144
|
blockType: exports.ShareBlockTypeSchema,
|
|
@@ -94,6 +146,7 @@ exports.IShareBlockStateSchema = zod_1.default.object({
|
|
|
94
146
|
currency: zod_1.default.string().min(3).max(3),
|
|
95
147
|
isOpen: zod_1.default.boolean(),
|
|
96
148
|
participants: zod_1.default.record(zod_1.default.string(), exports.IShareBlockParticipantSchema),
|
|
149
|
+
reservations: zod_1.default.record(zod_1.default.string(), exports.IReservedLegSchema).optional(),
|
|
97
150
|
});
|
|
98
151
|
/**
|
|
99
152
|
* Funding-specific extension of `IShareBlockState`. Adds:
|
|
@@ -392,4 +445,43 @@ exports.IShareBlockMarkDefaultedInputSchema = zod_1.default.object({
|
|
|
392
445
|
reason: zod_1.default.string().min(1),
|
|
393
446
|
asOf: zod_1.default.number().int().nonnegative(),
|
|
394
447
|
});
|
|
448
|
+
/**
|
|
449
|
+
* Input for the generic `reserveForSettlement` function (any block that opted
|
|
450
|
+
* into the settlement capability). Phase-1 (PREPARE) of the two-phase commit:
|
|
451
|
+
* holds `amountCents` for `settlementId`. `direction` selects debit (deduct
|
|
452
|
+
* from `balance`) vs credit (pending incoming, no balance change).
|
|
453
|
+
* `expectedHash` is the block's current-state hash the leg was signed against
|
|
454
|
+
* — the function rejects if it does not match, backing up the proof-chain
|
|
455
|
+
* drift guard (D5). Idempotent: a second reserve for the same `settlementId`
|
|
456
|
+
* is a no-op.
|
|
457
|
+
*/
|
|
458
|
+
exports.IShareBlockReserveForSettlementInputSchema = zod_1.default.object({
|
|
459
|
+
userId: zod_1.default.string(),
|
|
460
|
+
settlementId: zod_1.default.string(),
|
|
461
|
+
direction: exports.SettlementLegDirectionSchema,
|
|
462
|
+
amountCents: zod_1.default.number().int().positive(),
|
|
463
|
+
currency: zod_1.default.string(),
|
|
464
|
+
expectedHash: zod_1.default.string(),
|
|
465
|
+
});
|
|
466
|
+
/**
|
|
467
|
+
* Input for the generic `commitSettlement` function. Phase-2 finalize for one
|
|
468
|
+
* leg: credit legs add the held amount to `balance`; both directions then
|
|
469
|
+
* clear the reservation. Carries only the settlement id — amount and
|
|
470
|
+
* direction are read from the stored reservation. Idempotent: a second call
|
|
471
|
+
* once the reservation is gone is a no-op.
|
|
472
|
+
*/
|
|
473
|
+
exports.IShareBlockCommitSettlementInputSchema = zod_1.default.object({
|
|
474
|
+
userId: zod_1.default.string(),
|
|
475
|
+
settlementId: zod_1.default.string(),
|
|
476
|
+
});
|
|
477
|
+
/**
|
|
478
|
+
* Input for the generic `releaseSettlement` function. Abort-path unwind for
|
|
479
|
+
* one leg: debit legs return the held amount to `balance`; both directions
|
|
480
|
+
* delete the reservation. Idempotent: releasing an absent reservation is a
|
|
481
|
+
* no-op.
|
|
482
|
+
*/
|
|
483
|
+
exports.IShareBlockReleaseSettlementInputSchema = zod_1.default.object({
|
|
484
|
+
userId: zod_1.default.string(),
|
|
485
|
+
settlementId: zod_1.default.string(),
|
|
486
|
+
});
|
|
395
487
|
//#endregion Transaction Function Inputs
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@degenerate/generic",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "This contains the generic information needed for the ShareData Adaptive Framework Ecosystem (SAFE) network",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -38,14 +38,13 @@
|
|
|
38
38
|
},
|
|
39
39
|
"homepage": "https://github.com/syncrude/safe#readme",
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@
|
|
41
|
+
"@noble/ed25519": "3.1.0",
|
|
42
42
|
"bip39": "^3.1.0",
|
|
43
|
-
"elliptic": "^6.6.1",
|
|
44
43
|
"firebase-admin": "^13.9.0",
|
|
45
44
|
"jsonwebtoken": "^9.0.3",
|
|
46
45
|
"zod": "^4.4.3"
|
|
47
46
|
},
|
|
48
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "c8c1a2f456cdb01a74f85779275b246361e33b81",
|
|
49
48
|
"devDependencies": {
|
|
50
49
|
"@eslint/js": "^10.0.1",
|
|
51
50
|
"@types/eslint__js": "^8.42.3",
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as Elliptic from 'elliptic';
|
|
2
|
-
import { EllipticalCurvesSigning, EllipticalCurvesEncryption } from '../../_settings/cryptography-settings';
|
|
3
|
-
/**
|
|
4
|
-
* This function creates a key pair from a mnemonic using the elliptic library.
|
|
5
|
-
*
|
|
6
|
-
* @param curve the elliptical curve to create the key pair for.
|
|
7
|
-
* @param mnemonic the mnemonic to create the key pair from.
|
|
8
|
-
* @returns
|
|
9
|
-
*/
|
|
10
|
-
declare const createKeyPairFromMnemonic: (curve: EllipticalCurvesSigning | EllipticalCurvesEncryption, mnemonic: string) => Elliptic.ec.KeyPair;
|
|
11
|
-
export { createKeyPairFromMnemonic };
|
|
12
|
-
//# sourceMappingURL=create-key-pair-from-mnemonic.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-key-pair-from-mnemonic.d.ts","sourceRoot":"","sources":["../../../src/crypto/private-public-keys/create-key-pair-from-mnemonic.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AAErC,OAAO,EAAE,uBAAuB,EAAE,0BAA0B,EAAkB,MAAM,uCAAuC,CAAC;AAE5H;;;;;;GAMG;AACH,QAAA,MAAM,yBAAyB,GAAI,OAAO,uBAAuB,GAAG,0BAA0B,EAAE,UAAU,MAAM,KAAG,QAAQ,CAAC,EAAE,CAAC,OAO9H,CAAC;AAEF,OAAO,EAAE,yBAAyB,EAAE,CAAC"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.createKeyPairFromMnemonic = void 0;
|
|
37
|
-
/* eslint-disable new-cap */
|
|
38
|
-
const Elliptic = __importStar(require("elliptic"));
|
|
39
|
-
const crypto = __importStar(require("crypto"));
|
|
40
|
-
const cryptography_settings_1 = require("../../_settings/cryptography-settings");
|
|
41
|
-
/**
|
|
42
|
-
* This function creates a key pair from a mnemonic using the elliptic library.
|
|
43
|
-
*
|
|
44
|
-
* @param curve the elliptical curve to create the key pair for.
|
|
45
|
-
* @param mnemonic the mnemonic to create the key pair from.
|
|
46
|
-
* @returns
|
|
47
|
-
*/
|
|
48
|
-
const createKeyPairFromMnemonic = (curve, mnemonic) => {
|
|
49
|
-
const ellipticalCurve = new Elliptic.ec(curve);
|
|
50
|
-
const hash = crypto.createHash(cryptography_settings_1.CryptoSettings.Hash.Algorithm).update(mnemonic, cryptography_settings_1.CryptoSettings.TextEncoding).digest(cryptography_settings_1.CryptoSettings.Hash.Digest);
|
|
51
|
-
const keyPair = ellipticalCurve.keyFromPrivate(hash);
|
|
52
|
-
return keyPair;
|
|
53
|
-
};
|
|
54
|
-
exports.createKeyPairFromMnemonic = createKeyPairFromMnemonic;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as Elliptic from 'elliptic';
|
|
2
|
-
import { EllipticalCurvesSigning, EllipticalCurvesEncryption } from '../../_settings/cryptography-settings';
|
|
3
|
-
/**
|
|
4
|
-
* This function creates a key pair from a private key using the elliptic library.
|
|
5
|
-
* @param curve the elliptical curve to create the key pair for.
|
|
6
|
-
* @param privateKey the private key in hexadecimal format.
|
|
7
|
-
* @returns
|
|
8
|
-
*/
|
|
9
|
-
declare const createKeyPairFromPrivateKey: (curve: EllipticalCurvesSigning | EllipticalCurvesEncryption, privateKey: string) => Elliptic.ec.KeyPair;
|
|
10
|
-
export { createKeyPairFromPrivateKey };
|
|
11
|
-
//# sourceMappingURL=create-key-pair-from-private-key.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-key-pair-from-private-key.d.ts","sourceRoot":"","sources":["../../../src/crypto/private-public-keys/create-key-pair-from-private-key.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AAE5G;;;;;GAKG;AACH,QAAA,MAAM,2BAA2B,GAAI,OAAO,uBAAuB,GAAG,0BAA0B,EAC5F,YAAY,MAAM,KAAG,QAAQ,CAAC,EAAE,CAAC,OAKpC,CAAC;AAEF,OAAO,EAAE,2BAA2B,EAAE,CAAC"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.createKeyPairFromPrivateKey = void 0;
|
|
37
|
-
/* eslint-disable new-cap */
|
|
38
|
-
const Elliptic = __importStar(require("elliptic"));
|
|
39
|
-
/**
|
|
40
|
-
* This function creates a key pair from a private key using the elliptic library.
|
|
41
|
-
* @param curve the elliptical curve to create the key pair for.
|
|
42
|
-
* @param privateKey the private key in hexadecimal format.
|
|
43
|
-
* @returns
|
|
44
|
-
*/
|
|
45
|
-
const createKeyPairFromPrivateKey = (curve, privateKey) => {
|
|
46
|
-
const ellipticalCurve = new Elliptic.ec(curve);
|
|
47
|
-
const keyPair = ellipticalCurve.keyFromPrivate(privateKey, 'hex');
|
|
48
|
-
return keyPair;
|
|
49
|
-
};
|
|
50
|
-
exports.createKeyPairFromPrivateKey = createKeyPairFromPrivateKey;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as Elliptic from 'elliptic';
|
|
2
|
-
import { EllipticalCurvesEncryption, EllipticalCurvesSigning } from '../../_settings/cryptography-settings';
|
|
3
|
-
/**
|
|
4
|
-
* This function creates a key pair from a public key using the elliptic library.
|
|
5
|
-
*
|
|
6
|
-
* @param curve the elliptical curve to create the key pair for.
|
|
7
|
-
* @param publicKey the public key in hexadecimal format.
|
|
8
|
-
* @returns
|
|
9
|
-
*/
|
|
10
|
-
export declare const createKeyPairFromPublicKey: (curve: EllipticalCurvesSigning | EllipticalCurvesEncryption, publicKey: string, encoding?: BufferEncoding) => Elliptic.ec.KeyPair;
|
|
11
|
-
//# sourceMappingURL=create-key-pair-from-public-key.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-key-pair-from-public-key.d.ts","sourceRoot":"","sources":["../../../src/crypto/private-public-keys/create-key-pair-from-public-key.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAE5G;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,GACnC,OAAO,uBAAuB,GAAG,0BAA0B,EAC3D,WAAW,MAAM,EACjB,WAAU,cAAsB,KACjC,QAAQ,CAAC,EAAE,CAAC,OAKd,CAAC"}
|