@sip-protocol/sdk 0.5.1 → 0.6.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/README.md +58 -0
- package/dist/TransportWebUSB-TQ7WZ4LE.mjs +3098 -0
- package/dist/browser.d.mts +4 -4
- package/dist/browser.d.ts +4 -4
- package/dist/browser.js +10133 -4664
- package/dist/browser.mjs +32 -1
- package/dist/chunk-7QZPORY5.mjs +15604 -0
- package/dist/chunk-C2NPCUAJ.mjs +17010 -0
- package/dist/chunk-FCVLFUIC.mjs +16699 -0
- package/dist/chunk-G5UHXECN.mjs +16340 -0
- package/dist/chunk-GEDEIZHJ.mjs +16798 -0
- package/dist/chunk-KBS3OMSZ.mjs +14737 -0
- package/dist/chunk-MTNYSNR7.mjs +16269 -0
- package/dist/chunk-O5PIB2EA.mjs +16698 -0
- package/dist/chunk-PCFM7FQO.mjs +17010 -0
- package/dist/chunk-QK464ARC.mjs +16946 -0
- package/dist/chunk-TK3FWQNC.mjs +14737 -0
- package/dist/chunk-UJCSKKID.mjs +30 -0
- package/dist/chunk-VNBMNGC3.mjs +16698 -0
- package/dist/chunk-W5TUELDQ.mjs +16947 -0
- package/dist/index-05W_S8A7.d.mts +9237 -0
- package/dist/index-C5ehlFhR.d.mts +9443 -0
- package/dist/index-CD_zShu-.d.ts +10870 -0
- package/dist/index-CNzhx-WH.d.mts +9316 -0
- package/dist/index-CQBYdLYy.d.mts +10976 -0
- package/dist/index-Cg9TYEPv.d.mts +11321 -0
- package/dist/index-CqSppS4i.d.ts +9237 -0
- package/dist/index-CqZJOO8C.d.mts +11323 -0
- package/dist/index-CywN9Bnp.d.ts +11321 -0
- package/dist/index-DBa_jiZF.d.mts +9606 -0
- package/dist/index-DHy5ZjCD.d.ts +10976 -0
- package/dist/index-DLNdSQFQ.d.ts +9316 -0
- package/dist/index-DfsVsmxu.d.ts +11323 -0
- package/dist/index-Ink8HnKW.d.ts +9606 -0
- package/dist/index-ObjwyVDX.d.mts +10870 -0
- package/dist/index-h7B23m5b.d.ts +9443 -0
- package/dist/index-m0xbSfmT.d.mts +11318 -0
- package/dist/index-rWLEgvhN.d.ts +11318 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +10112 -4637
- package/dist/index.mjs +32 -1
- package/dist/noir-DKfEzWy9.d.mts +482 -0
- package/dist/noir-DKfEzWy9.d.ts +482 -0
- package/dist/proofs/noir.d.mts +1 -1
- package/dist/proofs/noir.d.ts +1 -1
- package/dist/proofs/noir.js +12 -3
- package/dist/proofs/noir.mjs +13 -3
- package/package.json +5 -3
- package/src/adapters/near-intents.ts +13 -3
- package/src/auction/index.ts +20 -0
- package/src/auction/sealed-bid.ts +1037 -0
- package/src/compliance/derivation.ts +13 -3
- package/src/compliance/reports.ts +5 -4
- package/src/cosmos/ibc-stealth.ts +2 -2
- package/src/cosmos/stealth.ts +2 -2
- package/src/crypto.ts +79 -9
- package/src/governance/index.ts +19 -0
- package/src/governance/private-vote.ts +1116 -0
- package/src/index.ts +50 -2
- package/src/intent.ts +227 -12
- package/src/nft/index.ts +27 -0
- package/src/nft/private-nft.ts +811 -0
- package/src/privacy.ts +88 -2
- package/src/proofs/browser-utils.ts +1 -7
- package/src/proofs/noir.ts +34 -7
- package/src/settlement/backends/direct-chain.ts +14 -3
- package/src/sip.ts +324 -25
- package/src/stealth.ts +120 -9
- package/src/types/browser.d.ts +67 -0
- package/src/validation.ts +4 -2
- package/src/wallet/bitcoin/adapter.ts +159 -15
- package/src/wallet/bitcoin/types.ts +340 -15
- package/src/wallet/cosmos/mock.ts +16 -12
- package/src/wallet/hardware/ledger.ts +83 -14
- package/src/wallet/hardware/types.ts +2 -0
package/src/index.ts
CHANGED
|
@@ -93,8 +93,9 @@ export {
|
|
|
93
93
|
|
|
94
94
|
export type { StealthCurve } from './stealth'
|
|
95
95
|
|
|
96
|
-
// Move blockchain stealth addresses (Aptos)
|
|
96
|
+
// Move blockchain stealth addresses (Aptos, Sui)
|
|
97
97
|
export {
|
|
98
|
+
// Aptos
|
|
98
99
|
AptosStealthService,
|
|
99
100
|
generateAptosStealthAddress,
|
|
100
101
|
deriveAptosStealthPrivateKey,
|
|
@@ -102,9 +103,17 @@ export {
|
|
|
102
103
|
ed25519PublicKeyToAptosAddress,
|
|
103
104
|
aptosAddressToAuthKey,
|
|
104
105
|
isValidAptosAddress,
|
|
106
|
+
// Sui
|
|
107
|
+
SuiStealthService,
|
|
108
|
+
generateSuiStealthAddress,
|
|
109
|
+
deriveSuiStealthPrivateKey,
|
|
110
|
+
checkSuiStealthAddress,
|
|
111
|
+
ed25519PublicKeyToSuiAddress,
|
|
112
|
+
normalizeSuiAddress,
|
|
113
|
+
isValidSuiAddress,
|
|
105
114
|
} from './move'
|
|
106
115
|
|
|
107
|
-
export type { AptosStealthResult } from './move'
|
|
116
|
+
export type { AptosStealthResult, SuiStealthResult } from './move'
|
|
108
117
|
|
|
109
118
|
// Cosmos blockchain stealth addresses
|
|
110
119
|
export {
|
|
@@ -297,6 +306,12 @@ export type {
|
|
|
297
306
|
CreatePaymentParams,
|
|
298
307
|
PaymentReceipt,
|
|
299
308
|
TrackedPayment,
|
|
309
|
+
// NFT types
|
|
310
|
+
PrivateNFTOwnership,
|
|
311
|
+
OwnershipProof,
|
|
312
|
+
CreatePrivateOwnershipParams,
|
|
313
|
+
ProveOwnershipParams,
|
|
314
|
+
OwnershipVerification,
|
|
300
315
|
} from '@sip-protocol/types'
|
|
301
316
|
|
|
302
317
|
// Payment status enum
|
|
@@ -566,6 +581,39 @@ export {
|
|
|
566
581
|
type TimeLockParams,
|
|
567
582
|
} from './compliance'
|
|
568
583
|
|
|
584
|
+
// Sealed-Bid Auctions
|
|
585
|
+
export {
|
|
586
|
+
SealedBidAuction,
|
|
587
|
+
createSealedBidAuction,
|
|
588
|
+
} from './auction'
|
|
589
|
+
|
|
590
|
+
export type {
|
|
591
|
+
SealedBid,
|
|
592
|
+
BidReceipt,
|
|
593
|
+
CreateBidParams,
|
|
594
|
+
VerifyBidParams,
|
|
595
|
+
} from './auction'
|
|
596
|
+
|
|
597
|
+
// Governance (Private Voting)
|
|
598
|
+
export {
|
|
599
|
+
PrivateVoting,
|
|
600
|
+
createPrivateVoting,
|
|
601
|
+
} from './governance'
|
|
602
|
+
|
|
603
|
+
export type {
|
|
604
|
+
EncryptedVote,
|
|
605
|
+
RevealedVote,
|
|
606
|
+
CastVoteParams,
|
|
607
|
+
} from './governance'
|
|
608
|
+
|
|
609
|
+
// NFT Module
|
|
610
|
+
export {
|
|
611
|
+
PrivateNFT,
|
|
612
|
+
createPrivateOwnership,
|
|
613
|
+
proveOwnership,
|
|
614
|
+
verifyOwnership,
|
|
615
|
+
} from './nft'
|
|
616
|
+
|
|
569
617
|
// Wallet Adapters
|
|
570
618
|
export {
|
|
571
619
|
BaseWalletAdapter,
|
package/src/intent.ts
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
type HexString,
|
|
19
19
|
type Hash,
|
|
20
20
|
type PrivacyLevel,
|
|
21
|
+
type ChainId,
|
|
21
22
|
} from '@sip-protocol/types'
|
|
22
23
|
import { generateStealthAddress, decodeStealthMetaAddress } from './stealth'
|
|
23
24
|
import {
|
|
@@ -41,24 +42,148 @@ import {
|
|
|
41
42
|
|
|
42
43
|
/**
|
|
43
44
|
* Options for creating a shielded intent
|
|
45
|
+
*
|
|
46
|
+
* Additional configuration passed to {@link createShieldedIntent} that
|
|
47
|
+
* affects proof generation and sender identification.
|
|
44
48
|
*/
|
|
45
49
|
export interface CreateIntentOptions {
|
|
46
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* Wallet address of the sender
|
|
52
|
+
*
|
|
53
|
+
* Used for:
|
|
54
|
+
* - Generating ownership proofs (proving control of input funds)
|
|
55
|
+
* - Creating sender commitments
|
|
56
|
+
* - Enabling refunds if transaction fails
|
|
57
|
+
*
|
|
58
|
+
* Optional but recommended for production use.
|
|
59
|
+
*/
|
|
47
60
|
senderAddress?: string
|
|
61
|
+
|
|
48
62
|
/**
|
|
49
|
-
* Proof provider for
|
|
50
|
-
*
|
|
63
|
+
* Proof provider for automatic ZK proof generation
|
|
64
|
+
*
|
|
65
|
+
* If provided and privacy level is SHIELDED or COMPLIANT, proofs will be
|
|
66
|
+
* generated automatically during intent creation. If not provided, proofs
|
|
67
|
+
* must be attached later using {@link attachProofs}.
|
|
68
|
+
*
|
|
69
|
+
* **Available providers:**
|
|
70
|
+
* - {@link MockProofProvider}: For testing
|
|
71
|
+
* - `NoirProofProvider`: For production (Node.js)
|
|
72
|
+
* - `BrowserNoirProvider`: For browsers
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* import { NoirProofProvider } from '@sip-protocol/sdk/proofs/noir'
|
|
77
|
+
*
|
|
78
|
+
* const provider = new NoirProofProvider()
|
|
79
|
+
* await provider.initialize()
|
|
80
|
+
*
|
|
81
|
+
* const intent = await createShieldedIntent(params, {
|
|
82
|
+
* senderAddress: wallet.address,
|
|
83
|
+
* proofProvider: provider,
|
|
84
|
+
* })
|
|
85
|
+
* ```
|
|
51
86
|
*/
|
|
52
87
|
proofProvider?: ProofProvider
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Signature proving ownership of the sender's address
|
|
91
|
+
*
|
|
92
|
+
* Required for production proof generation. This signature proves
|
|
93
|
+
* the sender controls the address that holds the input funds.
|
|
94
|
+
*
|
|
95
|
+
* Should be a 64-byte ECDSA signature over the address.
|
|
96
|
+
*/
|
|
97
|
+
ownershipSignature?: Uint8Array
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Sender's secret key for nullifier derivation
|
|
101
|
+
*
|
|
102
|
+
* Required for production proof generation. Used to derive:
|
|
103
|
+
* - Public key for ECDSA verification in proofs
|
|
104
|
+
* - Nullifier to prevent double-spending
|
|
105
|
+
*
|
|
106
|
+
* Should be a 32-byte secret. Keep this secure!
|
|
107
|
+
*/
|
|
108
|
+
senderSecret?: Uint8Array
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Signature authorizing this specific intent
|
|
112
|
+
*
|
|
113
|
+
* Required for production proof generation. This signature proves
|
|
114
|
+
* the sender authorized this intent (signs the intent hash).
|
|
115
|
+
*
|
|
116
|
+
* Should be a 64-byte ECDSA signature over the intent hash.
|
|
117
|
+
*/
|
|
118
|
+
authorizationSignature?: Uint8Array
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Allow placeholder signatures for development/testing
|
|
122
|
+
*
|
|
123
|
+
* When true, allows proof generation with empty placeholder signatures.
|
|
124
|
+
* **WARNING**: Never use this in production! Proofs with placeholders
|
|
125
|
+
* are not cryptographically valid.
|
|
126
|
+
*
|
|
127
|
+
* @default false
|
|
128
|
+
*/
|
|
129
|
+
allowPlaceholders?: boolean
|
|
53
130
|
}
|
|
54
131
|
|
|
55
132
|
/**
|
|
56
|
-
*
|
|
133
|
+
* Fluent builder for creating shielded intents
|
|
134
|
+
*
|
|
135
|
+
* Provides a chainable API for constructing intents step-by-step.
|
|
136
|
+
* More ergonomic than passing a large parameter object directly.
|
|
137
|
+
*
|
|
138
|
+
* **Builder Methods:**
|
|
139
|
+
* - {@link input}: Set input asset and amount
|
|
140
|
+
* - {@link output}: Set output asset and constraints
|
|
141
|
+
* - {@link privacy}: Set privacy level
|
|
142
|
+
* - {@link recipient}: Set recipient stealth meta-address
|
|
143
|
+
* - {@link slippage}: Set slippage tolerance
|
|
144
|
+
* - {@link ttl}: Set time-to-live
|
|
145
|
+
* - {@link withProvider}: Set proof provider
|
|
146
|
+
* - {@link build}: Create the intent
|
|
147
|
+
*
|
|
148
|
+
* @example Basic intent
|
|
149
|
+
* ```typescript
|
|
150
|
+
* const intent = await new IntentBuilder()
|
|
151
|
+
* .input('solana', 'SOL', 10n * 10n**9n)
|
|
152
|
+
* .output('ethereum', 'ETH', 0n)
|
|
153
|
+
* .privacy(PrivacyLevel.SHIELDED)
|
|
154
|
+
* .build()
|
|
155
|
+
* ```
|
|
156
|
+
*
|
|
157
|
+
* @example Full-featured intent with proofs
|
|
158
|
+
* ```typescript
|
|
159
|
+
* import { IntentBuilder, PrivacyLevel, MockProofProvider } from '@sip-protocol/sdk'
|
|
160
|
+
*
|
|
161
|
+
* const builder = new IntentBuilder()
|
|
162
|
+
* const intent = await builder
|
|
163
|
+
* .input('near', 'NEAR', 100n * 10n**24n, wallet.address) // 100 NEAR
|
|
164
|
+
* .output('zcash', 'ZEC', 95n * 10n**8n) // Min 95 ZEC
|
|
165
|
+
* .privacy(PrivacyLevel.COMPLIANT)
|
|
166
|
+
* .recipient('sip:zcash:0x02abc...123:0x03def...456')
|
|
167
|
+
* .slippage(1) // 1%
|
|
168
|
+
* .ttl(600) // 10 minutes
|
|
169
|
+
* .withProvider(new MockProofProvider())
|
|
170
|
+
* .build()
|
|
171
|
+
*
|
|
172
|
+
* console.log('Intent created:', intent.intentId)
|
|
173
|
+
* console.log('Has proofs:', !!intent.fundingProof && !!intent.validityProof)
|
|
174
|
+
* ```
|
|
175
|
+
*
|
|
176
|
+
* @see {@link createShieldedIntent} for the underlying implementation
|
|
177
|
+
* @see {@link CreateIntentParams} for parameter types
|
|
57
178
|
*/
|
|
58
179
|
export class IntentBuilder {
|
|
59
180
|
private params: Partial<CreateIntentParams> = {}
|
|
60
181
|
private senderAddress?: string
|
|
61
182
|
private proofProvider?: ProofProvider
|
|
183
|
+
private ownershipSignature?: Uint8Array
|
|
184
|
+
private senderSecret?: Uint8Array
|
|
185
|
+
private authorizationSignature?: Uint8Array
|
|
186
|
+
private allowPlaceholders?: boolean
|
|
62
187
|
|
|
63
188
|
/**
|
|
64
189
|
* Set the input for the intent
|
|
@@ -92,7 +217,7 @@ export class IntentBuilder {
|
|
|
92
217
|
|
|
93
218
|
this.params.input = {
|
|
94
219
|
asset: {
|
|
95
|
-
chain: chain as
|
|
220
|
+
chain: chain as ChainId,
|
|
96
221
|
symbol: token,
|
|
97
222
|
address: null,
|
|
98
223
|
decimals: 18, // Default, should be looked up
|
|
@@ -136,7 +261,7 @@ export class IntentBuilder {
|
|
|
136
261
|
|
|
137
262
|
this.params.output = {
|
|
138
263
|
asset: {
|
|
139
|
-
chain: chain as
|
|
264
|
+
chain: chain as ChainId,
|
|
140
265
|
symbol: token,
|
|
141
266
|
address: null,
|
|
142
267
|
decimals: 18,
|
|
@@ -238,6 +363,55 @@ export class IntentBuilder {
|
|
|
238
363
|
return this
|
|
239
364
|
}
|
|
240
365
|
|
|
366
|
+
/**
|
|
367
|
+
* Set the signatures and secret for proof generation
|
|
368
|
+
*
|
|
369
|
+
* Required for production proof generation. Provides the cryptographic
|
|
370
|
+
* materials needed to generate valid ZK proofs.
|
|
371
|
+
*
|
|
372
|
+
* @param signatures - Object containing ownership signature, sender secret, and authorization signature
|
|
373
|
+
* @returns this for chaining
|
|
374
|
+
*
|
|
375
|
+
* @example
|
|
376
|
+
* ```typescript
|
|
377
|
+
* const intent = await builder
|
|
378
|
+
* .input('near', 'NEAR', 100n)
|
|
379
|
+
* .output('zcash', 'ZEC', 95n)
|
|
380
|
+
* .privacy(PrivacyLevel.SHIELDED)
|
|
381
|
+
* .withProvider(noirProvider)
|
|
382
|
+
* .withSignatures({
|
|
383
|
+
* ownershipSignature: await wallet.signMessage(address),
|
|
384
|
+
* senderSecret: wallet.privateKey,
|
|
385
|
+
* authorizationSignature: await wallet.signMessage(intentHash),
|
|
386
|
+
* })
|
|
387
|
+
* .build()
|
|
388
|
+
* ```
|
|
389
|
+
*/
|
|
390
|
+
withSignatures(signatures: {
|
|
391
|
+
ownershipSignature: Uint8Array
|
|
392
|
+
senderSecret: Uint8Array
|
|
393
|
+
authorizationSignature: Uint8Array
|
|
394
|
+
}): this {
|
|
395
|
+
this.ownershipSignature = signatures.ownershipSignature
|
|
396
|
+
this.senderSecret = signatures.senderSecret
|
|
397
|
+
this.authorizationSignature = signatures.authorizationSignature
|
|
398
|
+
return this
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Allow placeholder signatures for development/testing
|
|
403
|
+
*
|
|
404
|
+
* **WARNING**: Never use this in production! Proofs with placeholders
|
|
405
|
+
* are not cryptographically valid.
|
|
406
|
+
*
|
|
407
|
+
* @param allow - Whether to allow placeholders (default: true)
|
|
408
|
+
* @returns this for chaining
|
|
409
|
+
*/
|
|
410
|
+
withPlaceholders(allow: boolean = true): this {
|
|
411
|
+
this.allowPlaceholders = allow
|
|
412
|
+
return this
|
|
413
|
+
}
|
|
414
|
+
|
|
241
415
|
/**
|
|
242
416
|
* Build the shielded intent
|
|
243
417
|
*
|
|
@@ -250,6 +424,10 @@ export class IntentBuilder {
|
|
|
250
424
|
return createShieldedIntent(this.params as CreateIntentParams, {
|
|
251
425
|
senderAddress: this.senderAddress,
|
|
252
426
|
proofProvider: this.proofProvider,
|
|
427
|
+
ownershipSignature: this.ownershipSignature,
|
|
428
|
+
senderSecret: this.senderSecret,
|
|
429
|
+
authorizationSignature: this.authorizationSignature,
|
|
430
|
+
allowPlaceholders: this.allowPlaceholders,
|
|
253
431
|
})
|
|
254
432
|
}
|
|
255
433
|
}
|
|
@@ -281,7 +459,14 @@ export async function createShieldedIntent(
|
|
|
281
459
|
validateCreateIntentParams(params)
|
|
282
460
|
|
|
283
461
|
const { input, output, privacy, recipientMetaAddress, viewingKey, ttl = 300 } = params
|
|
284
|
-
const {
|
|
462
|
+
const {
|
|
463
|
+
senderAddress,
|
|
464
|
+
proofProvider,
|
|
465
|
+
ownershipSignature,
|
|
466
|
+
senderSecret,
|
|
467
|
+
authorizationSignature,
|
|
468
|
+
allowPlaceholders = false,
|
|
469
|
+
} = options ?? {}
|
|
285
470
|
|
|
286
471
|
// Get privacy configuration
|
|
287
472
|
// Compute viewing key hash the same way as generateViewingKey():
|
|
@@ -331,12 +516,42 @@ export async function createShieldedIntent(
|
|
|
331
516
|
const requiresProofs = privacy !== PrivacyLevelEnum.TRANSPARENT
|
|
332
517
|
|
|
333
518
|
if (requiresProofs && proofProvider && proofProvider.isReady) {
|
|
519
|
+
// Check if signatures are provided or placeholders are allowed
|
|
520
|
+
const hasSignatures = ownershipSignature && senderSecret && authorizationSignature
|
|
521
|
+
const usingPlaceholders = !hasSignatures
|
|
522
|
+
|
|
523
|
+
if (usingPlaceholders && !allowPlaceholders) {
|
|
524
|
+
throw new ValidationError(
|
|
525
|
+
'Proof generation requires signatures. Provide ownershipSignature, senderSecret, and authorizationSignature in options, or set allowPlaceholders: true for development/testing.',
|
|
526
|
+
'options',
|
|
527
|
+
{
|
|
528
|
+
missing: [
|
|
529
|
+
!ownershipSignature && 'ownershipSignature',
|
|
530
|
+
!senderSecret && 'senderSecret',
|
|
531
|
+
!authorizationSignature && 'authorizationSignature',
|
|
532
|
+
].filter(Boolean),
|
|
533
|
+
}
|
|
534
|
+
)
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
if (usingPlaceholders) {
|
|
538
|
+
console.warn(
|
|
539
|
+
'[createShieldedIntent] WARNING: Using placeholder signatures for proof generation. ' +
|
|
540
|
+
'These proofs are NOT cryptographically valid. Do NOT use in production!'
|
|
541
|
+
)
|
|
542
|
+
}
|
|
543
|
+
|
|
334
544
|
// Helper to convert HexString to Uint8Array
|
|
335
545
|
const hexToUint8 = (hex: HexString): Uint8Array => {
|
|
336
546
|
const cleanHex = hex.startsWith('0x') ? hex.slice(2) : hex
|
|
337
547
|
return hexToBytes(cleanHex)
|
|
338
548
|
}
|
|
339
549
|
|
|
550
|
+
// Use provided signatures or placeholders (if allowed)
|
|
551
|
+
const effectiveOwnershipSig = ownershipSignature ?? new Uint8Array(64)
|
|
552
|
+
const effectiveSenderSecret = senderSecret ?? new Uint8Array(32)
|
|
553
|
+
const effectiveAuthSig = authorizationSignature ?? new Uint8Array(64)
|
|
554
|
+
|
|
340
555
|
// Generate funding proof
|
|
341
556
|
const fundingResult = await proofProvider.generateFundingProof({
|
|
342
557
|
balance: input.amount,
|
|
@@ -344,7 +559,7 @@ export async function createShieldedIntent(
|
|
|
344
559
|
blindingFactor: hexToUint8(inputCommitment.blindingFactor as HexString),
|
|
345
560
|
assetId: input.asset.symbol,
|
|
346
561
|
userAddress: senderAddress ?? '0x0',
|
|
347
|
-
ownershipSignature:
|
|
562
|
+
ownershipSignature: effectiveOwnershipSig,
|
|
348
563
|
})
|
|
349
564
|
fundingProof = fundingResult.proof
|
|
350
565
|
|
|
@@ -353,8 +568,8 @@ export async function createShieldedIntent(
|
|
|
353
568
|
intentHash: hash(intentId) as HexString,
|
|
354
569
|
senderAddress: senderAddress ?? '0x0',
|
|
355
570
|
senderBlinding: hexToUint8(senderCommitment.blindingFactor as HexString),
|
|
356
|
-
senderSecret:
|
|
357
|
-
authorizationSignature:
|
|
571
|
+
senderSecret: effectiveSenderSecret,
|
|
572
|
+
authorizationSignature: effectiveAuthSig,
|
|
358
573
|
nonce: new Uint8Array(32), // Could use randomBytes here
|
|
359
574
|
timestamp: now,
|
|
360
575
|
expiry: now + ttl,
|
|
@@ -381,8 +596,8 @@ export async function createShieldedIntent(
|
|
|
381
596
|
// - TRANSPARENT mode (not required)
|
|
382
597
|
// - No proof provider given
|
|
383
598
|
// - Provider not ready
|
|
384
|
-
fundingProof
|
|
385
|
-
validityProof
|
|
599
|
+
fundingProof,
|
|
600
|
+
validityProof,
|
|
386
601
|
|
|
387
602
|
viewingKeyHash: privacyConfig.viewingKey?.hash,
|
|
388
603
|
}
|
package/src/nft/index.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NFT Module for SIP Protocol
|
|
3
|
+
*
|
|
4
|
+
* Private NFT ownership using stealth addresses and zero-knowledge proofs.
|
|
5
|
+
*
|
|
6
|
+
* @module nft
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
PrivateNFT,
|
|
11
|
+
createPrivateOwnership,
|
|
12
|
+
proveOwnership,
|
|
13
|
+
verifyOwnership,
|
|
14
|
+
} from './private-nft'
|
|
15
|
+
|
|
16
|
+
// Re-export types for convenience
|
|
17
|
+
export type {
|
|
18
|
+
PrivateNFTOwnership,
|
|
19
|
+
OwnershipProof,
|
|
20
|
+
OwnershipVerification,
|
|
21
|
+
CreatePrivateOwnershipParams,
|
|
22
|
+
ProveOwnershipParams,
|
|
23
|
+
TransferPrivatelyParams,
|
|
24
|
+
TransferResult,
|
|
25
|
+
NFTTransfer,
|
|
26
|
+
OwnedNFT,
|
|
27
|
+
} from '@sip-protocol/types'
|