@tideorg/js 0.0.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.
Files changed (234) hide show
  1. package/LICENSE +333 -0
  2. package/README.md +12 -0
  3. package/dist/Clients/ClientBase.d.ts +24 -0
  4. package/dist/Clients/ClientBase.d.ts.map +1 -0
  5. package/dist/Clients/ClientBase.js +160 -0
  6. package/dist/Clients/NetworkClient.d.ts +11 -0
  7. package/dist/Clients/NetworkClient.d.ts.map +1 -0
  8. package/dist/Clients/NetworkClient.js +68 -0
  9. package/dist/Clients/NodeClient.d.ts +34 -0
  10. package/dist/Clients/NodeClient.d.ts.map +1 -0
  11. package/dist/Clients/NodeClient.js +191 -0
  12. package/dist/Clients/VoucherClient.d.ts +8 -0
  13. package/dist/Clients/VoucherClient.d.ts.map +1 -0
  14. package/dist/Clients/VoucherClient.js +36 -0
  15. package/dist/Clients/index.d.ts +5 -0
  16. package/dist/Clients/index.d.ts.map +1 -0
  17. package/dist/Clients/index.js +20 -0
  18. package/dist/Contracts/BaseContract.d.ts +47 -0
  19. package/dist/Contracts/BaseContract.d.ts.map +1 -0
  20. package/dist/Contracts/BaseContract.js +153 -0
  21. package/dist/Contracts/GenericRealmAccessThresholdRoleContract.d.ts +8 -0
  22. package/dist/Contracts/GenericRealmAccessThresholdRoleContract.d.ts.map +1 -0
  23. package/dist/Contracts/GenericRealmAccessThresholdRoleContract.js +21 -0
  24. package/dist/Contracts/GenericResourceAccessThresholdRoleContract.d.ts +8 -0
  25. package/dist/Contracts/GenericResourceAccessThresholdRoleContract.d.ts.map +1 -0
  26. package/dist/Contracts/GenericResourceAccessThresholdRoleContract.js +21 -0
  27. package/dist/Contracts/index.d.ts +4 -0
  28. package/dist/Contracts/index.d.ts.map +1 -0
  29. package/dist/Contracts/index.js +19 -0
  30. package/dist/Cryptide/Components/BaseComponent.d.ts +56 -0
  31. package/dist/Cryptide/Components/BaseComponent.d.ts.map +1 -0
  32. package/dist/Cryptide/Components/BaseComponent.js +176 -0
  33. package/dist/Cryptide/Components/ComponentRegistry.d.ts +18 -0
  34. package/dist/Cryptide/Components/ComponentRegistry.d.ts.map +1 -0
  35. package/dist/Cryptide/Components/ComponentRegistry.js +39 -0
  36. package/dist/Cryptide/Components/Schemes/AES/AESScheme.d.ts +5 -0
  37. package/dist/Cryptide/Components/Schemes/AES/AESScheme.d.ts.map +1 -0
  38. package/dist/Cryptide/Components/Schemes/AES/AESScheme.js +20 -0
  39. package/dist/Cryptide/Components/Schemes/AES/index.d.ts +2 -0
  40. package/dist/Cryptide/Components/Schemes/AES/index.d.ts.map +1 -0
  41. package/dist/Cryptide/Components/Schemes/AES/index.js +17 -0
  42. package/dist/Cryptide/Components/Schemes/BaseScheme.d.ts +7 -0
  43. package/dist/Cryptide/Components/Schemes/BaseScheme.d.ts.map +1 -0
  44. package/dist/Cryptide/Components/Schemes/BaseScheme.js +23 -0
  45. package/dist/Cryptide/Components/Schemes/Ed25519/Ed25519Components.d.ts +52 -0
  46. package/dist/Cryptide/Components/Schemes/Ed25519/Ed25519Components.d.ts.map +1 -0
  47. package/dist/Cryptide/Components/Schemes/Ed25519/Ed25519Components.js +171 -0
  48. package/dist/Cryptide/Components/Schemes/Ed25519/Ed25519Scheme.d.ts +13 -0
  49. package/dist/Cryptide/Components/Schemes/Ed25519/Ed25519Scheme.d.ts.map +1 -0
  50. package/dist/Cryptide/Components/Schemes/Ed25519/Ed25519Scheme.js +71 -0
  51. package/dist/Cryptide/Components/Schemes/Ed25519/index.d.ts +3 -0
  52. package/dist/Cryptide/Components/Schemes/Ed25519/index.d.ts.map +1 -0
  53. package/dist/Cryptide/Components/Schemes/Ed25519/index.js +18 -0
  54. package/dist/Cryptide/Components/Schemes/SchemeRegistry.d.ts +3 -0
  55. package/dist/Cryptide/Components/Schemes/SchemeRegistry.d.ts.map +1 -0
  56. package/dist/Cryptide/Components/Schemes/SchemeRegistry.js +22 -0
  57. package/dist/Cryptide/Components/Schemes/index.d.ts +5 -0
  58. package/dist/Cryptide/Components/Schemes/index.d.ts.map +1 -0
  59. package/dist/Cryptide/Components/Schemes/index.js +20 -0
  60. package/dist/Cryptide/Components/index.d.ts +4 -0
  61. package/dist/Cryptide/Components/index.d.ts.map +1 -0
  62. package/dist/Cryptide/Components/index.js +19 -0
  63. package/dist/Cryptide/Ed25519.d.ts +106 -0
  64. package/dist/Cryptide/Ed25519.d.ts.map +1 -0
  65. package/dist/Cryptide/Ed25519.js +522 -0
  66. package/dist/Cryptide/Encryption/AES.d.ts +6 -0
  67. package/dist/Cryptide/Encryption/AES.d.ts.map +1 -0
  68. package/dist/Cryptide/Encryption/AES.js +76 -0
  69. package/dist/Cryptide/Encryption/DH.d.ts +4 -0
  70. package/dist/Cryptide/Encryption/DH.d.ts.map +1 -0
  71. package/dist/Cryptide/Encryption/DH.js +38 -0
  72. package/dist/Cryptide/Encryption/ElGamal.d.ts +12 -0
  73. package/dist/Cryptide/Encryption/ElGamal.d.ts.map +1 -0
  74. package/dist/Cryptide/Encryption/ElGamal.js +61 -0
  75. package/dist/Cryptide/Encryption/index.d.ts +4 -0
  76. package/dist/Cryptide/Encryption/index.d.ts.map +1 -0
  77. package/dist/Cryptide/Encryption/index.js +19 -0
  78. package/dist/Cryptide/Hashing/H2P.d.ts +6 -0
  79. package/dist/Cryptide/Hashing/H2P.d.ts.map +1 -0
  80. package/dist/Cryptide/Hashing/H2P.js +235 -0
  81. package/dist/Cryptide/Hashing/Hash.d.ts +8 -0
  82. package/dist/Cryptide/Hashing/Hash.d.ts.map +1 -0
  83. package/dist/Cryptide/Hashing/Hash.js +43 -0
  84. package/dist/Cryptide/Hashing/index.d.ts +3 -0
  85. package/dist/Cryptide/Hashing/index.d.ts.map +1 -0
  86. package/dist/Cryptide/Hashing/index.js +18 -0
  87. package/dist/Cryptide/Interpolation.d.ts +20 -0
  88. package/dist/Cryptide/Interpolation.d.ts.map +1 -0
  89. package/dist/Cryptide/Interpolation.js +68 -0
  90. package/dist/Cryptide/Math.d.ts +11 -0
  91. package/dist/Cryptide/Math.d.ts.map +1 -0
  92. package/dist/Cryptide/Math.js +81 -0
  93. package/dist/Cryptide/Serialization.d.ts +66 -0
  94. package/dist/Cryptide/Serialization.d.ts.map +1 -0
  95. package/dist/Cryptide/Serialization.js +517 -0
  96. package/dist/Cryptide/Signing/BlindSig.d.ts +10 -0
  97. package/dist/Cryptide/Signing/BlindSig.d.ts.map +1 -0
  98. package/dist/Cryptide/Signing/BlindSig.js +41 -0
  99. package/dist/Cryptide/Signing/EdDSA.d.ts +14 -0
  100. package/dist/Cryptide/Signing/EdDSA.d.ts.map +1 -0
  101. package/dist/Cryptide/Signing/EdDSA.js +67 -0
  102. package/dist/Cryptide/Signing/TideSignature.d.ts +59 -0
  103. package/dist/Cryptide/Signing/TideSignature.d.ts.map +1 -0
  104. package/dist/Cryptide/Signing/TideSignature.js +118 -0
  105. package/dist/Cryptide/Signing/index.d.ts +4 -0
  106. package/dist/Cryptide/Signing/index.d.ts.map +1 -0
  107. package/dist/Cryptide/Signing/index.js +19 -0
  108. package/dist/Cryptide/TideKey.d.ts +17 -0
  109. package/dist/Cryptide/TideKey.d.ts.map +1 -0
  110. package/dist/Cryptide/TideKey.js +84 -0
  111. package/dist/Cryptide/TideMemoryObjects.d.ts +4 -0
  112. package/dist/Cryptide/TideMemoryObjects.d.ts.map +1 -0
  113. package/dist/Cryptide/TideMemoryObjects.js +32 -0
  114. package/dist/Cryptide/index.d.ts +11 -0
  115. package/dist/Cryptide/index.d.ts.map +1 -0
  116. package/dist/Cryptide/index.js +28 -0
  117. package/dist/Flow/DecryptionFlows/dVVKDecryptionFlow.d.ts +16 -0
  118. package/dist/Flow/DecryptionFlows/dVVKDecryptionFlow.d.ts.map +1 -0
  119. package/dist/Flow/DecryptionFlows/dVVKDecryptionFlow.js +47 -0
  120. package/dist/Flow/DecryptionFlows/index.d.ts +2 -0
  121. package/dist/Flow/DecryptionFlows/index.d.ts.map +1 -0
  122. package/dist/Flow/DecryptionFlows/index.js +17 -0
  123. package/dist/Flow/EncryptionFlows/AuthorizedEncryptionFlow.d.ts +13 -0
  124. package/dist/Flow/EncryptionFlows/AuthorizedEncryptionFlow.d.ts.map +1 -0
  125. package/dist/Flow/EncryptionFlows/AuthorizedEncryptionFlow.js +183 -0
  126. package/dist/Flow/EncryptionFlows/PolicyAuthorizedEncryptionFlow.d.ts +57 -0
  127. package/dist/Flow/EncryptionFlows/PolicyAuthorizedEncryptionFlow.d.ts.map +1 -0
  128. package/dist/Flow/EncryptionFlows/PolicyAuthorizedEncryptionFlow.js +220 -0
  129. package/dist/Flow/EncryptionFlows/index.d.ts +3 -0
  130. package/dist/Flow/EncryptionFlows/index.d.ts.map +1 -0
  131. package/dist/Flow/EncryptionFlows/index.js +18 -0
  132. package/dist/Flow/SigningFlows/AuthorizedSigningFlow.d.ts +12 -0
  133. package/dist/Flow/SigningFlows/AuthorizedSigningFlow.d.ts.map +1 -0
  134. package/dist/Flow/SigningFlows/AuthorizedSigningFlow.js +50 -0
  135. package/dist/Flow/SigningFlows/dTestVVkSigningFlow.d.ts +15 -0
  136. package/dist/Flow/SigningFlows/dTestVVkSigningFlow.d.ts.map +1 -0
  137. package/dist/Flow/SigningFlows/dTestVVkSigningFlow.js +67 -0
  138. package/dist/Flow/SigningFlows/dVVKSigningFlow.d.ts +17 -0
  139. package/dist/Flow/SigningFlows/dVVKSigningFlow.d.ts.map +1 -0
  140. package/dist/Flow/SigningFlows/dVVKSigningFlow.js +61 -0
  141. package/dist/Flow/SigningFlows/dVVKSigningFlow2Step.d.ts +28 -0
  142. package/dist/Flow/SigningFlows/dVVKSigningFlow2Step.d.ts.map +1 -0
  143. package/dist/Flow/SigningFlows/dVVKSigningFlow2Step.js +118 -0
  144. package/dist/Flow/SigningFlows/index.d.ts +5 -0
  145. package/dist/Flow/SigningFlows/index.d.ts.map +1 -0
  146. package/dist/Flow/SigningFlows/index.js +20 -0
  147. package/dist/Flow/VoucherFlows/VoucherFlow.d.ts +16 -0
  148. package/dist/Flow/VoucherFlows/VoucherFlow.d.ts.map +1 -0
  149. package/dist/Flow/VoucherFlows/VoucherFlow.js +34 -0
  150. package/dist/Flow/VoucherFlows/index.d.ts +2 -0
  151. package/dist/Flow/VoucherFlows/index.d.ts.map +1 -0
  152. package/dist/Flow/VoucherFlows/index.js +17 -0
  153. package/dist/Flow/index.d.ts +5 -0
  154. package/dist/Flow/index.d.ts.map +1 -0
  155. package/dist/Flow/index.js +20 -0
  156. package/dist/Math/KeyDecryption.d.ts +3 -0
  157. package/dist/Math/KeyDecryption.d.ts.map +1 -0
  158. package/dist/Math/KeyDecryption.js +24 -0
  159. package/dist/Math/KeySigning.d.ts +4 -0
  160. package/dist/Math/KeySigning.d.ts.map +1 -0
  161. package/dist/Math/KeySigning.js +28 -0
  162. package/dist/Math/index.d.ts +3 -0
  163. package/dist/Math/index.d.ts.map +1 -0
  164. package/dist/Math/index.js +18 -0
  165. package/dist/Models/AuthRequest.d.ts +14 -0
  166. package/dist/Models/AuthRequest.d.ts.map +1 -0
  167. package/dist/Models/AuthRequest.js +48 -0
  168. package/dist/Models/BaseTideRequest.d.ts +55 -0
  169. package/dist/Models/BaseTideRequest.d.ts.map +1 -0
  170. package/dist/Models/BaseTideRequest.js +299 -0
  171. package/dist/Models/CustomTideRequest.d.ts +19 -0
  172. package/dist/Models/CustomTideRequest.d.ts.map +1 -0
  173. package/dist/Models/CustomTideRequest.js +30 -0
  174. package/dist/Models/Datum.d.ts +11 -0
  175. package/dist/Models/Datum.d.ts.map +1 -0
  176. package/dist/Models/Datum.js +33 -0
  177. package/dist/Models/Doken.d.ts +33 -0
  178. package/dist/Models/Doken.d.ts.map +1 -0
  179. package/dist/Models/Doken.js +133 -0
  180. package/dist/Models/EnclaveEntry.d.ts +14 -0
  181. package/dist/Models/EnclaveEntry.d.ts.map +1 -0
  182. package/dist/Models/EnclaveEntry.js +49 -0
  183. package/dist/Models/Infos/KeyInfo.d.ts +24 -0
  184. package/dist/Models/Infos/KeyInfo.d.ts.map +1 -0
  185. package/dist/Models/Infos/KeyInfo.js +51 -0
  186. package/dist/Models/Infos/OrkInfo.d.ts +18 -0
  187. package/dist/Models/Infos/OrkInfo.d.ts.map +1 -0
  188. package/dist/Models/Infos/OrkInfo.js +58 -0
  189. package/dist/Models/Infos/index.d.ts +3 -0
  190. package/dist/Models/Infos/index.d.ts.map +1 -0
  191. package/dist/Models/Infos/index.js +18 -0
  192. package/dist/Models/ModelRegistry.d.ts +29 -0
  193. package/dist/Models/ModelRegistry.d.ts.map +1 -0
  194. package/dist/Models/ModelRegistry.js +321 -0
  195. package/dist/Models/Policy.d.ts +41 -0
  196. package/dist/Models/Policy.d.ts.map +1 -0
  197. package/dist/Models/Policy.js +317 -0
  198. package/dist/Models/PolicyProtectedSerializedField.d.ts +12 -0
  199. package/dist/Models/PolicyProtectedSerializedField.d.ts.map +1 -0
  200. package/dist/Models/PolicyProtectedSerializedField.js +50 -0
  201. package/dist/Models/Responses/Vendor/VoucherResponse.d.ts +12 -0
  202. package/dist/Models/Responses/Vendor/VoucherResponse.d.ts.map +1 -0
  203. package/dist/Models/Responses/Vendor/VoucherResponse.js +39 -0
  204. package/dist/Models/Responses/Vendor/index.d.ts +2 -0
  205. package/dist/Models/Responses/Vendor/index.d.ts.map +1 -0
  206. package/dist/Models/Responses/Vendor/index.js +17 -0
  207. package/dist/Models/Responses/index.d.ts +2 -0
  208. package/dist/Models/Responses/index.d.ts.map +1 -0
  209. package/dist/Models/Responses/index.js +17 -0
  210. package/dist/Models/SerializedField.d.ts +12 -0
  211. package/dist/Models/SerializedField.d.ts.map +1 -0
  212. package/dist/Models/SerializedField.js +50 -0
  213. package/dist/Models/VendorData.d.ts +12 -0
  214. package/dist/Models/VendorData.d.ts.map +1 -0
  215. package/dist/Models/VendorData.js +38 -0
  216. package/dist/Models/VendorSettings.d.ts +9 -0
  217. package/dist/Models/VendorSettings.d.ts.map +1 -0
  218. package/dist/Models/VendorSettings.js +32 -0
  219. package/dist/Models/index.d.ts +13 -0
  220. package/dist/Models/index.d.ts.map +1 -0
  221. package/dist/Models/index.js +30 -0
  222. package/dist/Tools/TideMemory.d.ts +10 -0
  223. package/dist/Tools/TideMemory.d.ts.map +1 -0
  224. package/dist/Tools/TideMemory.js +105 -0
  225. package/dist/Tools/Utils.d.ts +13 -0
  226. package/dist/Tools/Utils.d.ts.map +1 -0
  227. package/dist/Tools/Utils.js +244 -0
  228. package/dist/Tools/index.d.ts +3 -0
  229. package/dist/Tools/index.d.ts.map +1 -0
  230. package/dist/Tools/index.js +18 -0
  231. package/dist/index.d.ts +10 -0
  232. package/dist/index.d.ts.map +1 -0
  233. package/dist/index.js +26 -0
  234. package/package.json +27 -0
@@ -0,0 +1,17 @@
1
+ import BaseTideRequest from "../../Models/BaseTideRequest";
2
+ import OrkInfo from "../../Models/Infos/OrkInfo";
3
+ import { Doken } from "../../Models/Doken";
4
+ import TideKey from "../../Cryptide/TideKey";
5
+ export default class dVVKSigningFlow {
6
+ vvkid: string;
7
+ vvkPublic: any;
8
+ orks: OrkInfo[];
9
+ sessKey: TideKey;
10
+ doken: string;
11
+ getVouchersFunction: ((request: string) => Promise<string>) | null;
12
+ voucherURL: string;
13
+ constructor(vvkid: string, vvkPublic: any, orks: OrkInfo[], sessKey: TideKey, doken: Doken, voucherURL: string);
14
+ setVoucherRetrievalFunction(getVouchersFunction: (request: string) => Promise<string>): dVVKSigningFlow;
15
+ start(request: BaseTideRequest, waitForAll?: boolean): Promise<any[]>;
16
+ }
17
+ //# sourceMappingURL=dVVKSigningFlow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dVVKSigningFlow.d.ts","sourceRoot":"","sources":["../../../Flow/SigningFlows/dVVKSigningFlow.ts"],"names":[],"mappings":"AAiBA,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAG3D,OAAO,OAAO,MAAM,4BAA4B,CAAC;AAIjD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAE7C,MAAM,CAAC,OAAO,OAAO,eAAe;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,GAAG,CAAC;IACf,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,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,OAAO,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM;IAgB9G,2BAA2B,CAAC,mBAAmB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,eAAe;IAKjG,KAAK,CAAC,OAAO,EAAE,eAAe,EAAE,UAAU,GAAE,OAAe;CA0BpE"}
@@ -0,0 +1,61 @@
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, Threshold, WaitForNumberofORKs, sortORKs } from "../../Tools/Utils";
18
+ import NodeClient from "../../Clients/NodeClient";
19
+ import { PreSign, Sign as SumS } from "../../Math/KeySigning";
20
+ import { BigIntToByteArray, ConcatUint8Arrays, serializeBitArray } from "../../Cryptide/Serialization";
21
+ import VoucherFlow from "../VoucherFlows/VoucherFlow";
22
+ export default class dVVKSigningFlow {
23
+ constructor(vvkid, vvkPublic, orks, sessKey, doken, voucherURL) {
24
+ this.vvkid = vvkid;
25
+ this.vvkPublic = vvkPublic;
26
+ this.orks = orks;
27
+ this.orks = sortORKs(this.orks); // sort for bitwise!
28
+ if (doken) {
29
+ if (!doken.payload.sessionKey.Equals(sessKey.get_public_component()))
30
+ throw Error("Mismatch between session key private and Doken session key public");
31
+ this.doken = doken.serialize();
32
+ }
33
+ this.sessKey = sessKey;
34
+ this.getVouchersFunction = null;
35
+ this.voucherURL = voucherURL;
36
+ }
37
+ setVoucherRetrievalFunction(getVouchersFunction) {
38
+ this.getVouchersFunction = getVouchersFunction;
39
+ return this;
40
+ }
41
+ async start(request, waitForAll = false) {
42
+ const voucherFlow = new VoucherFlow(this.orks.map(o => o.orkPaymentPublic), this.voucherURL, "vendorsign");
43
+ const pre_vouchers = voucherFlow.GetVouchers(this.getVouchersFunction);
44
+ 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).EnableTideDH(info.orkPublic));
45
+ const clients = await Promise.all(pre_clients);
46
+ const { vouchers } = await pre_vouchers;
47
+ const pre_PreSignResponses = clients.map((client, i) => client.PreSign(i, this.vvkid, request, vouchers.toORK(i)));
48
+ const { fulfilledResponses, bitwise } = await WaitForNumberofORKs(this.orks, pre_PreSignResponses, "VVK", waitForAll ? Max : Threshold, null, clients);
49
+ const GRj = PreSign(fulfilledResponses.map(f => f.GRis));
50
+ const pre_SignResponses = clients.map((client, i) => client.Sign(this.vvkid, request, GRj, serializeBitArray(bitwise)));
51
+ const SignResponses = await Promise.all(pre_SignResponses);
52
+ const Sj = SumS(SignResponses.map(s => s.Sij));
53
+ if (GRj.length != Sj.length)
54
+ throw Error("Weird amount of GRjs and Sjs");
55
+ let sigs = [];
56
+ for (let i = 0; i < GRj.length; i++) {
57
+ sigs.push(ConcatUint8Arrays([GRj[i].toRawBytes(), BigIntToByteArray(Sj[i])]));
58
+ }
59
+ return sigs;
60
+ }
61
+ }
@@ -0,0 +1,28 @@
1
+ import BaseTideRequest from "../../Models/BaseTideRequest";
2
+ import OrkInfo from "../../Models/Infos/OrkInfo";
3
+ import { Doken } from "../../Models/Doken";
4
+ import TideKey from "../../Cryptide/TideKey";
5
+ export default class dVVKSigningFlow2Step {
6
+ vvkid: string;
7
+ vvkPublic: any;
8
+ orks: OrkInfo[];
9
+ sessKey: TideKey;
10
+ doken: string;
11
+ getVouchersFunction: ((request: string) => Promise<string>) | null;
12
+ voucherURL: string;
13
+ vendorAction: string;
14
+ request: BaseTideRequest;
15
+ vouchers: any;
16
+ preSignState: any;
17
+ constructor(vvkid: string, vvkPublic: any, orks: OrkInfo[], sessKey: TideKey, doken: Doken, voucherURL: string);
18
+ setVoucherRetrievalFunction(getVouchersFunction: (request: string) => Promise<string>): this;
19
+ setRequest(request: any): Promise<void>;
20
+ overrideVoucherAction(action: any): Promise<void>;
21
+ getVouchers(): any;
22
+ preSign(dynamicData: Uint8Array | Uint8Array[]): Promise<Uint8Array[]>;
23
+ sign(dynamicData: Uint8Array | Uint8Array[]): Promise<{
24
+ sigs: any[];
25
+ addionalDatas: any[];
26
+ }>;
27
+ }
28
+ //# sourceMappingURL=dVVKSigningFlow2Step.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dVVKSigningFlow2Step.d.ts","sourceRoot":"","sources":["../../../Flow/SigningFlows/dVVKSigningFlow2Step.ts"],"names":[],"mappings":"AAiBA,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAG3D,OAAO,OAAO,MAAM,4BAA4B,CAAC;AAIjD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAE7C,MAAM,CAAC,OAAO,OAAO,oBAAoB;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,GAAG,CAAC;IACf,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,mBAAmB,EAAE,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC;IACnE,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,eAAe,CAAC;IACzB,QAAQ,EAAE,GAAG,CAAC;IACd,YAAY,EAAE,GAAG,CAAC;gBAEN,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM;IAiB9G,2BAA2B,CAAC,mBAAmB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC;IAK/E,UAAU,CAAC,OAAO,KAAA;IAMlB,qBAAqB,CAAC,MAAM,KAAA;IAIlC,WAAW;IAIL,OAAO,CAAC,WAAW,EAAE,UAAU,GAAG,UAAU,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAiCtE,IAAI,CAAC,WAAW,EAAE,UAAU,GAAG,UAAU,EAAE;;;;CA4BpD"}
@@ -0,0 +1,118 @@
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 BaseTideRequest from "../../Models/BaseTideRequest";
18
+ import { Threshold, WaitForNumberofORKs, sortORKs } from "../../Tools/Utils";
19
+ import NodeClient from "../../Clients/NodeClient";
20
+ import { PreSign, Sign as SumS } from "../../Math/KeySigning";
21
+ import { BigIntToByteArray, ConcatUint8Arrays, serializeBitArray } from "../../Cryptide/Serialization";
22
+ import VoucherFlow from "../VoucherFlows/VoucherFlow";
23
+ export default class dVVKSigningFlow2Step {
24
+ constructor(vvkid, vvkPublic, orks, sessKey, doken, voucherURL) {
25
+ this.vvkid = vvkid;
26
+ this.vvkPublic = vvkPublic;
27
+ this.orks = orks;
28
+ this.orks = sortORKs(this.orks); // sort for bitwise!
29
+ if (doken) {
30
+ if (!doken.payload.sessionKey.Equals(sessKey.get_public_component()))
31
+ throw Error("Mismatch between session key private and Doken session key public");
32
+ this.doken = doken.serialize();
33
+ }
34
+ this.sessKey = sessKey;
35
+ this.getVouchersFunction = null;
36
+ this.voucherURL = voucherURL;
37
+ this.vendorAction = "vendorsign";
38
+ }
39
+ setVoucherRetrievalFunction(getVouchersFunction) {
40
+ this.getVouchersFunction = getVouchersFunction;
41
+ return this;
42
+ }
43
+ async setRequest(request) {
44
+ if (!(request instanceof BaseTideRequest))
45
+ throw 'Request is not a BaseTideRequest';
46
+ if (request.dyanmicData.length != 0)
47
+ throw 'Dyanamic data must be null for signing flow 2 step';
48
+ this.request = request;
49
+ }
50
+ async overrideVoucherAction(action) {
51
+ this.vendorAction = action;
52
+ }
53
+ getVouchers() {
54
+ if (!this.vouchers)
55
+ throw 'Call preSign first';
56
+ return this.vouchers;
57
+ }
58
+ async preSign(dynamicData) {
59
+ let dynDataisArray = false;
60
+ if (dynamicData) {
61
+ if (!(dynamicData instanceof Uint8Array) && !(Array.isArray(dynamicData)))
62
+ throw 'Dynamic data must be Uint8Array or Uint8Array[]';
63
+ if (dynamicData instanceof Uint8Array) {
64
+ this.request.setNewDynamicData(dynamicData);
65
+ }
66
+ else
67
+ dynDataisArray = true;
68
+ }
69
+ const voucherFlow = new VoucherFlow(this.orks.map(o => o.orkPaymentPublic), this.voucherURL, this.vendorAction);
70
+ const pre_vouchers = voucherFlow.GetVouchers(this.getVouchersFunction);
71
+ 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).EnableTideDH(info.orkPublic));
72
+ const clients = await Promise.all(pre_clients);
73
+ const { vouchers, k } = await pre_vouchers;
74
+ this.vouchers = {
75
+ k,
76
+ ...vouchers
77
+ };
78
+ const pre_PreSignResponses = clients.map((client, i) => client.PreSign(i, this.vvkid, dynDataisArray ? this.request.replicate().setNewDynamicData(dynamicData[i]) : this.request, vouchers.toORK(i)));
79
+ const { fulfilledResponses, bitwise } = await WaitForNumberofORKs(this.orks, pre_PreSignResponses, "VVK", Threshold, null, clients);
80
+ const GRj = PreSign(fulfilledResponses.map(f => f.GRis));
81
+ this.preSignState = {
82
+ clients,
83
+ GRj,
84
+ bitwise
85
+ };
86
+ return fulfilledResponses.map(f => f.AdditionalData);
87
+ }
88
+ async sign(dynamicData) {
89
+ let dynDataisArray = false;
90
+ if (dynamicData) {
91
+ if (!(dynamicData instanceof Uint8Array) && !(Array.isArray(dynamicData)))
92
+ throw 'Dynamic data must be Uint8Array or Uint8Array[]';
93
+ if (dynamicData instanceof Uint8Array) {
94
+ this.request.setNewDynamicData(dynamicData);
95
+ }
96
+ else {
97
+ if (dynamicData.length != this.preSignState.clients.length)
98
+ throw Error("Supplied datas array must equal client amount");
99
+ dynDataisArray = true;
100
+ }
101
+ }
102
+ if (!this.preSignState)
103
+ throw 'Execute preSign first';
104
+ const pre_SignResponses = this.preSignState.clients.map((client, i) => client.Sign(this.vvkid, dynDataisArray ? this.request.replicate().setNewDynamicData(dynamicData[i]) : this.request, this.preSignState.GRj, serializeBitArray(this.preSignState.bitwise)));
105
+ const SignResponses = await Promise.all(pre_SignResponses);
106
+ const Sj = SumS(SignResponses.map(s => s.Sij));
107
+ if (this.preSignState.GRj.length != Sj.length)
108
+ throw Error("Weird amount of GRjs and Sjs");
109
+ let sigs = [];
110
+ for (let i = 0; i < this.preSignState.GRj.length; i++) {
111
+ sigs.push(ConcatUint8Arrays([this.preSignState.GRj[i].toRawBytes(), BigIntToByteArray(Sj[i])]));
112
+ }
113
+ return {
114
+ sigs,
115
+ addionalDatas: SignResponses.map(s => s.AdditionalData)
116
+ };
117
+ }
118
+ }
@@ -0,0 +1,5 @@
1
+ export { AuthorizedSigningFlow } from './AuthorizedSigningFlow';
2
+ export { default as dTestVVKSigningFlow } from './dTestVVkSigningFlow';
3
+ export { default as dVVKSigningFlow } from './dVVKSigningFlow';
4
+ export { default as dVVKSigningFlow2Step } from './dVVKSigningFlow2Step';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../Flow/SigningFlows/index.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,20 @@
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 { AuthorizedSigningFlow } from './AuthorizedSigningFlow';
18
+ export { default as dTestVVKSigningFlow } from './dTestVVkSigningFlow';
19
+ export { default as dVVKSigningFlow } from './dVVKSigningFlow';
20
+ export { default as dVVKSigningFlow2Step } from './dVVKSigningFlow2Step';
@@ -0,0 +1,16 @@
1
+ import { Point } from "../../Cryptide/Ed25519";
2
+ import TideKey from "../../Cryptide/TideKey";
3
+ export default class VoucherFlow {
4
+ orkPaymentPublics: Point[];
5
+ voucherURL: string;
6
+ action: string;
7
+ constructor(orkPaymentPublics: Point[], voucherURL: string, action: string);
8
+ /**
9
+ * I'm making this so I can use keycloak's client that has all of the keycloak's authorization built in.
10
+ */
11
+ GetVouchers(clientFunction?: ((request: string) => Promise<string>) | null): Promise<{
12
+ vouchers: any;
13
+ k: TideKey;
14
+ }>;
15
+ }
16
+ //# sourceMappingURL=VoucherFlow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VoucherFlow.d.ts","sourceRoot":"","sources":["../../../Flow/VoucherFlows/VoucherFlow.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAG/C,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAG7C,MAAM,CAAC,OAAO,OAAO,WAAW;IAC5B,iBAAiB,EAAE,KAAK,EAAE,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;gBAEH,iBAAiB,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAK1E;;OAEG;IACG,WAAW,CAAC,cAAc,GAAE,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,IAAW;;;;CAmBzF"}
@@ -0,0 +1,34 @@
1
+ import VoucherClient from "../../Clients/VoucherClient";
2
+ import VoucherResponse from "../../Models/Responses/Vendor/VoucherResponse";
3
+ import TideKey from "../../Cryptide/TideKey";
4
+ import Ed25519Scheme from "../../Cryptide/Components/Schemes/Ed25519/Ed25519Scheme";
5
+ export default class VoucherFlow {
6
+ constructor(orkPaymentPublics, voucherURL, action) {
7
+ this.orkPaymentPublics = orkPaymentPublics;
8
+ this.voucherURL = voucherURL;
9
+ this.action = action;
10
+ }
11
+ /**
12
+ * I'm making this so I can use keycloak's client that has all of the keycloak's authorization built in.
13
+ */
14
+ async GetVouchers(clientFunction = null) {
15
+ let vouchers = undefined;
16
+ const k = TideKey.NewKey(Ed25519Scheme);
17
+ const blurKeyPub = await k.prepVouchersReq(this.orkPaymentPublics);
18
+ if (clientFunction == null) {
19
+ // get vouchers
20
+ const vendorClient = new VoucherClient(this.voucherURL);
21
+ vouchers = await vendorClient.GetVouchers(blurKeyPub, this.action, k.get_public_component().public);
22
+ }
23
+ else {
24
+ const request = JSON.stringify({
25
+ BlurPORKi: blurKeyPub.map(blur => blur.toBase64()),
26
+ ActionRequest: this.action,
27
+ BlurerK: k.get_public_component().public.toBase64()
28
+ });
29
+ const response = await clientFunction(request);
30
+ vouchers = VoucherResponse.from(response, k.get_public_component().public.toBase64());
31
+ }
32
+ return { vouchers, k };
33
+ }
34
+ }
@@ -0,0 +1,2 @@
1
+ export { default as VoucherFlow } from './VoucherFlow';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../Flow/VoucherFlows/index.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,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 VoucherFlow } from './VoucherFlow';
@@ -0,0 +1,5 @@
1
+ export * as DecryptionFlows from './DecryptionFlows';
2
+ export * as EncryptionFlows from './EncryptionFlows';
3
+ export * as SigningFlows from './SigningFlows';
4
+ export * as VoucherFlows from './VoucherFlows';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../Flow/index.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,eAAe,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,eAAe,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,YAAY,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,YAAY,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,20 @@
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 * as DecryptionFlows from './DecryptionFlows';
18
+ export * as EncryptionFlows from './EncryptionFlows';
19
+ export * as SigningFlows from './SigningFlows';
20
+ export * as VoucherFlows from './VoucherFlows';
@@ -0,0 +1,3 @@
1
+ import { Point } from "../Cryptide/Ed25519";
2
+ export declare function GetKeys(appliedC1s: Point[][], ids: bigint[]): Promise<Uint8Array<ArrayBuffer>[]>;
3
+ //# sourceMappingURL=KeyDecryption.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KeyDecryption.d.ts","sourceRoot":"","sources":["../../Math/KeyDecryption.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAI5C,wBAAsB,OAAO,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,sCAKjE"}
@@ -0,0 +1,24 @@
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 { SHA256_Digest } from "../Cryptide/Hashing/Hash";
18
+ import { AggregatePointArrays, GetLis } from "../Cryptide/Interpolation";
19
+ export async function GetKeys(appliedC1s, ids) {
20
+ // Apply Lis to points, sum result
21
+ const lis = GetLis(ids);
22
+ const appliedC1sWithLi = appliedC1s.map((c1, i) => c1.map(c => c.mul(lis[i])));
23
+ return Promise.all(AggregatePointArrays(appliedC1sWithLi).map(async (p) => SHA256_Digest(p.toRawBytes())));
24
+ }
@@ -0,0 +1,4 @@
1
+ import { Point } from "../Cryptide/Ed25519";
2
+ export declare function PreSign(GRij: Point[][]): Point[];
3
+ export declare function Sign(Sis: bigint[][]): bigint[];
4
+ //# sourceMappingURL=KeySigning.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KeySigning.d.ts","sourceRoot":"","sources":["../../Math/KeySigning.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAG5C,wBAAgB,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,WAGtC;AAED,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,YAGnC"}
@@ -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
+ import { Point } from "../Cryptide/Ed25519";
18
+ import { mod } from "../Cryptide/Math";
19
+ export function PreSign(GRij) {
20
+ if (!GRij.every(Gri => Gri.length == GRij[0].length))
21
+ throw new Error("Orks returned different amount of Grs");
22
+ return GRij[0].map((_, i) => GRij.reduce((sum, next) => sum.add(next[i]), Point.ZERO));
23
+ }
24
+ export function Sign(Sis) {
25
+ if (!Sis.every(Si => Si.length == Sis[0].length))
26
+ throw new Error("Orks returned different amount of Si");
27
+ return Sis[0].map((_, i) => mod(Sis.reduce((sum, next) => sum + next[i], BigInt(0))));
28
+ }
@@ -0,0 +1,3 @@
1
+ export * from './KeyDecryption';
2
+ export * from './KeySigning';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../Math/index.ts"],"names":[],"mappings":"AAiBA,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC"}
@@ -0,0 +1,18 @@
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 './KeyDecryption';
18
+ export * from './KeySigning';
@@ -0,0 +1,14 @@
1
+ export default class AuthRequest {
2
+ keyId: string;
3
+ purpose: string;
4
+ keyPub: string;
5
+ expiry: bigint;
6
+ sessionId: string;
7
+ dPoPApproval: string | undefined;
8
+ constructor(keyId: string, purpose: string, keyPub: string, expiry: bigint, sessionId?: string, dPopApproval?: string);
9
+ toUint8Array(): Uint8Array<ArrayBuffer>;
10
+ toString(): string;
11
+ static new(keyId: string, purpose: string, clientKey: string, expiry: bigint, sessionId?: string, clientDPoPKey?: string): AuthRequest;
12
+ static from(data: string): AuthRequest;
13
+ }
14
+ //# sourceMappingURL=AuthRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthRequest.d.ts","sourceRoot":"","sources":["../../Models/AuthRequest.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAC,OAAO,OAAO,WAAW;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;gBAErB,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAE,MAAa,EAAE,YAAY,GAAE,MAAa;IASjI,YAAY;IAGZ,QAAQ;IAYR,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAE,MAAa,EAAE,aAAa,GAAC,MAAa;IAInI,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM;CAI3B"}
@@ -0,0 +1,48 @@
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 { StringToUint8Array } from "../Cryptide/Serialization";
18
+ export default class AuthRequest {
19
+ constructor(keyId, purpose, keyPub, expiry, sessionId = null, dPopApproval = null) {
20
+ this.keyId = keyId;
21
+ this.purpose = purpose;
22
+ this.keyPub = keyPub;
23
+ this.expiry = expiry; // in seconds
24
+ this.sessionId = sessionId;
25
+ this.dPoPApproval = dPopApproval;
26
+ }
27
+ toUint8Array() {
28
+ return StringToUint8Array(this.toString());
29
+ }
30
+ toString() {
31
+ const json = {
32
+ 'User': this.keyId,
33
+ 'Purpose': this.purpose,
34
+ 'Key': this.keyPub,
35
+ 'Expiry': this.expiry.toString(),
36
+ 'SessionId': !this.sessionId ? "" : this.sessionId, // SessionId is optional (although mandatory for apps like keycloak)
37
+ 'DPoPApproval': this.dPoPApproval ? this.dPoPApproval : ""
38
+ };
39
+ return JSON.stringify(json);
40
+ }
41
+ static new(keyId, purpose, clientKey, expiry, sessionId = null, clientDPoPKey = null) {
42
+ return new AuthRequest(keyId, purpose, clientKey, expiry, sessionId, clientDPoPKey); // 30 seconds
43
+ }
44
+ static from(data) {
45
+ const json = JSON.parse(data);
46
+ return new AuthRequest(json.User, json.Purpose, json.Key, BigInt(json.Expiry), json.SessionId, json.ClientDPoPKey);
47
+ }
48
+ }
@@ -0,0 +1,55 @@
1
+ import { Doken } from "./Doken";
2
+ import { TideMemory } from "../Tools/TideMemory";
3
+ import { Policy } from "./Policy";
4
+ export default class BaseTideRequest {
5
+ static _name: string;
6
+ static _version: string;
7
+ name: string;
8
+ version: string;
9
+ authFlow: string;
10
+ draft: TideMemory;
11
+ dyanmicData: TideMemory;
12
+ authorization: TideMemory;
13
+ authorizerCert: TideMemory;
14
+ authorizer: TideMemory;
15
+ expiry: number;
16
+ policy: TideMemory;
17
+ constructor(name: string, version: string, authFlow: string, draft?: Uint8Array, dyanmicData?: Uint8Array);
18
+ id(): string;
19
+ /**
20
+ * This isn't copying. Just created another BaseTideRequest object that allows you to point each individual field to OTHER sections of memory.
21
+ * If you modify an existing 'replicated' field, you'll also modify the other object you originally replicated.
22
+ */
23
+ replicate(): BaseTideRequest;
24
+ setNewDynamicData(d: Uint8Array): this;
25
+ setCustomExpiry(timeFromNowInSeconds: number): this;
26
+ addAuthorizer(authorizer: Uint8Array): void;
27
+ addAuthorizerCertificate(authorizerCertificate: Uint8Array): void;
28
+ addAuthorization(authorization: Uint8Array): this;
29
+ addPolicy(policy: Uint8Array): this;
30
+ hasPolicy(): boolean;
31
+ dataToAuthorize(): Promise<Uint8Array<ArrayBuffer>>;
32
+ dataToApprove(): Promise<Uint8Array<ArrayBuffer>>;
33
+ getRequestInitDetails(): Promise<{
34
+ creationTime: Uint8Array<ArrayBufferLike>;
35
+ expireTime: Uint8Array<ArrayBufferLike>;
36
+ modelId: Uint8Array<ArrayBuffer>;
37
+ draftHash: TideMemory;
38
+ }>;
39
+ addCreationSignature(creationTime: Uint8Array, sig: Uint8Array): this;
40
+ isInitialized(): boolean;
41
+ getUniqueId(): string;
42
+ getInitializedTime(): number;
43
+ getCurrentApprovalCount(): number;
44
+ getPolicy(): Policy;
45
+ /**
46
+ * Add an approval for this request. To be used for policy auth flow
47
+ */
48
+ addApproval(doken: Doken, sig: Uint8Array): void;
49
+ removeApproval(approvalVuid: string): boolean;
50
+ encode(): TideMemory;
51
+ static decode<T extends BaseTideRequest>(this: new (name: string, version: string, authFlow: string, draft: Uint8Array, dynamicData: Uint8Array) => T, data: Uint8Array): T;
52
+ private static uint32ToUint8ArrayLE;
53
+ private static uint8ArrayToUint32LE;
54
+ }
55
+ //# sourceMappingURL=BaseTideRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseTideRequest.d.ts","sourceRoot":"","sources":["../../Models/BaseTideRequest.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAMlC,MAAM,CAAC,OAAO,OAAO,eAAe;IAChC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC;IAExB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,UAAU,CAAC;IAClB,WAAW,EAAE,UAAU,CAAC;IACxB,aAAa,EAAE,UAAU,CAAC;IAC1B,cAAc,EAAE,UAAU,CAAC;IAC3B,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,UAAU,CAAC;gBAEP,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,GAAE,UAA6B,EAAE,WAAW,GAAE,UAA6B;IAkB7I,EAAE;IAIF;;;OAGG;IACH,SAAS;IAUT,iBAAiB,CAAC,CAAC,EAAE,UAAU;IAM/B,eAAe,CAAC,oBAAoB,EAAE,MAAM;IAK5C,aAAa,CAAC,UAAU,EAAE,UAAU;IAKpC,wBAAwB,CAAC,qBAAqB,EAAE,UAAU;IAK1D,gBAAgB,CAAC,aAAa,EAAE,UAAU;IAM1C,SAAS,CAAC,MAAM,EAAE,UAAU;IAM5B,SAAS,IAAI,OAAO;IAKd,eAAe;IAKf,aAAa;IAOb,qBAAqB;;;;;;IAU3B,oBAAoB,CAAC,YAAY,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU;IAW9D,aAAa,IAAI,OAAO;IAUxB,WAAW,IAAI,MAAM;IAMrB,kBAAkB,IAAI,MAAM;IAM5B,uBAAuB,IAAI,MAAM;IAQjC,SAAS,IAAI,MAAM;IAInB;;OAEG;IACH,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,UAAU;IAgCzC,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO;IA0C7C,MAAM;IA2BN,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,eAAe,EACnC,IAAI,EAAE,KAAK,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,KAAK,CAAC,EAC5G,IAAI,EAAE,UAAU,GACjB,CAAC;IAyCJ,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAcnC,OAAO,CAAC,MAAM,CAAC,oBAAoB;CAoBtC"}