chily 0.8.2__cp313-none-win32.whl

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.
chily/__init__.py ADDED
@@ -0,0 +1,5 @@
1
+ from .chily import *
2
+
3
+ __doc__ = chily.__doc__
4
+ if hasattr(chily, "__all__"):
5
+ __all__ = chily.__all__
Binary file
@@ -0,0 +1,194 @@
1
+ Metadata-Version: 2.3
2
+ Name: chily
3
+ Version: 0.8.2
4
+ Summary: Crypto wrapper library for the Decentriq platform.
5
+ Author: "decentriq" <opensource@decentriq.ch>
6
+ Author-email: "decentriq" <opensource@decentriq.ch>
7
+ Maintainer-email: decentriq <opensource@decentriq.ch>
8
+ Requires-Python: >=3.6
9
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
10
+
11
+ ## 🌶 CryptoLib: chily
12
+
13
+ ### Authenticated Encryption
14
+
15
+ The plan for `chily` is to have pure Rust implementation for the following crypto protocols (following RFC 7539):
16
+
17
+ - Key exchange: X25519
18
+ - Encryption: XSalsa20 stream cipher
19
+ - Authentication: Poly1305 MAC
20
+
21
+ In contrast to RFC 7530 we use XChaCha20 instead of ChaCha in order to have a 24 byte nonce (instead of 96bits).
22
+
23
+ ### Randomness
24
+
25
+ We heavily rely on "secure" randomness in this library. Mainly for key generation in the enclave (no external static key can be provided) and nonce derivation. Depending on the target we use the following sources:
26
+
27
+ - x64: `getrandom` system call if available, otherwise `/dev/urandom`
28
+ - SGX: Based on `rdrand` instructions of the CPU ([https://docs.rs/rdrand/0.6.0/rdrand/](https://docs.rs/rdrand/0.6.0/rdrand/))
29
+ - WASM: `Crypto.getRandomValues` exposed by the JS engine via `wasm-bindgen` bridge
30
+
31
+ ## 🚴 Usage
32
+
33
+ ### Rust
34
+
35
+ Just add `chily` as a dependency and see how it's being used in the following example:
36
+
37
+ ```rust
38
+ // generate random keypair
39
+ let alice = Keypair::generate();
40
+
41
+ // or parse a secret from existing bytes
42
+ let bob_secret: [u8; 32] = [
43
+ 64, 218, 126, 251, 171, 87, 50, 212, 196, 55, 166, 65, 195, 199, 64, 229, 128, 129,
44
+ 243, 144, 211, 52, 77, 159, 48, 167, 45, 8, 79, 228, 116, 101,
45
+ ];
46
+ // and then create the keypair
47
+ let bob = Keypair::from_secret_key(bob_secret.into());
48
+
49
+ // define some buffer
50
+ let plaintext = b"avato rocks";
51
+ let mut buffer = plaintext.to_vec();
52
+
53
+ // create a random Nonce
54
+ let nonce = Nonce::from_random();
55
+
56
+ // instantiate the cipher
57
+ let mut cipher = Cipher::new(&alice.secret, &bob.public);
58
+
59
+ // encrypt in place
60
+ let tag = cipher.encrypt_in_place_detached(&mut buffer, b"", &nonce);
61
+
62
+ // decrypt in place
63
+ cipher.decrypt_in_place_detached(&mut buffer, b"", &nonce, &tag);
64
+
65
+ assert_eq!(plaintext.to_vec(), buffer); // Ok!
66
+ ```
67
+
68
+ ### JavaScript / TypeScript
69
+
70
+ Add the package from folder `js/pkg` as dependency to the `package.json` in your project:
71
+ ```
72
+ "dependencies": {
73
+ "chily": "file:chily-0.2.0.tgz"
74
+ }
75
+ ```
76
+
77
+ Then the library can be used as shown below:
78
+
79
+ ```ts
80
+ import * as chily from "chily";
81
+
82
+ // generate random keypair
83
+ let alice = chily.Keypair.fromRandom();
84
+
85
+ // or parse a secret from existing bytes
86
+ let bob_secret = chily.StaticSecret.fromBytes(new Uint8Array([
87
+ 64, 218, 126, 251, 171, 87, 50, 212, 196, 55, 166, 65, 195, 199, 64, 229, 128, 129,
88
+ 243, 144, 211, 52, 77, 159, 48, 167, 45, 8, 79, 228, 116, 101,
89
+ ]));
90
+ // and then create the keypair
91
+ let bob = chily.Keypair.fromSecret(bob_secret);
92
+
93
+ // create a random Nonce
94
+ let nonce = chily.Nonce.fromRandom();
95
+
96
+ // instantiate the cipher
97
+ let cipher = chily.Cipher.new(alice.secret, bob.publicKey);
98
+
99
+ // define some buffer
100
+ var plaintext = new Uint8Array([21,31]);
101
+
102
+ // encrypt
103
+ let encrypted = cipher.encrypt(plaintext, nonce);
104
+
105
+ // decrypt
106
+ let decrypted = cipher.decrypt(encrypted, nonce);
107
+
108
+ expect(plaintext).to.eql(decrypted); // Ok!
109
+ ```
110
+
111
+ ### Python
112
+
113
+ Install the wheel from folder `py/pkg` by running `pip3 install chily.whl`
114
+ Then the library can be used as shown below:
115
+
116
+ ```python
117
+ import chily
118
+
119
+ # generate random keypair
120
+ alice = chily.Keypair.from_random();
121
+
122
+ # or parse a secret from existing bytes
123
+ bob_secret = chily.StaticSecret.from_bytes([
124
+ 64, 218, 126, 251, 171, 87, 50, 212, 196, 55, 166, 65, 195, 199, 64, 229, 128, 129,
125
+ 243, 144, 211, 52, 77, 159, 48, 167, 45, 8, 79, 228, 116, 101,
126
+ ])
127
+ # and then create the keypair
128
+ bob = chily.Keypair.from_secret(bob_secret)
129
+
130
+ # create a random Nonce
131
+ nonce = chily.Nonce.from_random();
132
+
133
+ # instantiate the cipher
134
+ cipher = chily.Cipher(alice.secret, bob.publicKey, nonce)
135
+
136
+ # define some buffer
137
+ plaintext = [21,31]
138
+
139
+ # encrypt
140
+ enc = cipher.encrypt(plaintext, nonce)
141
+
142
+ # decrypt
143
+ dec = cipher.decrypt(enc, nonce)
144
+
145
+ assert plaintext == dec
146
+ ```
147
+
148
+ ## 🛠️ Test
149
+ We have four different test stages.
150
+
151
+ ### Rust
152
+ Regular tests written in Rust. Just call `cargo test`.
153
+
154
+ ### WASM
155
+ Some test can be specified to run in the node wasm interpreter. They are defined using the `[wasm_bindgen_test]` attribute. In order to run them go execute the following command in the `js` folder:
156
+ ```bash
157
+ npm run wasm-test
158
+ ```
159
+
160
+ ### JavaScript / TypeScript
161
+ There also are some tests for the JavaScript bindings using `mocha` and `chai`.
162
+ They are defined in the folder `js/tests` and can be run using the following command:
163
+ ```bash
164
+ npm run test
165
+ ```
166
+
167
+ ### Python
168
+ There also are some tests for the Python bindings using `tox`.
169
+ They are defined in the folder `py/tests` and can be run using the following command:
170
+ ```bash
171
+ tox
172
+ ```
173
+
174
+ ## 🎁 Build & Package
175
+
176
+ ### JavaScript / TypeScript
177
+ To build the wasm code and the js/ts binding run in the `js` folder:
178
+ * `npm run build-node` for nodejs
179
+ * `npm run build-bundler` for browser / webpack
180
+ * `npm run build` for one compatible with both
181
+
182
+ Then package the dependency by running `npm pack` in the corresponding `pkg` dir.
183
+
184
+ ### Python
185
+ To build the python bindings you'll need `maturin`. Run in the `py` folder:
186
+ * `pip3 install maturin` to install maturin
187
+ * `./build.sh` to build the wheel for the current platform in the pkg folder
188
+
189
+ ## 🔋 ToDos
190
+
191
+ * Add X.509 cert support
192
+ * Error handling
193
+ * Add Poly1305 MAC
194
+
@@ -0,0 +1,5 @@
1
+ chily-0.8.2.dist-info/METADATA,sha256=7cdxzioty2j5kMwB74Teg4yelsKSH4e6vyjF1DoqMo8,5701
2
+ chily-0.8.2.dist-info/WHEEL,sha256=WfGDYcfyrwHJGrJdYOfcTSq__NLnyswWxmOIqe7ZQM0,91
3
+ chily/__init__.py,sha256=IHgXeyQAiRo9B3oOnajw3XcyFjb58iTScLZ4d17Ld0c,103
4
+ chily/chily.cp313-win32.pyd,sha256=zo-k0d0xTPnjMglq90It0UIoVLMvzM5wwqpoUyiYN0Y,464896
5
+ chily-0.8.2.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.7.4)
3
+ Root-Is-Purelib: false
4
+ Tag: cp313-none-win32