@interncom/diplomatic 0.12.10 → 0.13.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/cli/index.mjs +2 -2
- package/dist/cli/shared/codec.d.ts +1 -0
- package/dist/cli/shared/codecs/pairPackage.d.ts +1 -2
- package/dist/cli/shared/consts.d.ts +2 -1
- package/dist/cli/shared/crypto/enclave.d.ts +4 -23
- package/dist/cli/shared/crypto/noble.d.ts +8 -1
- package/dist/cli/shared/crypto/pairing.d.ts +34 -0
- package/dist/cli/shared/crypto/x25519.d.ts +10 -0
- package/dist/web/index.d.ts +5 -4
- package/dist/web/index.mjs +1 -1
- package/dist/web/shared/codec.d.ts +1 -0
- package/dist/web/shared/codecs/pairPackage.d.ts +1 -2
- package/dist/web/shared/consts.d.ts +2 -1
- package/dist/web/shared/crypto/enclave.d.ts +4 -23
- package/dist/web/shared/crypto/noble.d.ts +8 -1
- package/dist/web/shared/crypto/pairing.d.ts +34 -0
- package/dist/web/shared/crypto/x25519.d.ts +10 -0
- package/dist/web/worker.mjs +1 -1
- package/package.json +1 -1
- package/dist/web/identity/pairPackage.d.ts +0 -30
- package/dist/web/shared/codecs/pairPackageEnvelope.d.ts +0 -18
|
@@ -40,6 +40,7 @@ export declare class Encoder {
|
|
|
40
40
|
writeStructs<T>(codec: ICodecStruct<T>, structs: Iterable<T>): Status;
|
|
41
41
|
writeBytesSeq(bytesSeq: Iterable<Uint8Array>): void;
|
|
42
42
|
result(): Uint8Array;
|
|
43
|
+
wipe(): void;
|
|
43
44
|
scan(): Generator<Uint8Array>;
|
|
44
45
|
}
|
|
45
46
|
export interface ICodecStruct<T> {
|
|
@@ -6,8 +6,7 @@ export type PairPackagePlain = {
|
|
|
6
6
|
hosts: BundleHost[];
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
9
|
-
* Inner plaintext
|
|
10
|
-
* ceremony, then carried as `body` in {@link pairPackageEnvelopeCodec}):
|
|
9
|
+
* Inner plaintext (AEAD is applied by QR pairing: X25519 + blake3 + XSalsa20):
|
|
11
10
|
* masterSeed: 32 fixed bytes
|
|
12
11
|
* hostsLen: varint
|
|
13
12
|
* hosts: hostsLen × BundleHost
|
|
@@ -3,6 +3,7 @@ import { Status } from "../consts.ts";
|
|
|
3
3
|
import { MASTER_SEED_LEN, type SealedMasterKey } from "../seed.ts";
|
|
4
4
|
import type { ICrypto, PublicKey } from "../types.ts";
|
|
5
5
|
import { type ValStat } from "../valstat.ts";
|
|
6
|
+
import { type DHKEReq, type DHKEResp, PairRequest } from "./pairing.ts";
|
|
6
7
|
import { type LargeBlobCreateOpts, type LargeBlobRp } from "../webauthn/largeBlob.ts";
|
|
7
8
|
import { type PrfCreateOpts, type PrfEvalOpts, type PrfRp } from "../webauthn/prf.ts";
|
|
8
9
|
export type { LargeBlobCreateOpts, LargeBlobRp };
|
|
@@ -48,7 +49,6 @@ export type Identity = {
|
|
|
48
49
|
kdmFor: (msgHeadEnc: Uint8Array) => Promise<Uint8Array>;
|
|
49
50
|
};
|
|
50
51
|
declare const SEAL_WRAP_DOMAIN: Uint8Array<ArrayBufferLike>;
|
|
51
|
-
declare const SEAL_PAIR_DOMAIN: Uint8Array<ArrayBufferLike>;
|
|
52
52
|
declare const SEAL_KEY_LEN = 32;
|
|
53
53
|
declare const SEAL_PRF_MIN_LEN = 16;
|
|
54
54
|
export declare class Enclave {
|
|
@@ -109,27 +109,8 @@ export declare class Enclave {
|
|
|
109
109
|
}>>;
|
|
110
110
|
/** UV + overwrite largeBlob with zeros (destroys stored seed material). */
|
|
111
111
|
static clearLargeBlob(credId: Uint8Array, opts?: LargeBlobRp): Promise<Status>;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
* Returns ciphertext body + public ceremony meta (no PRF).
|
|
115
|
-
*/
|
|
116
|
-
sealPairPackageBody(hosts: BundleHost[], opts?: PasskeyPrfOpts): Promise<ValStat<{
|
|
117
|
-
body: Uint8Array;
|
|
118
|
-
salt: Uint8Array;
|
|
119
|
-
credId: Uint8Array;
|
|
120
|
-
}>>;
|
|
121
|
-
/**
|
|
122
|
-
* UV + PRF (using envelope salt/credId), decrypt pair body, build Enclave.
|
|
123
|
-
* Also seals master under the same PRF for durable IDB (single ceremony).
|
|
124
|
-
*/
|
|
125
|
-
static openPairPackageBody(body: Uint8Array, opts: PasskeyPrfOpts & {
|
|
126
|
-
salt: Uint8Array;
|
|
127
|
-
}): Promise<ValStat<{
|
|
128
|
-
enclave: Enclave;
|
|
129
|
-
hosts: BundleHost[];
|
|
130
|
-
sealedMaster: SealedMasterKey;
|
|
131
|
-
credId: Uint8Array;
|
|
132
|
-
}>>;
|
|
112
|
+
static pairRequest(): Promise<ValStat<PairRequest>>;
|
|
113
|
+
pairAccept(dhkeReq: DHKEReq, hosts: BundleHost[]): Promise<ValStat<DHKEResp>>;
|
|
133
114
|
/**
|
|
134
115
|
* Spawn a new sync Worker from the embedded bundle and inject this enclave's
|
|
135
116
|
* master seed into it (transfer). Seed never goes to a caller-supplied port —
|
|
@@ -156,4 +137,4 @@ export declare class Enclave {
|
|
|
156
137
|
}
|
|
157
138
|
/** Derive seal key from PRF output (domain-separated). Used by enclave seal/unseal. */
|
|
158
139
|
export declare function sealKeyFromPrf(crypto: ICrypto, prf: Uint8Array, domain?: Uint8Array): Promise<ValStat<Uint8Array>>;
|
|
159
|
-
export { MASTER_SEED_LEN, SEAL_KEY_LEN,
|
|
140
|
+
export { MASTER_SEED_LEN, SEAL_KEY_LEN, SEAL_PRF_MIN_LEN, SEAL_WRAP_DOMAIN };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { type X25519Sk } from "./x25519.ts";
|
|
1
2
|
import type { DerivationSeed, Hash, ICrypto, KeyPair } from "../types.ts";
|
|
2
3
|
/**
|
|
3
|
-
* ICrypto: noble for XSalsa20 + blake3;
|
|
4
|
+
* ICrypto: noble for XSalsa20 + blake3; WebCrypto Ed25519 + X25519
|
|
5
|
+
* (our scalar; RFC 7748 check before trusting pub/DH).
|
|
4
6
|
*/
|
|
5
7
|
export declare class NobleCrypto implements ICrypto {
|
|
6
8
|
private verifyKeys;
|
|
@@ -14,4 +16,9 @@ export declare class NobleCrypto implements ICrypto {
|
|
|
14
16
|
signEd25519(message: Uint8Array | string, secKey: Uint8Array): Promise<Uint8Array>;
|
|
15
17
|
checkSigEd25519(sig: Uint8Array, message: Uint8Array | string, pubKey: Uint8Array): Promise<boolean>;
|
|
16
18
|
blake3(data: Uint8Array): Promise<Hash>;
|
|
19
|
+
genX25519(): Promise<{
|
|
20
|
+
priv: X25519Sk;
|
|
21
|
+
pub: Uint8Array;
|
|
22
|
+
}>;
|
|
23
|
+
x25519Shared(priv: X25519Sk, peerPub: Uint8Array): Promise<Uint8Array>;
|
|
17
24
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { BundleHost } from "../codecs/bundleHost.ts";
|
|
2
|
+
import { type ValStat } from "../valstat.ts";
|
|
3
|
+
import { Enclave } from "./enclave.ts";
|
|
4
|
+
import type { X25519Sk } from "./x25519.ts";
|
|
5
|
+
export declare const SEAL_PAIR_DOMAIN: Uint8Array<ArrayBufferLike>;
|
|
6
|
+
export declare const X25519_PUB_LEN = 32;
|
|
7
|
+
/** respPub (32) ‖ XSalsa nonce (24) ‖ tag (16); plaintext follows in the ct. */
|
|
8
|
+
export declare const DHKE_RESP_MIN: number;
|
|
9
|
+
declare const dhkeReqSymbol: unique symbol;
|
|
10
|
+
declare const dhkeRespSymbol: unique symbol;
|
|
11
|
+
export type DHKEReq = Uint8Array & {
|
|
12
|
+
readonly [dhkeReqSymbol]: true;
|
|
13
|
+
};
|
|
14
|
+
export type DHKEResp = Uint8Array & {
|
|
15
|
+
readonly [dhkeRespSymbol]: true;
|
|
16
|
+
};
|
|
17
|
+
export declare function asDHKEReq(bytes: Uint8Array): ValStat<DHKEReq>;
|
|
18
|
+
export declare function asDHKEResp(bytes: Uint8Array): ValStat<DHKEResp>;
|
|
19
|
+
export declare function pairKey(sk: X25519Sk, // local X25519 priv
|
|
20
|
+
peer: Uint8Array, // ECDH peer pub (enroller: dhkeReq; enrollee: respPub)
|
|
21
|
+
reqPub: Uint8Array, // enrollee pub, bound into KDF
|
|
22
|
+
respPub: Uint8Array): Promise<ValStat<Uint8Array>>;
|
|
23
|
+
export declare class PairRequest {
|
|
24
|
+
#private;
|
|
25
|
+
private constructor();
|
|
26
|
+
static create(): Promise<ValStat<PairRequest>>;
|
|
27
|
+
wipe(): void;
|
|
28
|
+
get dhkeReq(): DHKEReq;
|
|
29
|
+
finish(dhkeResp: DHKEResp): Promise<ValStat<{
|
|
30
|
+
enclave: Enclave;
|
|
31
|
+
hosts: BundleHost[];
|
|
32
|
+
}>>;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ValStat } from "../valstat.ts";
|
|
2
|
+
export declare const X25519_SK_LEN = 32;
|
|
3
|
+
declare const x25519SkSymbol: unique symbol;
|
|
4
|
+
export type X25519Sk = Uint8Array & {
|
|
5
|
+
readonly [x25519SkSymbol]: true;
|
|
6
|
+
};
|
|
7
|
+
export declare function asX25519Sk(bytes: Uint8Array): ValStat<X25519Sk>;
|
|
8
|
+
export declare function x25519(sk: X25519Sk, u: Uint8Array): Uint8Array;
|
|
9
|
+
export declare function x25519Pub(sk: X25519Sk): Uint8Array;
|
|
10
|
+
export {};
|