@dstorage-tech/dstorage-sdk 0.0.4
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/LICENSE +21 -0
- package/README.md +530 -0
- package/dist/KeypairEncryptionAdapter-AE75YC4W-AOWNSH2M.mjs +9 -0
- package/dist/KeypairEncryptionAdapter-AE75YC4W-BAVHRNNJ.mjs +1 -0
- package/dist/KeypairEncryptionAdapter-AE75YC4W-BEYO4RUO.mjs +1 -0
- package/dist/KeypairEncryptionAdapter-AE75YC4W-VAOH6AAL.mjs +9 -0
- package/dist/KeypairEncryptionAdapter-XUKCLRFU-6ERIZN2M.mjs +1 -0
- package/dist/KeypairEncryptionAdapter-XUKCLRFU-AYDAZ2TZ.mjs +9 -0
- package/dist/KeypairEncryptionAdapter-XUKCLRFU-ERPYK5S4.mjs +8 -0
- package/dist/MnemonicEncryptionAdapter-J6IE5OKA-6DFVUVD6.mjs +1 -0
- package/dist/MnemonicEncryptionAdapter-J6IE5OKA-O5AJPX42.mjs +1 -0
- package/dist/MnemonicEncryptionAdapter-J6IE5OKA-SI6TBLTQ.mjs +9 -0
- package/dist/MnemonicEncryptionAdapter-J6IE5OKA-WEPFOTSJ.mjs +9 -0
- package/dist/MnemonicEncryptionAdapter-RCHUETBP-DZPBGQG6.mjs +8 -0
- package/dist/MnemonicEncryptionAdapter-RCHUETBP-ELAMJMMO.mjs +1 -0
- package/dist/MnemonicEncryptionAdapter-RCHUETBP-M7NHGSHO.mjs +9 -0
- package/dist/PasswordEncryptionAdapter-CWOXUGR4-2YZ64B4A.mjs +1 -0
- package/dist/PasswordEncryptionAdapter-CWOXUGR4-DCEGC2NX.mjs +1 -0
- package/dist/PasswordEncryptionAdapter-CWOXUGR4-QEGGYPFJ.mjs +13 -0
- package/dist/PasswordEncryptionAdapter-CWOXUGR4-ZYUBUYUI.mjs +13 -0
- package/dist/PasswordEncryptionAdapter-ECHND672-3DEFO6FP.mjs +13 -0
- package/dist/PasswordEncryptionAdapter-ECHND672-MUTHAMZY.mjs +12 -0
- package/dist/PasswordEncryptionAdapter-ECHND672-XVBPHPPT.mjs +1 -0
- package/dist/browser.d.mts +2418 -0
- package/dist/browser.mjs +5175 -0
- package/dist/chunk-25I6ZXUC.mjs +9403 -0
- package/dist/chunk-4X5K43JF.mjs +62 -0
- package/dist/chunk-4YMF57VY.mjs +1 -0
- package/dist/chunk-5MZ7FPPY.mjs +1 -0
- package/dist/chunk-5P4EW2YL.mjs +1 -0
- package/dist/chunk-5QOKJEH3.mjs +8 -0
- package/dist/chunk-5RW7SGA7.mjs +1 -0
- package/dist/chunk-62RSKZ6T.mjs +118 -0
- package/dist/chunk-6IAQVMSM.mjs +102 -0
- package/dist/chunk-BBJCQFWP.mjs +275 -0
- package/dist/chunk-BWLEAAFW.mjs +2599 -0
- package/dist/chunk-EYF3263P.mjs +2049 -0
- package/dist/chunk-FJ7LSZOW.mjs +5537 -0
- package/dist/chunk-GUYENY5N.mjs +1 -0
- package/dist/chunk-HDD6SUU4.mjs +276 -0
- package/dist/chunk-JMPRZK5D.mjs +62 -0
- package/dist/chunk-L5QD6GHB.mjs +101 -0
- package/dist/chunk-O37NHERH.mjs +17 -0
- package/dist/chunk-OLGVVM5Y.mjs +102 -0
- package/dist/chunk-PKHRAYFD.mjs +1 -0
- package/dist/chunk-PLAOCKSS.mjs +101 -0
- package/dist/chunk-QKA2DCR6.mjs +118 -0
- package/dist/chunk-RPSRFFXN.mjs +275 -0
- package/dist/chunk-TESUOXRJ.mjs +1 -0
- package/dist/chunk-TMLXCRJU.mjs +1 -0
- package/dist/chunk-TNRKN4LB.mjs +1 -0
- package/dist/chunk-TSZ37JDY.mjs +2596 -0
- package/dist/chunk-U3MS6KMF.mjs +1 -0
- package/dist/chunk-UBALMYIY.mjs +2049 -0
- package/dist/chunk-UDYXMII2.mjs +121 -0
- package/dist/chunk-UJCSKKID.mjs +30 -0
- package/dist/chunk-UOOF4V2Y.mjs +1 -0
- package/dist/chunk-VDZ7F7MP.mjs +1329 -0
- package/dist/chunk-X4LEBNK6.mjs +276 -0
- package/dist/chunk-Z2TH6U4C.mjs +3 -0
- package/dist/chunk-Z6DUAI5B.mjs +121 -0
- package/dist/chunk-ZEPZ4QDD.mjs +1 -0
- package/dist/chunk-ZGUY5EIR.mjs +1 -0
- package/dist/cjs-RMZ3L2IO.mjs +5 -0
- package/dist/contract-api-AO4RGPLT-4HRCMSCE.mjs +279 -0
- package/dist/contract-api-AO4RGPLT-ADH6ZDKC.mjs +279 -0
- package/dist/contract-api-AO4RGPLT-ENC72WCG.mjs +280 -0
- package/dist/contract-api-AO4RGPLT-PAMIPEI3.mjs +1 -0
- package/dist/contract-api-AO4RGPLT-W3RSVP5A.mjs +1 -0
- package/dist/contract-api-AO4RGPLT-WENYDV6I.mjs +1 -0
- package/dist/contract-api-TJ7JPHZA-6FUBJ6DS.mjs +279 -0
- package/dist/contract-api-TJ7JPHZA-ZWP3EH7D.mjs +279 -0
- package/dist/contracts/dataregistry/managed/keys/removeReference.prover +0 -0
- package/dist/contracts/dataregistry/managed/keys/removeReference.verifier +0 -0
- package/dist/contracts/dataregistry/managed/keys/storeReference.prover +0 -0
- package/dist/contracts/dataregistry/managed/keys/storeReference.verifier +0 -0
- package/dist/contracts/dataregistry/managed/keys/updateReference.prover +0 -0
- package/dist/contracts/dataregistry/managed/keys/updateReference.verifier +0 -0
- package/dist/contracts/dataregistry/managed/zkir/removeReference.bzkir +0 -0
- package/dist/contracts/dataregistry/managed/zkir/removeReference.zkir +138 -0
- package/dist/contracts/dataregistry/managed/zkir/storeReference.bzkir +0 -0
- package/dist/contracts/dataregistry/managed/zkir/storeReference.zkir +158 -0
- package/dist/contracts/dataregistry/managed/zkir/updateReference.bzkir +0 -0
- package/dist/contracts/dataregistry/managed/zkir/updateReference.zkir +190 -0
- package/dist/dataregistry-simulator-E6RTGGWT-5YEGBW7P.mjs +108 -0
- package/dist/dataregistry-simulator-E6RTGGWT-DJS4MHBD.mjs +109 -0
- package/dist/dataregistry-simulator-E6RTGGWT-QGCYR3VF.mjs +1 -0
- package/dist/dist-655VYUPJ.mjs +1 -0
- package/dist/dist-INTAFXQ7.mjs +65 -0
- package/dist/dist-MEZZWKP4.mjs +1 -0
- package/dist/dist-MOLWJ4Y7.mjs +64 -0
- package/dist/dist-UD4WRMYJ.mjs +65 -0
- package/dist/errors.d.mts +117 -0
- package/dist/errors.d.ts +117 -0
- package/dist/errors.js +2308 -0
- package/dist/errors.mjs +2278 -0
- package/dist/esm5-AGBDHMNS.mjs +1 -0
- package/dist/esm5-GFOBLUFI.mjs +350 -0
- package/dist/in-memory-private-state-NGOP37V7-DXWZE42Q.mjs +48 -0
- package/dist/in-memory-private-state-NGOP37V7-QXT3RUEH.mjs +49 -0
- package/dist/in-memory-private-state-NGOP37V7-XFJFNFCQ.mjs +1 -0
- package/dist/index.d.mts +2843 -0
- package/dist/index.d.ts +2843 -0
- package/dist/index.js +19639 -0
- package/dist/index.mjs +5177 -0
- package/package.json +87 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EncryptionErrorCode
|
|
3
|
+
} from "./chunk-O37NHERH.mjs";
|
|
4
|
+
import {
|
|
5
|
+
DStorageError,
|
|
6
|
+
mlkemGenerateKeypair,
|
|
7
|
+
mlkemUnwrapDek,
|
|
8
|
+
mlkemWrapDek
|
|
9
|
+
} from "./chunk-BWLEAAFW.mjs";
|
|
10
|
+
|
|
11
|
+
// ../encryption/dist/chunk-NAJYQ4J6.mjs
|
|
12
|
+
var KeypairEncryptionAdapter = class _KeypairEncryptionAdapter {
|
|
13
|
+
constructor(pk, sk, context, variant) {
|
|
14
|
+
this.publicKey = pk;
|
|
15
|
+
this.secretKey = sk;
|
|
16
|
+
this.context = context;
|
|
17
|
+
this.variant = variant;
|
|
18
|
+
this.name = variant;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Upload-only adapter — holds only the Public Key.
|
|
22
|
+
* wrapDek() works normally; unwrapDek() throws (no SK available).
|
|
23
|
+
*/
|
|
24
|
+
static fromPublicKey(pk, context, variant = "mlkem768") {
|
|
25
|
+
return new _KeypairEncryptionAdapter(pk, void 0, context, variant);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Full adapter — holds both Public Key and Secret Key.
|
|
29
|
+
* Both wrapDek() and unwrapDek() work.
|
|
30
|
+
*/
|
|
31
|
+
static fromKeypair(pk, sk, context, variant = "mlkem768") {
|
|
32
|
+
return new _KeypairEncryptionAdapter(pk, sk, context, variant);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Generate a fresh random ML-KEM keypair.
|
|
36
|
+
*
|
|
37
|
+
* Returns the adapter (with both PK+SK) plus the raw keys so the caller
|
|
38
|
+
* can persist the secret key and share the public key separately.
|
|
39
|
+
*
|
|
40
|
+
* @param context Domain-separation string bound into the KEK derivation
|
|
41
|
+
* @param variant Default: "mlkem768".
|
|
42
|
+
*/
|
|
43
|
+
static generateKeypair(context, variant = "mlkem768") {
|
|
44
|
+
const { pk, sk } = mlkemGenerateKeypair(variant);
|
|
45
|
+
return {
|
|
46
|
+
adapter: new _KeypairEncryptionAdapter(pk, sk, context, variant),
|
|
47
|
+
publicKey: pk,
|
|
48
|
+
secretKey: sk
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Deterministically derive a ML-KEM keypair from a BIP-39 mnemonic phrase or hex seed.
|
|
53
|
+
*
|
|
54
|
+
* Delegates to MnemonicEncryptionAdapter.intoKeypairEncryptionAdapter() so all
|
|
55
|
+
* mnemonic/seed handling lives in a single place.
|
|
56
|
+
*
|
|
57
|
+
* Same inputs + variant always produce the same keypair.
|
|
58
|
+
*
|
|
59
|
+
* `seedHex` may be either 32 bytes (64 hex chars) or 64 bytes (128 hex chars) —
|
|
60
|
+
* both are expanded to the 64-byte ML-KEM seed via HKDF.
|
|
61
|
+
*
|
|
62
|
+
* @param input { mnemonic } (24-word BIP-39) or { seedHex } (32- or 64-byte hex)
|
|
63
|
+
* @param context Domain-separation string bound into the KEK derivation
|
|
64
|
+
* @param variant Default: "mlkem768"
|
|
65
|
+
*/
|
|
66
|
+
static async fromMnemonic(input, context, variant = "mlkem768") {
|
|
67
|
+
const { MnemonicEncryptionAdapter } = await import("./MnemonicEncryptionAdapter-RCHUETBP-M7NHGSHO.mjs");
|
|
68
|
+
const ms = new MnemonicEncryptionAdapter(input);
|
|
69
|
+
return ms.intoKeypairEncryptionAdapter(context, variant);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Deterministically derive a ML-KEM keypair from a password and salt.
|
|
73
|
+
*
|
|
74
|
+
* Delegates to PasswordEncryptionAdapter.intoKeypairEncryptionAdapter() so all
|
|
75
|
+
* password handling (scrypt params, entropy validation, 64-byte seed derivation)
|
|
76
|
+
* lives in a single place.
|
|
77
|
+
*
|
|
78
|
+
* Same password + salt + variant always produces the same keypair.
|
|
79
|
+
*
|
|
80
|
+
* @param password User password (validated for entropy)
|
|
81
|
+
* @param salt Domain salt — must not be empty
|
|
82
|
+
* @param context Domain-separation string bound into the KEK derivation
|
|
83
|
+
* @param variant Default: "mlkem768"
|
|
84
|
+
* @param params Optional custom scrypt params
|
|
85
|
+
*/
|
|
86
|
+
static async fromPassword(password, salt, context, variant = "mlkem768", params) {
|
|
87
|
+
const { PasswordEncryptionAdapter } = await import("./PasswordEncryptionAdapter-ECHND672-3DEFO6FP.mjs");
|
|
88
|
+
const ps = new PasswordEncryptionAdapter({
|
|
89
|
+
password,
|
|
90
|
+
salt,
|
|
91
|
+
...params ? { params } : {}
|
|
92
|
+
});
|
|
93
|
+
return ps.intoKeypairEncryptionAdapter(context, variant);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Zero the Secret Key bytes and mark this adapter as read-only.
|
|
97
|
+
* Call when the adapter is no longer needed to minimise the window
|
|
98
|
+
* during which raw ML-KEM key material sits in GC-reachable memory.
|
|
99
|
+
* After destroy(), unwrapDek() will throw.
|
|
100
|
+
*/
|
|
101
|
+
destroy() {
|
|
102
|
+
this.secretKey?.fill(0);
|
|
103
|
+
this.secretKey = void 0;
|
|
104
|
+
}
|
|
105
|
+
async wrapDek(dek) {
|
|
106
|
+
return mlkemWrapDek(dek, this.publicKey, this.context, this.variant);
|
|
107
|
+
}
|
|
108
|
+
async unwrapDek(data) {
|
|
109
|
+
if (!this.secretKey) {
|
|
110
|
+
throw new DStorageError(
|
|
111
|
+
EncryptionErrorCode.KEYPAIR_MISSING_SECRET_KEY,
|
|
112
|
+
`[dStorage] KeypairEncryptionAdapter(${this.variant}): cannot unwrapDek \u2014 no Secret Key is available. Use fromKeypair() or fromPassword() to create an adapter with a SK.`
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
return mlkemUnwrapDek(data, this.secretKey, this.context);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export {
|
|
120
|
+
KeypairEncryptionAdapter
|
|
121
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
20
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
21
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
22
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
23
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
24
|
+
mod
|
|
25
|
+
));
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
__commonJS,
|
|
29
|
+
__toESM
|
|
30
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as m}from"./chunk-PKHRAYFD.mjs";import{A as c,B as p,a as o,y as s}from"./chunk-UBALMYIY.mjs";var h=class n{constructor(e,t,r,i){this.publicKey=e,this.secretKey=t,this.context=r,this.variant=i,this.name=i}static fromPublicKey(e,t,r="mlkem768"){return new n(e,void 0,t,r)}static fromKeypair(e,t,r,i="mlkem768"){return new n(e,t,r,i)}static generateKeypair(e,t="mlkem768"){let{pk:r,sk:i}=s(t);return{adapter:new n(r,i,e,t),publicKey:r,secretKey:i}}static async fromMnemonic(e,t,r="mlkem768"){let{MnemonicEncryptionAdapter:i}=await import("./MnemonicEncryptionAdapter-J6IE5OKA-6DFVUVD6.mjs");return new i(e).intoKeypairEncryptionAdapter(t,r)}static async fromPassword(e,t,r,i="mlkem768",a){let{PasswordEncryptionAdapter:y}=await import("./PasswordEncryptionAdapter-CWOXUGR4-DCEGC2NX.mjs");return new y({password:e,salt:t,...a?{params:a}:{}}).intoKeypairEncryptionAdapter(r,i)}destroy(){this.secretKey?.fill(0),this.secretKey=void 0}async wrapDek(e){return c(e,this.publicKey,this.context,this.variant)}async unwrapDek(e){if(!this.secretKey)throw new o(m.KEYPAIR_MISSING_SECRET_KEY,`[dStorage] KeypairEncryptionAdapter(${this.variant}): cannot unwrapDek \u2014 no Secret Key is available. Use fromKeypair() or fromPassword() to create an adapter with a SK.`);return p(e,this.secretKey,this.context)}};export{h as a};
|