@tideorg/js 0.13.19
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 +333 -0
- package/README.md +12 -0
- package/dist/Clients/ClientBase.d.ts +24 -0
- package/dist/Clients/ClientBase.d.ts.map +1 -0
- package/dist/Clients/ClientBase.js +160 -0
- package/dist/Clients/NetworkClient.d.ts +11 -0
- package/dist/Clients/NetworkClient.d.ts.map +1 -0
- package/dist/Clients/NetworkClient.js +68 -0
- package/dist/Clients/NodeClient.d.ts +34 -0
- package/dist/Clients/NodeClient.d.ts.map +1 -0
- package/dist/Clients/NodeClient.js +191 -0
- package/dist/Clients/VoucherClient.d.ts +8 -0
- package/dist/Clients/VoucherClient.d.ts.map +1 -0
- package/dist/Clients/VoucherClient.js +36 -0
- package/dist/Clients/index.d.ts +5 -0
- package/dist/Clients/index.d.ts.map +1 -0
- package/dist/Clients/index.js +20 -0
- package/dist/Contracts/BaseContract.d.ts +47 -0
- package/dist/Contracts/BaseContract.d.ts.map +1 -0
- package/dist/Contracts/BaseContract.js +153 -0
- package/dist/Contracts/GenericRealmAccessThresholdRoleContract.d.ts +8 -0
- package/dist/Contracts/GenericRealmAccessThresholdRoleContract.d.ts.map +1 -0
- package/dist/Contracts/GenericRealmAccessThresholdRoleContract.js +21 -0
- package/dist/Contracts/GenericResourceAccessThresholdRoleContract.d.ts +8 -0
- package/dist/Contracts/GenericResourceAccessThresholdRoleContract.d.ts.map +1 -0
- package/dist/Contracts/GenericResourceAccessThresholdRoleContract.js +21 -0
- package/dist/Contracts/index.d.ts +4 -0
- package/dist/Contracts/index.d.ts.map +1 -0
- package/dist/Contracts/index.js +19 -0
- package/dist/Cryptide/Components/BaseComponent.d.ts +56 -0
- package/dist/Cryptide/Components/BaseComponent.d.ts.map +1 -0
- package/dist/Cryptide/Components/BaseComponent.js +176 -0
- package/dist/Cryptide/Components/ComponentRegistry.d.ts +18 -0
- package/dist/Cryptide/Components/ComponentRegistry.d.ts.map +1 -0
- package/dist/Cryptide/Components/ComponentRegistry.js +39 -0
- package/dist/Cryptide/Components/Schemes/AES/AESScheme.d.ts +5 -0
- package/dist/Cryptide/Components/Schemes/AES/AESScheme.d.ts.map +1 -0
- package/dist/Cryptide/Components/Schemes/AES/AESScheme.js +20 -0
- package/dist/Cryptide/Components/Schemes/AES/index.d.ts +2 -0
- package/dist/Cryptide/Components/Schemes/AES/index.d.ts.map +1 -0
- package/dist/Cryptide/Components/Schemes/AES/index.js +17 -0
- package/dist/Cryptide/Components/Schemes/BaseScheme.d.ts +7 -0
- package/dist/Cryptide/Components/Schemes/BaseScheme.d.ts.map +1 -0
- package/dist/Cryptide/Components/Schemes/BaseScheme.js +23 -0
- package/dist/Cryptide/Components/Schemes/Ed25519/Ed25519Components.d.ts +52 -0
- package/dist/Cryptide/Components/Schemes/Ed25519/Ed25519Components.d.ts.map +1 -0
- package/dist/Cryptide/Components/Schemes/Ed25519/Ed25519Components.js +171 -0
- package/dist/Cryptide/Components/Schemes/Ed25519/Ed25519Scheme.d.ts +13 -0
- package/dist/Cryptide/Components/Schemes/Ed25519/Ed25519Scheme.d.ts.map +1 -0
- package/dist/Cryptide/Components/Schemes/Ed25519/Ed25519Scheme.js +71 -0
- package/dist/Cryptide/Components/Schemes/Ed25519/index.d.ts +3 -0
- package/dist/Cryptide/Components/Schemes/Ed25519/index.d.ts.map +1 -0
- package/dist/Cryptide/Components/Schemes/Ed25519/index.js +18 -0
- package/dist/Cryptide/Components/Schemes/SchemeRegistry.d.ts +3 -0
- package/dist/Cryptide/Components/Schemes/SchemeRegistry.d.ts.map +1 -0
- package/dist/Cryptide/Components/Schemes/SchemeRegistry.js +22 -0
- package/dist/Cryptide/Components/Schemes/index.d.ts +5 -0
- package/dist/Cryptide/Components/Schemes/index.d.ts.map +1 -0
- package/dist/Cryptide/Components/Schemes/index.js +20 -0
- package/dist/Cryptide/Components/index.d.ts +4 -0
- package/dist/Cryptide/Components/index.d.ts.map +1 -0
- package/dist/Cryptide/Components/index.js +19 -0
- package/dist/Cryptide/Ed25519.d.ts +106 -0
- package/dist/Cryptide/Ed25519.d.ts.map +1 -0
- package/dist/Cryptide/Ed25519.js +522 -0
- package/dist/Cryptide/Encryption/AES.d.ts +6 -0
- package/dist/Cryptide/Encryption/AES.d.ts.map +1 -0
- package/dist/Cryptide/Encryption/AES.js +76 -0
- package/dist/Cryptide/Encryption/DH.d.ts +4 -0
- package/dist/Cryptide/Encryption/DH.d.ts.map +1 -0
- package/dist/Cryptide/Encryption/DH.js +38 -0
- package/dist/Cryptide/Encryption/ElGamal.d.ts +12 -0
- package/dist/Cryptide/Encryption/ElGamal.d.ts.map +1 -0
- package/dist/Cryptide/Encryption/ElGamal.js +61 -0
- package/dist/Cryptide/Encryption/index.d.ts +4 -0
- package/dist/Cryptide/Encryption/index.d.ts.map +1 -0
- package/dist/Cryptide/Encryption/index.js +19 -0
- package/dist/Cryptide/Hashing/H2P.d.ts +6 -0
- package/dist/Cryptide/Hashing/H2P.d.ts.map +1 -0
- package/dist/Cryptide/Hashing/H2P.js +235 -0
- package/dist/Cryptide/Hashing/Hash.d.ts +8 -0
- package/dist/Cryptide/Hashing/Hash.d.ts.map +1 -0
- package/dist/Cryptide/Hashing/Hash.js +43 -0
- package/dist/Cryptide/Hashing/index.d.ts +3 -0
- package/dist/Cryptide/Hashing/index.d.ts.map +1 -0
- package/dist/Cryptide/Hashing/index.js +18 -0
- package/dist/Cryptide/Interpolation.d.ts +20 -0
- package/dist/Cryptide/Interpolation.d.ts.map +1 -0
- package/dist/Cryptide/Interpolation.js +68 -0
- package/dist/Cryptide/Math.d.ts +11 -0
- package/dist/Cryptide/Math.d.ts.map +1 -0
- package/dist/Cryptide/Math.js +81 -0
- package/dist/Cryptide/Serialization.d.ts +66 -0
- package/dist/Cryptide/Serialization.d.ts.map +1 -0
- package/dist/Cryptide/Serialization.js +517 -0
- package/dist/Cryptide/Signing/BlindSig.d.ts +10 -0
- package/dist/Cryptide/Signing/BlindSig.d.ts.map +1 -0
- package/dist/Cryptide/Signing/BlindSig.js +41 -0
- package/dist/Cryptide/Signing/EdDSA.d.ts +14 -0
- package/dist/Cryptide/Signing/EdDSA.d.ts.map +1 -0
- package/dist/Cryptide/Signing/EdDSA.js +67 -0
- package/dist/Cryptide/Signing/TideSignature.d.ts +54 -0
- package/dist/Cryptide/Signing/TideSignature.d.ts.map +1 -0
- package/dist/Cryptide/Signing/TideSignature.js +110 -0
- package/dist/Cryptide/Signing/index.d.ts +4 -0
- package/dist/Cryptide/Signing/index.d.ts.map +1 -0
- package/dist/Cryptide/Signing/index.js +19 -0
- package/dist/Cryptide/TideKey.d.ts +17 -0
- package/dist/Cryptide/TideKey.d.ts.map +1 -0
- package/dist/Cryptide/TideKey.js +84 -0
- package/dist/Cryptide/TideMemoryObjects.d.ts +4 -0
- package/dist/Cryptide/TideMemoryObjects.d.ts.map +1 -0
- package/dist/Cryptide/TideMemoryObjects.js +32 -0
- package/dist/Cryptide/index.d.ts +11 -0
- package/dist/Cryptide/index.d.ts.map +1 -0
- package/dist/Cryptide/index.js +28 -0
- package/dist/Flow/DecryptionFlows/dVVKDecryptionFlow.d.ts +16 -0
- package/dist/Flow/DecryptionFlows/dVVKDecryptionFlow.d.ts.map +1 -0
- package/dist/Flow/DecryptionFlows/dVVKDecryptionFlow.js +47 -0
- package/dist/Flow/DecryptionFlows/index.d.ts +2 -0
- package/dist/Flow/DecryptionFlows/index.d.ts.map +1 -0
- package/dist/Flow/DecryptionFlows/index.js +17 -0
- package/dist/Flow/EncryptionFlows/AuthorizedEncryptionFlow.d.ts +13 -0
- package/dist/Flow/EncryptionFlows/AuthorizedEncryptionFlow.d.ts.map +1 -0
- package/dist/Flow/EncryptionFlows/AuthorizedEncryptionFlow.js +183 -0
- package/dist/Flow/EncryptionFlows/PolicyAuthorizedEncryptionFlow.d.ts +57 -0
- package/dist/Flow/EncryptionFlows/PolicyAuthorizedEncryptionFlow.d.ts.map +1 -0
- package/dist/Flow/EncryptionFlows/PolicyAuthorizedEncryptionFlow.js +220 -0
- package/dist/Flow/EncryptionFlows/index.d.ts +3 -0
- package/dist/Flow/EncryptionFlows/index.d.ts.map +1 -0
- package/dist/Flow/EncryptionFlows/index.js +18 -0
- package/dist/Flow/SigningFlows/AuthorizedSigningFlow.d.ts +12 -0
- package/dist/Flow/SigningFlows/AuthorizedSigningFlow.d.ts.map +1 -0
- package/dist/Flow/SigningFlows/AuthorizedSigningFlow.js +50 -0
- package/dist/Flow/SigningFlows/dTestVVkSigningFlow.d.ts +15 -0
- package/dist/Flow/SigningFlows/dTestVVkSigningFlow.d.ts.map +1 -0
- package/dist/Flow/SigningFlows/dTestVVkSigningFlow.js +67 -0
- package/dist/Flow/SigningFlows/dVVKSigningFlow.d.ts +17 -0
- package/dist/Flow/SigningFlows/dVVKSigningFlow.d.ts.map +1 -0
- package/dist/Flow/SigningFlows/dVVKSigningFlow.js +61 -0
- package/dist/Flow/SigningFlows/dVVKSigningFlow2Step.d.ts +28 -0
- package/dist/Flow/SigningFlows/dVVKSigningFlow2Step.d.ts.map +1 -0
- package/dist/Flow/SigningFlows/dVVKSigningFlow2Step.js +118 -0
- package/dist/Flow/SigningFlows/index.d.ts +5 -0
- package/dist/Flow/SigningFlows/index.d.ts.map +1 -0
- package/dist/Flow/SigningFlows/index.js +20 -0
- package/dist/Flow/VoucherFlows/VoucherFlow.d.ts +16 -0
- package/dist/Flow/VoucherFlows/VoucherFlow.d.ts.map +1 -0
- package/dist/Flow/VoucherFlows/VoucherFlow.js +34 -0
- package/dist/Flow/VoucherFlows/index.d.ts +2 -0
- package/dist/Flow/VoucherFlows/index.d.ts.map +1 -0
- package/dist/Flow/VoucherFlows/index.js +17 -0
- package/dist/Flow/index.d.ts +5 -0
- package/dist/Flow/index.d.ts.map +1 -0
- package/dist/Flow/index.js +20 -0
- package/dist/Math/KeyDecryption.d.ts +3 -0
- package/dist/Math/KeyDecryption.d.ts.map +1 -0
- package/dist/Math/KeyDecryption.js +24 -0
- package/dist/Math/KeySigning.d.ts +4 -0
- package/dist/Math/KeySigning.d.ts.map +1 -0
- package/dist/Math/KeySigning.js +28 -0
- package/dist/Math/index.d.ts +3 -0
- package/dist/Math/index.d.ts.map +1 -0
- package/dist/Math/index.js +18 -0
- package/dist/Models/AuthRequest.d.ts +13 -0
- package/dist/Models/AuthRequest.d.ts.map +1 -0
- package/dist/Models/AuthRequest.js +46 -0
- package/dist/Models/BaseTideRequest.d.ts +55 -0
- package/dist/Models/BaseTideRequest.d.ts.map +1 -0
- package/dist/Models/BaseTideRequest.js +299 -0
- package/dist/Models/CustomTideRequest.d.ts +19 -0
- package/dist/Models/CustomTideRequest.d.ts.map +1 -0
- package/dist/Models/CustomTideRequest.js +30 -0
- package/dist/Models/Datum.d.ts +11 -0
- package/dist/Models/Datum.d.ts.map +1 -0
- package/dist/Models/Datum.js +33 -0
- package/dist/Models/Doken.d.ts +33 -0
- package/dist/Models/Doken.d.ts.map +1 -0
- package/dist/Models/Doken.js +133 -0
- package/dist/Models/EnclaveEntry.d.ts +14 -0
- package/dist/Models/EnclaveEntry.d.ts.map +1 -0
- package/dist/Models/EnclaveEntry.js +49 -0
- package/dist/Models/Infos/KeyInfo.d.ts +24 -0
- package/dist/Models/Infos/KeyInfo.d.ts.map +1 -0
- package/dist/Models/Infos/KeyInfo.js +51 -0
- package/dist/Models/Infos/OrkInfo.d.ts +18 -0
- package/dist/Models/Infos/OrkInfo.d.ts.map +1 -0
- package/dist/Models/Infos/OrkInfo.js +58 -0
- package/dist/Models/Infos/index.d.ts +3 -0
- package/dist/Models/Infos/index.d.ts.map +1 -0
- package/dist/Models/Infos/index.js +18 -0
- package/dist/Models/ModelRegistry.d.ts +29 -0
- package/dist/Models/ModelRegistry.d.ts.map +1 -0
- package/dist/Models/ModelRegistry.js +321 -0
- package/dist/Models/Policy.d.ts +41 -0
- package/dist/Models/Policy.d.ts.map +1 -0
- package/dist/Models/Policy.js +317 -0
- package/dist/Models/PolicyProtectedSerializedField.d.ts +12 -0
- package/dist/Models/PolicyProtectedSerializedField.d.ts.map +1 -0
- package/dist/Models/PolicyProtectedSerializedField.js +50 -0
- package/dist/Models/Responses/Vendor/VoucherResponse.d.ts +12 -0
- package/dist/Models/Responses/Vendor/VoucherResponse.d.ts.map +1 -0
- package/dist/Models/Responses/Vendor/VoucherResponse.js +39 -0
- package/dist/Models/Responses/Vendor/index.d.ts +2 -0
- package/dist/Models/Responses/Vendor/index.d.ts.map +1 -0
- package/dist/Models/Responses/Vendor/index.js +17 -0
- package/dist/Models/Responses/index.d.ts +2 -0
- package/dist/Models/Responses/index.d.ts.map +1 -0
- package/dist/Models/Responses/index.js +17 -0
- package/dist/Models/SerializedField.d.ts +12 -0
- package/dist/Models/SerializedField.d.ts.map +1 -0
- package/dist/Models/SerializedField.js +50 -0
- package/dist/Models/VendorData.d.ts +12 -0
- package/dist/Models/VendorData.d.ts.map +1 -0
- package/dist/Models/VendorData.js +38 -0
- package/dist/Models/VendorSettings.d.ts +9 -0
- package/dist/Models/VendorSettings.d.ts.map +1 -0
- package/dist/Models/VendorSettings.js +32 -0
- package/dist/Models/index.d.ts +13 -0
- package/dist/Models/index.d.ts.map +1 -0
- package/dist/Models/index.js +30 -0
- package/dist/Tools/TideMemory.d.ts +10 -0
- package/dist/Tools/TideMemory.d.ts.map +1 -0
- package/dist/Tools/TideMemory.js +105 -0
- package/dist/Tools/Utils.d.ts +13 -0
- package/dist/Tools/Utils.d.ts.map +1 -0
- package/dist/Tools/Utils.js +242 -0
- package/dist/Tools/index.d.ts +3 -0
- package/dist/Tools/index.d.ts.map +1 -0
- package/dist/Tools/index.js +18 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/package.json +27 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Tide Protocol - Infrastructure for a TRUE Zero-Trust paradigm
|
|
3
|
+
// Copyright (C) 2022 Tide Foundation Ltd
|
|
4
|
+
//
|
|
5
|
+
// This program is free software and is subject to the terms of
|
|
6
|
+
// the Tide Community Open Code License as published by the
|
|
7
|
+
// Tide Foundation Limited. You may modify it and redistribute
|
|
8
|
+
// it in accordance with and subject to the terms of that License.
|
|
9
|
+
// This program is distributed WITHOUT WARRANTY of any kind,
|
|
10
|
+
// including without any implied warranty of MERCHANTABILITY or
|
|
11
|
+
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
12
|
+
// See the Tide Community Open Code License for more details.
|
|
13
|
+
// You should have received a copy of the Tide Community Open
|
|
14
|
+
// Code License along with this program.
|
|
15
|
+
// If not, see https://tide.org/licenses_tcoc2-0-0-en
|
|
16
|
+
//
|
|
17
|
+
import { Point, CURVE } from "../Ed25519";
|
|
18
|
+
import { SHA512_Digest } from "../Hashing/Hash";
|
|
19
|
+
import { RandomBigInt, mod } from "../Math";
|
|
20
|
+
import { base64ToBytes, BigIntFromByteArray, BigIntToByteArray, bytesToBase64, ConcatUint8Arrays, StringToUint8Array } from "../Serialization";
|
|
21
|
+
/**
|
|
22
|
+
* Sign the msg with a private key in non-standard way as it uses a random number generator. Non-deterministic.
|
|
23
|
+
*/
|
|
24
|
+
export async function sign(msg, priv) {
|
|
25
|
+
if (typeof (msg) == 'string') {
|
|
26
|
+
msg = StringToUint8Array(msg);
|
|
27
|
+
}
|
|
28
|
+
const A = Point.BASE.mul(priv).toRawBytes();
|
|
29
|
+
const r = RandomBigInt();
|
|
30
|
+
const R = Point.BASE.mul(r).toRawBytes();
|
|
31
|
+
const to_hash2 = ConcatUint8Arrays([R, A, msg]);
|
|
32
|
+
const k = mod(BigIntFromByteArray(await SHA512_Digest(to_hash2)));
|
|
33
|
+
const S = mod(r + (k * priv));
|
|
34
|
+
const sig_bytes = ConcatUint8Arrays([R, BigIntToByteArray(S)]);
|
|
35
|
+
return bytesToBase64(sig_bytes);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Verify a EdDSA signature, given a signature, public key and message.
|
|
39
|
+
*/
|
|
40
|
+
export async function verify(sig, pub, msg) {
|
|
41
|
+
try {
|
|
42
|
+
if (typeof (msg) == 'string') {
|
|
43
|
+
msg = StringToUint8Array(msg);
|
|
44
|
+
}
|
|
45
|
+
const sig_bytes = base64ToBytes(sig);
|
|
46
|
+
if (sig_bytes.length != 64)
|
|
47
|
+
return false;
|
|
48
|
+
const R = Point.fromBytes(sig_bytes.slice(0, 32));
|
|
49
|
+
const S = BigIntFromByteArray(sig_bytes.slice(-32));
|
|
50
|
+
const A = typeof (pub) === 'string' ? Point.fromBase64(pub) : pub;
|
|
51
|
+
return await verifyRaw(S, R, A, msg);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return false; // very strict indeed
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Verify a message with raw S and R
|
|
59
|
+
*/
|
|
60
|
+
export async function verifyRaw(S, R, A, M) {
|
|
61
|
+
if (S < BigInt(0) || S >= CURVE.n) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
const to_hash = ConcatUint8Arrays([R.toRawBytes(), A.toRawBytes(), M]);
|
|
65
|
+
const k = mod(BigIntFromByteArray(await SHA512_Digest(to_hash)));
|
|
66
|
+
return Point.BASE.mul(S).mul(BigInt(8)).equals(R.mul(BigInt(8)).add(A.mul(k).mul(BigInt(8))));
|
|
67
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export declare class TideSignatureFormat {
|
|
2
|
+
Name: string;
|
|
3
|
+
Version: string;
|
|
4
|
+
Message: Uint8Array;
|
|
5
|
+
Header: () => string;
|
|
6
|
+
Footer: () => string;
|
|
7
|
+
constructor(message: string | Uint8Array);
|
|
8
|
+
format(): Uint8Array;
|
|
9
|
+
}
|
|
10
|
+
export declare class PolicyAuthorizedTideRequestSignatureFormat extends TideSignatureFormat {
|
|
11
|
+
Name: string;
|
|
12
|
+
Version: string;
|
|
13
|
+
constructor(issueTimeBytes: any, exp: bigint | number, modelId: any, draftHash: any);
|
|
14
|
+
}
|
|
15
|
+
export declare class URLSignatureFormat extends TideSignatureFormat {
|
|
16
|
+
Name: string;
|
|
17
|
+
Version: string;
|
|
18
|
+
constructor(message: any);
|
|
19
|
+
}
|
|
20
|
+
export declare class ClientURLSignatureFormat extends TideSignatureFormat {
|
|
21
|
+
Name: string;
|
|
22
|
+
Version: string;
|
|
23
|
+
constructor(message: any);
|
|
24
|
+
}
|
|
25
|
+
export declare class PublicKeySignatureFormat extends TideSignatureFormat {
|
|
26
|
+
Name: string;
|
|
27
|
+
Version: string;
|
|
28
|
+
constructor(message: any);
|
|
29
|
+
}
|
|
30
|
+
export declare class AuthorizerSignatureFormat extends TideSignatureFormat {
|
|
31
|
+
Name: string;
|
|
32
|
+
Version: string;
|
|
33
|
+
constructor(authflow: any, modelIds: any, authorizer: any);
|
|
34
|
+
format(): Uint8Array<ArrayBuffer>;
|
|
35
|
+
}
|
|
36
|
+
export declare class TidecloakSettingsSignatureFormat extends TideSignatureFormat {
|
|
37
|
+
Name: string;
|
|
38
|
+
Version: string;
|
|
39
|
+
constructor(message: any);
|
|
40
|
+
}
|
|
41
|
+
export declare class TestSignatureFormat extends TideSignatureFormat {
|
|
42
|
+
Name: string;
|
|
43
|
+
Version: string;
|
|
44
|
+
constructor(message: any);
|
|
45
|
+
}
|
|
46
|
+
export declare class PlainSignatureFormat extends TideSignatureFormat {
|
|
47
|
+
/**
|
|
48
|
+
* WARNING: Only use this class if you are SURE that the data you are signing is ALREADY serialized in some form.
|
|
49
|
+
* @param {string|Uint8Array} message
|
|
50
|
+
*/
|
|
51
|
+
constructor(message: any);
|
|
52
|
+
format(): Uint8Array<ArrayBuffer>;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=TideSignature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TideSignature.d.ts","sourceRoot":"","sources":["../../../Cryptide/Signing/TideSignature.ts"],"names":[],"mappings":"AAoBA,qBAAa,mBAAmB;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,UAAU,CAAC;IACpB,MAAM,eAAyE;IAC/E,MAAM,eAAuE;gBAEjE,OAAO,EAAE,MAAM,GAAG,UAAU;IAOxC,MAAM,IAAI,UAAU;CAGvB;AAED,qBAAa,0CAA2C,SAAQ,mBAAmB;IAElF,IAAI,SAAiC;IACrC,OAAO,SAAO;gBACC,cAAc,KAAA,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,OAAO,KAAA,EAAE,SAAS,KAAA;CAQvE;AAED,qBAAa,kBAAmB,SAAQ,mBAAmB;IACvD,IAAI,SAAS;IACb,OAAO,SAAO;gBACF,OAAO,KAAA;CAGtB;AACD,qBAAa,wBAAyB,SAAQ,mBAAmB;IAC7D,IAAI,SAAe;IACnB,OAAO,SAAO;gBACF,OAAO,KAAA;CAGtB;AAED,qBAAa,wBAAyB,SAAQ,mBAAmB;IAC7D,IAAI,SAAe;IACnB,OAAO,SAAO;gBACF,OAAO,KAAA;CAGtB;AAED,qBAAa,yBAA0B,SAAQ,mBAAmB;IAC9D,IAAI,SAAgB;IACpB,OAAO,SAAO;gBACF,QAAQ,KAAA,EAAE,QAAQ,KAAA,EAAE,UAAU,KAAA;IAY1C,MAAM;CAGT;AAED,qBAAa,gCAAiC,SAAQ,mBAAmB;IACrE,IAAI,SAAuB;IAC3B,OAAO,SAAO;gBACF,OAAO,KAAA;CAGtB;AAED,qBAAa,mBAAoB,SAAQ,mBAAmB;IACxD,IAAI,SAAiB;IACrB,OAAO,SAAO;gBACF,OAAO,KAAA;CAGtB;AAED,qBAAa,oBAAqB,SAAQ,mBAAmB;IACzD;;;OAGG;gBACS,OAAO,KAAA;IAGnB,MAAM;CAGT"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Tide Protocol - Infrastructure for a TRUE Zero-Trust paradigm
|
|
3
|
+
// Copyright (C) 2022 Tide Foundation Ltd
|
|
4
|
+
//
|
|
5
|
+
// This program is free software and is subject to the terms of
|
|
6
|
+
// the Tide Community Open Code License as published by the
|
|
7
|
+
// Tide Foundation Limited. You may modify it and redistribute
|
|
8
|
+
// it in accordance with and subject to the terms of that License.
|
|
9
|
+
// This program is distributed WITHOUT WARRANTY of any kind,
|
|
10
|
+
// including without any implied warranty of MERCHANTABILITY or
|
|
11
|
+
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
12
|
+
// See the Tide Community Open Code License for more details.
|
|
13
|
+
// You should have received a copy of the Tide Community Open
|
|
14
|
+
// Code License along with this program.
|
|
15
|
+
// If not, see https://tide.org/licenses_tcoc2-0-0-en
|
|
16
|
+
//
|
|
17
|
+
import { Serialization } from "../index";
|
|
18
|
+
import { ConcatUint8Arrays, StringToUint8Array } from "../Serialization";
|
|
19
|
+
export class TideSignatureFormat {
|
|
20
|
+
constructor(message) {
|
|
21
|
+
this.Header = () => "=====TIDE_" + this.Name + ":" + this.Version + "_START=====\n";
|
|
22
|
+
this.Footer = () => "\n=====TIDE_" + this.Name + ":" + this.Version + "_END=====";
|
|
23
|
+
if (typeof (message) == 'string') {
|
|
24
|
+
this.Message = StringToUint8Array(message);
|
|
25
|
+
}
|
|
26
|
+
else if (message instanceof Uint8Array) {
|
|
27
|
+
this.Message = message.slice();
|
|
28
|
+
}
|
|
29
|
+
else
|
|
30
|
+
throw Error("Unknown type provided");
|
|
31
|
+
}
|
|
32
|
+
format() {
|
|
33
|
+
return ConcatUint8Arrays([StringToUint8Array(this.Header()), this.Message, StringToUint8Array(this.Footer())]);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export class PolicyAuthorizedTideRequestSignatureFormat extends TideSignatureFormat {
|
|
37
|
+
constructor(issueTimeBytes, exp, modelId, draftHash) {
|
|
38
|
+
const expiry = new Uint8Array(8);
|
|
39
|
+
const expiry_view = new DataView(expiry.buffer);
|
|
40
|
+
expiry_view.setBigInt64(0, typeof exp === "number" ? BigInt(exp) : exp, true);
|
|
41
|
+
const message = Serialization.ConcatUint8Arrays([issueTimeBytes, expiry, StringToUint8Array(modelId), draftHash]);
|
|
42
|
+
super(message);
|
|
43
|
+
this.Name = "PolicyAuthorizedTideRequest";
|
|
44
|
+
this.Version = "1";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export class URLSignatureFormat extends TideSignatureFormat {
|
|
48
|
+
constructor(message) {
|
|
49
|
+
super(message);
|
|
50
|
+
this.Name = "URL";
|
|
51
|
+
this.Version = "1";
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export class ClientURLSignatureFormat extends TideSignatureFormat {
|
|
55
|
+
constructor(message) {
|
|
56
|
+
super(message);
|
|
57
|
+
this.Name = "ClientURL";
|
|
58
|
+
this.Version = "1";
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export class PublicKeySignatureFormat extends TideSignatureFormat {
|
|
62
|
+
constructor(message) {
|
|
63
|
+
super(message);
|
|
64
|
+
this.Name = "PublicKey";
|
|
65
|
+
this.Version = "1";
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export class AuthorizerSignatureFormat extends TideSignatureFormat {
|
|
69
|
+
constructor(authflow, modelIds, authorizer) {
|
|
70
|
+
const authflow_b = StringToUint8Array(authflow);
|
|
71
|
+
const models_b = modelIds.map(k => StringToUint8Array(k));
|
|
72
|
+
const authorizer_pack = Serialization.CreateTideMemory(authflow_b, 8 + (4 * models_b.length) + authflow_b.length + models_b.reduce((sum, next) => sum + next.length, 0) + authorizer.length);
|
|
73
|
+
Serialization.WriteValue(authorizer_pack, 1, authorizer);
|
|
74
|
+
models_b.forEach((model, i) => {
|
|
75
|
+
Serialization.WriteValue(authorizer_pack, i + 2, model);
|
|
76
|
+
});
|
|
77
|
+
super(authorizer_pack);
|
|
78
|
+
this.Name = "Authorizer";
|
|
79
|
+
this.Version = "1";
|
|
80
|
+
}
|
|
81
|
+
format() {
|
|
82
|
+
return this.Message.slice();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
export class TidecloakSettingsSignatureFormat extends TideSignatureFormat {
|
|
86
|
+
constructor(message) {
|
|
87
|
+
super(message);
|
|
88
|
+
this.Name = "TidecloakSettings";
|
|
89
|
+
this.Version = "1";
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export class TestSignatureFormat extends TideSignatureFormat {
|
|
93
|
+
constructor(message) {
|
|
94
|
+
super(message);
|
|
95
|
+
this.Name = "TestMessage";
|
|
96
|
+
this.Version = "1";
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
export class PlainSignatureFormat extends TideSignatureFormat {
|
|
100
|
+
/**
|
|
101
|
+
* WARNING: Only use this class if you are SURE that the data you are signing is ALREADY serialized in some form.
|
|
102
|
+
* @param {string|Uint8Array} message
|
|
103
|
+
*/
|
|
104
|
+
constructor(message) {
|
|
105
|
+
super(message);
|
|
106
|
+
}
|
|
107
|
+
format() {
|
|
108
|
+
return this.Message.slice();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../Cryptide/Signing/index.ts"],"names":[],"mappings":"AAiBA,cAAc,iBAAiB,CAAC;AAChC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Tide Protocol - Infrastructure for a TRUE Zero-Trust paradigm
|
|
3
|
+
// Copyright (C) 2022 Tide Foundation Ltd
|
|
4
|
+
//
|
|
5
|
+
// This program is free software and is subject to the terms of
|
|
6
|
+
// the Tide Community Open Code License as published by the
|
|
7
|
+
// Tide Foundation Limited. You may modify it and redistribute
|
|
8
|
+
// it in accordance with and subject to the terms of that License.
|
|
9
|
+
// This program is distributed WITHOUT WARRANTY of any kind,
|
|
10
|
+
// including without any implied warranty of MERCHANTABILITY or
|
|
11
|
+
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
12
|
+
// See the Tide Community Open Code License for more details.
|
|
13
|
+
// You should have received a copy of the Tide Community Open
|
|
14
|
+
// Code License along with this program.
|
|
15
|
+
// If not, see https://tide.org/licenses_tcoc2-0-0-en
|
|
16
|
+
//
|
|
17
|
+
export * from './TideSignature';
|
|
18
|
+
export * as EdDSA from './EdDSA';
|
|
19
|
+
export * as BlindSig from './BlindSig';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BaseComponent, BasePrivateComponent, BasePublicComponent } from "./Components/BaseComponent";
|
|
2
|
+
export default class TideKey {
|
|
3
|
+
static NewKey(scheme: any): TideKey;
|
|
4
|
+
static FromSerializedComponent(c: Uint8Array | string): TideKey;
|
|
5
|
+
component: BaseComponent;
|
|
6
|
+
privateComponent: BasePrivateComponent;
|
|
7
|
+
publicComponent: BasePublicComponent;
|
|
8
|
+
constructor(c: BaseComponent);
|
|
9
|
+
get_private_component(): BasePrivateComponent;
|
|
10
|
+
get_public_component(): BasePublicComponent;
|
|
11
|
+
sign(message: any): Promise<any>;
|
|
12
|
+
verify(message: any, signature: any): Promise<any>;
|
|
13
|
+
asymmetricDecrypt(cipher: any): Promise<any>;
|
|
14
|
+
asymmetricEncrypt(message: any): Promise<any>;
|
|
15
|
+
prepVouchersReq(gORKn: any): Promise<any[]>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=TideKey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TideKey.d.ts","sourceRoot":"","sources":["../../Cryptide/TideKey.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,mBAAmB,EAAQ,MAAM,4BAA4B,CAAC;AAU5G,MAAM,CAAC,OAAO,OAAO,OAAO;IAExB,MAAM,CAAC,MAAM,CAAC,MAAM,KAAA;IAKpB,MAAM,CAAC,uBAAuB,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM;IAIrD,SAAS,EAAE,aAAa,CAAa;IACrC,gBAAgB,EAAE,oBAAoB,CAAC;IACvC,eAAe,EAAE,mBAAmB,CAAC;gBAEzB,CAAC,EAAE,aAAa;IAI5B,qBAAqB,IAAI,oBAAoB;IAK7C,oBAAoB,IAAI,mBAAmB;IAMrC,IAAI,CAAC,OAAO,KAAA;IAIZ,MAAM,CAAC,OAAO,KAAA,EAAE,SAAS,KAAA;IAIzB,iBAAiB,CAAC,MAAM,KAAA;IAIxB,iBAAiB,CAAC,OAAO,KAAA;IAMzB,eAAe,CAAC,KAAK,KAAA;CAU9B"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Tide Protocol - Infrastructure for a TRUE Zero-Trust paradigm
|
|
3
|
+
// Copyright (C) 2022 Tide Foundation Ltd
|
|
4
|
+
//
|
|
5
|
+
// This program is free software and is subject to the terms of
|
|
6
|
+
// the Tide Community Open Code License as published by the
|
|
7
|
+
// Tide Foundation Limited. You may modify it and redistribute
|
|
8
|
+
// it in accordance with and subject to the terms of that License.
|
|
9
|
+
// This program is distributed WITHOUT WARRANTY of any kind,
|
|
10
|
+
// including without any implied warranty of MERCHANTABILITY or
|
|
11
|
+
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
12
|
+
// See the Tide Community Open Code License for more details.
|
|
13
|
+
// You should have received a copy of the Tide Community Open
|
|
14
|
+
// Code License along with this program.
|
|
15
|
+
// If not, see https://tide.org/licenses_tcoc2-0-0-en
|
|
16
|
+
//
|
|
17
|
+
import { BaseComponent, BasePrivateComponent, BasePublicComponent, Seed } from "./Components/BaseComponent";
|
|
18
|
+
import { Registery } from "./Components/ComponentRegistry";
|
|
19
|
+
import Ed25519Scheme from "./Components/Schemes/Ed25519/Ed25519Scheme";
|
|
20
|
+
import { computeSharedKey } from "./Encryption/DH";
|
|
21
|
+
import { mod } from "./Math";
|
|
22
|
+
import { BigIntFromByteArray } from "./Serialization";
|
|
23
|
+
export default class TideKey {
|
|
24
|
+
static NewKey(scheme) {
|
|
25
|
+
const seedFactory = Registery[scheme.Name][Seed];
|
|
26
|
+
return new TideKey(seedFactory.Create(undefined));
|
|
27
|
+
}
|
|
28
|
+
static FromSerializedComponent(c) {
|
|
29
|
+
return new TideKey(BaseComponent.DeserializeComponent(c));
|
|
30
|
+
}
|
|
31
|
+
constructor(c) {
|
|
32
|
+
this.component = undefined;
|
|
33
|
+
if (c instanceof BaseComponent)
|
|
34
|
+
this.component = c;
|
|
35
|
+
else
|
|
36
|
+
throw Error("Expecting object derived from BaseComponent");
|
|
37
|
+
}
|
|
38
|
+
get_private_component() {
|
|
39
|
+
if (!hasOwnInstanceMethod(this.component, "GetPrivate") && !(this.component instanceof BasePrivateComponent))
|
|
40
|
+
throw Error("Cannot generate or find private component");
|
|
41
|
+
this.privateComponent = this.component instanceof BasePrivateComponent ? this.component : this.component.GetPrivate();
|
|
42
|
+
return this.privateComponent;
|
|
43
|
+
}
|
|
44
|
+
get_public_component() {
|
|
45
|
+
if (!hasOwnInstanceMethod(this.component, "GetPublic") && !(this.component instanceof BasePublicComponent))
|
|
46
|
+
throw Error("Cannot generate or find public component");
|
|
47
|
+
this.publicComponent = this.component instanceof BasePublicComponent ? this.component : this.component.GetPublic();
|
|
48
|
+
return this.publicComponent;
|
|
49
|
+
}
|
|
50
|
+
async sign(message) {
|
|
51
|
+
const f = this.component.Scheme.GetSigningFunction();
|
|
52
|
+
return await f(message, this.get_private_component());
|
|
53
|
+
}
|
|
54
|
+
async verify(message, signature) {
|
|
55
|
+
const f = this.component.Scheme.GetVerifyingFunction();
|
|
56
|
+
return await f(message, signature, this.get_public_component());
|
|
57
|
+
}
|
|
58
|
+
async asymmetricDecrypt(cipher) {
|
|
59
|
+
const d = this.component.Scheme.GetDecryptingFunction();
|
|
60
|
+
return await d(cipher, this.get_private_component());
|
|
61
|
+
}
|
|
62
|
+
async asymmetricEncrypt(message) {
|
|
63
|
+
const e = this.component.Scheme.GetEncryptingFunction();
|
|
64
|
+
return await e(message, this.get_public_component());
|
|
65
|
+
}
|
|
66
|
+
async prepVouchersReq(gORKn) {
|
|
67
|
+
// Ensure scheme is Ed25519 for tide vouchers
|
|
68
|
+
if (this.component.Scheme !== Ed25519Scheme)
|
|
69
|
+
throw Error("Cannot execute prepVouchersReq on a non Ed25519 key");
|
|
70
|
+
let blurKeyPub = [];
|
|
71
|
+
for (let i = 0; i < gORKn.length; i++) {
|
|
72
|
+
const z = mod(BigIntFromByteArray(await computeSharedKey(gORKn[i], this.get_private_component().priv)));
|
|
73
|
+
blurKeyPub[i] = gORKn[i].mul(z);
|
|
74
|
+
}
|
|
75
|
+
return blurKeyPub;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function hasOwnInstanceMethod(obj, methodName) {
|
|
79
|
+
// get the “own” prototype of this object’s class
|
|
80
|
+
const proto = Object.getPrototypeOf(obj);
|
|
81
|
+
// check it has its own property of that name, and that it’s a function
|
|
82
|
+
return Object.prototype.hasOwnProperty.call(proto, methodName)
|
|
83
|
+
&& typeof proto[methodName] === 'function';
|
|
84
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Ed25519PublicComponent } from "./Components/Schemes/Ed25519/Ed25519Components";
|
|
2
|
+
export declare function CreateVRKPackage(gvrk: Ed25519PublicComponent, expiry: number | bigint): Uint8Array<ArrayBuffer>;
|
|
3
|
+
export declare function CreateAuthorizerPackage(authFlow: string, signModels: string[], vrk_pack: Uint8Array): Uint8Array<ArrayBuffer>;
|
|
4
|
+
//# sourceMappingURL=TideMemoryObjects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TideMemoryObjects.d.ts","sourceRoot":"","sources":["../../Cryptide/TideMemoryObjects.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AAGxF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,sBAAsB,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,2BAUrF;AACD,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,UAAU,2BAEnG"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Tide Protocol - Infrastructure for a TRUE Zero-Trust paradigm
|
|
3
|
+
// Copyright (C) 2022 Tide Foundation Ltd
|
|
4
|
+
//
|
|
5
|
+
// This program is free software and is subject to the terms of
|
|
6
|
+
// the Tide Community Open Code License as published by the
|
|
7
|
+
// Tide Foundation Limited. You may modify it and redistribute
|
|
8
|
+
// it in accordance with and subject to the terms of that License.
|
|
9
|
+
// This program is distributed WITHOUT WARRANTY of any kind,
|
|
10
|
+
// including without any implied warranty of MERCHANTABILITY or
|
|
11
|
+
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
12
|
+
// See the Tide Community Open Code License for more details.
|
|
13
|
+
// You should have received a copy of the Tide Community Open
|
|
14
|
+
// Code License along with this program.
|
|
15
|
+
// If not, see https://tide.org/licenses_tcoc2-0-0-en
|
|
16
|
+
//
|
|
17
|
+
import { CreateTideMemory, writeInt64LittleEndian, WriteValue } from "./Serialization";
|
|
18
|
+
import { Utils } from "../index";
|
|
19
|
+
import { AuthorizerSignatureFormat } from "./Signing/TideSignature";
|
|
20
|
+
export function CreateVRKPackage(gvrk, expiry) {
|
|
21
|
+
const serializedgvrk = gvrk.Serialize().ToBytes();
|
|
22
|
+
const ex = typeof expiry == "bigint" ? expiry : BigInt(expiry);
|
|
23
|
+
if (ex < BigInt(Utils.CurrentTime() + 5))
|
|
24
|
+
throw Error("Expiry must be at least 5 seconds into future");
|
|
25
|
+
const time_b = writeInt64LittleEndian(ex);
|
|
26
|
+
const vrk_pack = CreateTideMemory(serializedgvrk, 4 + 4 + serializedgvrk.length + time_b.length);
|
|
27
|
+
WriteValue(vrk_pack, 1, time_b);
|
|
28
|
+
return vrk_pack;
|
|
29
|
+
}
|
|
30
|
+
export function CreateAuthorizerPackage(authFlow, signModels, vrk_pack) {
|
|
31
|
+
return new AuthorizerSignatureFormat(authFlow, signModels, vrk_pack).format();
|
|
32
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { default as TideKey } from "./TideKey";
|
|
2
|
+
export * as Encryption from "./Encryption";
|
|
3
|
+
export * as Signing from "./Signing";
|
|
4
|
+
export * as Hashing from "./Hashing";
|
|
5
|
+
export * as Interpolation from "./Interpolation";
|
|
6
|
+
export * as Math from "./Math";
|
|
7
|
+
export * as Serialization from "./Serialization";
|
|
8
|
+
export * as Ed25519 from "./Ed25519";
|
|
9
|
+
export * as TideMemoryObjects from "./TideMemoryObjects";
|
|
10
|
+
export * as Components from "./Components";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../Cryptide/index.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAA;AAG9C,OAAO,KAAK,UAAU,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,OAAO,MAAM,WAAW,CAAA;AACpC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAA;AACpC,OAAO,KAAK,aAAa,MAAM,iBAAiB,CAAA;AAChD,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAA;AAC9B,OAAO,KAAK,aAAa,MAAM,iBAAiB,CAAA;AAChD,OAAO,KAAK,OAAO,MAAM,WAAW,CAAA;AACpC,OAAO,KAAK,iBAAiB,MAAM,qBAAqB,CAAA;AACxD,OAAO,KAAK,UAAU,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Tide Protocol - Infrastructure for a TRUE Zero-Trust paradigm
|
|
3
|
+
// Copyright (C) 2022 Tide Foundation Ltd
|
|
4
|
+
//
|
|
5
|
+
// This program is free software and is subject to the terms of
|
|
6
|
+
// the Tide Community Open Code License as published by the
|
|
7
|
+
// Tide Foundation Limited. You may modify it and redistribute
|
|
8
|
+
// it in accordance with and subject to the terms of that License.
|
|
9
|
+
// This program is distributed WITHOUT WARRANTY of any kind,
|
|
10
|
+
// including without any implied warranty of MERCHANTABILITY or
|
|
11
|
+
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
12
|
+
// See the Tide Community Open Code License for more details.
|
|
13
|
+
// You should have received a copy of the Tide Community Open
|
|
14
|
+
// Code License along with this program.
|
|
15
|
+
// If not, see https://tide.org/licenses_tcoc2-0-0-en
|
|
16
|
+
//
|
|
17
|
+
// Top-level exports
|
|
18
|
+
export { default as TideKey } from "./TideKey";
|
|
19
|
+
// Namespace exports - for direct access
|
|
20
|
+
export * as Encryption from "./Encryption";
|
|
21
|
+
export * as Signing from "./Signing";
|
|
22
|
+
export * as Hashing from "./Hashing";
|
|
23
|
+
export * as Interpolation from "./Interpolation";
|
|
24
|
+
export * as Math from "./Math";
|
|
25
|
+
export * as Serialization from "./Serialization";
|
|
26
|
+
export * as Ed25519 from "./Ed25519";
|
|
27
|
+
export * as TideMemoryObjects from "./TideMemoryObjects";
|
|
28
|
+
export * as Components from "./Components";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import BaseTideRequest from "../../Models/BaseTideRequest";
|
|
2
|
+
import { Doken } from "../../Models/Doken";
|
|
3
|
+
import TideKey from "../../Cryptide/TideKey";
|
|
4
|
+
export default class dVVKDecryptionFlow {
|
|
5
|
+
vvkid: string;
|
|
6
|
+
vvkPublic: any;
|
|
7
|
+
orks: any;
|
|
8
|
+
sessKey: TideKey;
|
|
9
|
+
doken: Doken;
|
|
10
|
+
getVouchersFunction: ((request: string) => Promise<string>) | null;
|
|
11
|
+
voucherURL: string;
|
|
12
|
+
constructor(vvkid: string, vvkPublic: any, orks: any, sessKey: TideKey, doken: Doken, voucherURL: string);
|
|
13
|
+
setVoucherRetrievalFunction(getVouchersFunction: (request: string) => Promise<string>): this;
|
|
14
|
+
start(request: BaseTideRequest, waitForAll?: boolean): Promise<Uint8Array<ArrayBuffer>[]>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=dVVKDecryptionFlow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dVVKDecryptionFlow.d.ts","sourceRoot":"","sources":["../../../Flow/DecryptionFlows/dVVKDecryptionFlow.ts"],"names":[],"mappings":"AAkBA,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAI3D,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAE7C,MAAM,CAAC,OAAO,OAAO,kBAAkB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,GAAG,CAAC;IACf,IAAI,EAAE,GAAG,CAAC;IACV,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;IACb,mBAAmB,EAAE,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC;IACnE,UAAU,EAAE,MAAM,CAAC;gBAEP,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM;IAaxG,2BAA2B,CAAC,mBAAmB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC;IAI/E,KAAK,CAAC,OAAO,EAAE,eAAe,EAAE,UAAU,GAAE,OAAe;CAYpE"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Tide Protocol - Infrastructure for a TRUE Zero-Trust paradigm
|
|
3
|
+
// Copyright (C) 2022 Tide Foundation Ltd
|
|
4
|
+
//
|
|
5
|
+
// This program is free software and is subject to the terms of
|
|
6
|
+
// the Tide Community Open Code License as published by the
|
|
7
|
+
// Tide Foundation Limited. You may modify it and redistribute
|
|
8
|
+
// it in accordance with and subject to the terms of that License.
|
|
9
|
+
// This program is distributed WITHOUT WARRANTY of any kind,
|
|
10
|
+
// including without any implied warranty of MERCHANTABILITY or
|
|
11
|
+
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
12
|
+
// See the Tide Community Open Code License for more details.
|
|
13
|
+
// You should have received a copy of the Tide Community Open
|
|
14
|
+
// Code License along with this program.
|
|
15
|
+
// If not, see https://tide.org/licenses_tcoc2-0-0-en
|
|
16
|
+
//
|
|
17
|
+
import { Max, sortORKs, Threshold, WaitForNumberofORKs } from "../../Tools/Utils";
|
|
18
|
+
import NodeClient from "../../Clients/NodeClient";
|
|
19
|
+
import VoucherFlow from "../VoucherFlows/VoucherFlow";
|
|
20
|
+
import { GetKeys } from "../../Math/KeyDecryption";
|
|
21
|
+
export default class dVVKDecryptionFlow {
|
|
22
|
+
constructor(vvkid, vvkPublic, orks, sessKey, doken, voucherURL) {
|
|
23
|
+
this.vvkid = vvkid;
|
|
24
|
+
this.vvkPublic = vvkPublic;
|
|
25
|
+
this.orks = orks;
|
|
26
|
+
this.orks = sortORKs(this.orks); // sort for bitwise!
|
|
27
|
+
if (!doken.payload.sessionKey.Equals(sessKey.get_public_component()))
|
|
28
|
+
throw Error("Mismatch between session key private and Doken session key public");
|
|
29
|
+
this.sessKey = sessKey;
|
|
30
|
+
this.doken = doken;
|
|
31
|
+
this.getVouchersFunction = null;
|
|
32
|
+
this.voucherURL = voucherURL;
|
|
33
|
+
}
|
|
34
|
+
setVoucherRetrievalFunction(getVouchersFunction) {
|
|
35
|
+
this.getVouchersFunction = getVouchersFunction;
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
async start(request, waitForAll = false) {
|
|
39
|
+
const pre_clients = this.orks.map(info => new NodeClient(info.orkURL).AddBearerAuthorization(this.sessKey.get_private_component().rawBytes, this.sessKey.get_public_component().Serialize().ToString(), this.doken.serialize()).EnableTideDH(info.orkPublic));
|
|
40
|
+
const voucherFlow = new VoucherFlow(this.orks.map(o => o.orkPaymentPublic), this.voucherURL, "vendordecrypt");
|
|
41
|
+
const { vouchers } = await voucherFlow.GetVouchers(this.getVouchersFunction);
|
|
42
|
+
const clients = await Promise.all(pre_clients); // to speed things up - computer shared key while grabbing vouchers
|
|
43
|
+
const pre_PreDecryptResponses = clients.map((client, i) => client.Decrypt(i, this.vvkid, request, vouchers.toORK(i)));
|
|
44
|
+
const { fulfilledResponses, bitwise } = await WaitForNumberofORKs(this.orks, pre_PreDecryptResponses, "VVK", waitForAll ? Max : Threshold, null, clients);
|
|
45
|
+
return GetKeys(fulfilledResponses, this.orks.map(o => BigInt(o.orkID))); // to be used for symmetric encryption now with caller
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../Flow/DecryptionFlows/index.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Tide Protocol - Infrastructure for a TRUE Zero-Trust paradigm
|
|
3
|
+
// Copyright (C) 2022 Tide Foundation Ltd
|
|
4
|
+
//
|
|
5
|
+
// This program is free software and is subject to the terms of
|
|
6
|
+
// the Tide Community Open Code License as published by the
|
|
7
|
+
// Tide Foundation Limited. You may modify it and redistribute
|
|
8
|
+
// it in accordance with and subject to the terms of that License.
|
|
9
|
+
// This program is distributed WITHOUT WARRANTY of any kind,
|
|
10
|
+
// including without any implied warranty of MERCHANTABILITY or
|
|
11
|
+
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
12
|
+
// See the Tide Community Open Code License for more details.
|
|
13
|
+
// You should have received a copy of the Tide Community Open
|
|
14
|
+
// Code License along with this program.
|
|
15
|
+
// If not, see https://tide.org/licenses_tcoc2-0-0-en
|
|
16
|
+
//
|
|
17
|
+
export { default as dVVKDecryptionFlow } from './dVVKDecryptionFlow';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {{
|
|
4
|
+
* vendorId: string,
|
|
5
|
+
* token: Doken,
|
|
6
|
+
* sessionKey: TideKey
|
|
7
|
+
* voucherURL: string,
|
|
8
|
+
* homeOrkUrl: string | null
|
|
9
|
+
* keyInfo: KeyInfo
|
|
10
|
+
* }} config
|
|
11
|
+
*/
|
|
12
|
+
export declare function AuthorizedEncryptionFlow(config: any): void;
|
|
13
|
+
//# sourceMappingURL=AuthorizedEncryptionFlow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthorizedEncryptionFlow.d.ts","sourceRoot":"","sources":["../../../Flow/EncryptionFlows/AuthorizedEncryptionFlow.ts"],"names":[],"mappings":"AA4BA;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,KAAA,QA6K9C"}
|