@opaquecash/stellar 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.
- package/README.md +119 -0
- package/dist/crypto/index.cjs +2854 -0
- package/dist/crypto/index.cjs.map +1 -0
- package/dist/crypto/index.d.cts +345 -0
- package/dist/crypto/index.d.ts +345 -0
- package/dist/crypto/index.js +2784 -0
- package/dist/crypto/index.js.map +1 -0
- package/dist/index-Cy3ABCai.d.cts +520 -0
- package/dist/index-Dqr8RiOd.d.ts +520 -0
- package/dist/index.cjs +5146 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +822 -0
- package/dist/index.d.ts +822 -0
- package/dist/index.js +4989 -0
- package/dist/index.js.map +1 -0
- package/dist/notes-CTR_oi8Y.d.cts +56 -0
- package/dist/notes-CTR_oi8Y.d.ts +56 -0
- package/dist/relayer-protocol/index.cjs +455 -0
- package/dist/relayer-protocol/index.cjs.map +1 -0
- package/dist/relayer-protocol/index.d.cts +3 -0
- package/dist/relayer-protocol/index.d.ts +3 -0
- package/dist/relayer-protocol/index.js +431 -0
- package/dist/relayer-protocol/index.js.map +1 -0
- package/package.json +106 -0
package/README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# @opaquecash/stellar
|
|
2
|
+
|
|
3
|
+
Stealth private payments, privacy pools, relayer-market submission, and on-chain
|
|
4
|
+
zero-knowledge reputation for [Stellar](https://stellar.org) / Soroban — in one
|
|
5
|
+
framework-free, typed, isomorphic (browser + Node) package.
|
|
6
|
+
|
|
7
|
+
> Status: pre-release (`0.x`). All layers are implemented and tested: crypto,
|
|
8
|
+
> config, signer, RPC, contract bindings, domain services, the high-level
|
|
9
|
+
> `OpaqueClient`, Groth16 proof generation (reputation + pool), pure-TS
|
|
10
|
+
> announcement scanning, on-chain pool-state reconstruction, and the
|
|
11
|
+
> relayer-market gateway. Proving requires circuit artifacts via an
|
|
12
|
+
> `ArtifactResolver`; relayer payload encryption requires the optional `tweetnacl`
|
|
13
|
+
> peer dependency.
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm install @opaquecash/stellar
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Peer dependencies (install the ones your usage needs):
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
npm install @stellar/stellar-sdk @noble/curves @noble/hashes
|
|
25
|
+
# pool / reputation proving:
|
|
26
|
+
npm install circomlibjs snarkjs
|
|
27
|
+
# relayer market:
|
|
28
|
+
npm install tweetnacl
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Subpath exports
|
|
32
|
+
|
|
33
|
+
The package is tree-shakeable; import the narrowest surface you need.
|
|
34
|
+
|
|
35
|
+
| Import | Contents |
|
|
36
|
+
|--------|----------|
|
|
37
|
+
| `@opaquecash/stellar` | umbrella: `OpaqueClient`, services, bindings, config, signer |
|
|
38
|
+
| `@opaquecash/stellar/crypto` | isomorphic primitives, **no chain dependency** |
|
|
39
|
+
| `@opaquecash/stellar/relayer-protocol` | relayer wire format, payload hashing, box crypto, gateway client |
|
|
40
|
+
|
|
41
|
+
## High-level client
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import { OpaqueClient, keypairSigner } from "@opaquecash/stellar";
|
|
45
|
+
|
|
46
|
+
// Server-side with a raw keypair (browser apps pass a Freighter-backed signer).
|
|
47
|
+
const opaque = new OpaqueClient({
|
|
48
|
+
network: "testnet", // testnet addresses are baked in
|
|
49
|
+
signer: keypairSigner(process.env.SECRET!),
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// Stealth payments
|
|
53
|
+
const id = opaque.payments.deriveIdentity(walletSignatureHex);
|
|
54
|
+
await opaque.payments.register({ metaAddress: id.metaAddress });
|
|
55
|
+
await opaque.payments.send({ to: recipientMetaHex, amountXlm: "10" });
|
|
56
|
+
|
|
57
|
+
// On-chain ZK reputation (bring a precomputed proof until the prover lands)
|
|
58
|
+
await opaque.reputation.verifyOnChain(proofBundle);
|
|
59
|
+
|
|
60
|
+
// Privacy pool
|
|
61
|
+
const { note } = await opaque.pool.deposit({ amountXlm: "5" });
|
|
62
|
+
await opaque.pool.withdraw({ proof, recipient, noteCommitment: note.commitment });
|
|
63
|
+
|
|
64
|
+
// Schema administration
|
|
65
|
+
const { schemaId } = await opaque.schemas.register({
|
|
66
|
+
name: "credit", fieldDefinitions: "u64 score, bool verified",
|
|
67
|
+
revocable: true, schemaExpiryLedger: 5_000_000,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// Escape hatches
|
|
71
|
+
opaque.contracts.privacyPool; // typed contract bindings
|
|
72
|
+
opaque.soroban; // built-in RpcClient (Soroban + Horizon)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Override any default (RPC URLs, contract addresses, gateways) via the constructor;
|
|
76
|
+
plug your own `NoteStore`/`VaultStore`/`ScanStore`, `Logger`, and `Telemetry`.
|
|
77
|
+
|
|
78
|
+
## Crypto layer (available now)
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
import {
|
|
82
|
+
deriveKeysFromSignature,
|
|
83
|
+
keysToStealthMetaAddress,
|
|
84
|
+
stealthMetaAddressToHex,
|
|
85
|
+
computeStealthAddressAndViewTag,
|
|
86
|
+
checkViewTagMatch,
|
|
87
|
+
reconstructStealthPrivateKey,
|
|
88
|
+
deriveStealthStellarKeypairFromStealthPrivKey,
|
|
89
|
+
} from "@opaquecash/stellar/crypto";
|
|
90
|
+
|
|
91
|
+
// Recipient: derive a stealth meta-address from a wallet signature.
|
|
92
|
+
const { viewingKey, spendingKey } = deriveKeysFromSignature(walletSignatureHex);
|
|
93
|
+
const { metaAddress } = keysToStealthMetaAddress(viewingKey, spendingKey);
|
|
94
|
+
const metaHex = stealthMetaAddressToHex(metaAddress);
|
|
95
|
+
|
|
96
|
+
// Sender: derive a one-time stealth address + the Stellar account that receives funds.
|
|
97
|
+
const send = computeStealthAddressAndViewTag(metaHex);
|
|
98
|
+
// -> send.stealthStellarAddress is the G-address to pay.
|
|
99
|
+
|
|
100
|
+
// Recipient: detect (cheap) then reconstruct the spending key.
|
|
101
|
+
if (checkViewTagMatch({ viewingKey, ephemeralPubKey: send.ephemeralPubKey, viewTag: send.viewTag })) {
|
|
102
|
+
const stealthPriv = reconstructStealthPrivateKey({
|
|
103
|
+
viewingKey,
|
|
104
|
+
spendingKey,
|
|
105
|
+
ephemeralPubKey: send.ephemeralPubKey,
|
|
106
|
+
});
|
|
107
|
+
const keypair = deriveStealthStellarKeypairFromStealthPrivKey(stealthPriv);
|
|
108
|
+
// keypair.publicKey() === send.stealthStellarAddress
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Also in `crypto`: privacy-pool note derivation (`deriveDeposit`, `newNoteSecrets`),
|
|
113
|
+
schema / attestation codecs (`computeSchemaId`, `encodeAttestationData`), encrypted
|
|
114
|
+
backups (`encryptGhostEntries`), payment links (`createPaymentLink`), and memo
|
|
115
|
+
validation (`validateMemo`).
|
|
116
|
+
|
|
117
|
+
## License
|
|
118
|
+
|
|
119
|
+
MIT
|