Skip to content

Commit d94520f

Browse files
Get rid of precompute encodings
1 parent b701e7e commit d94520f

File tree

14 files changed

+134
-320
lines changed

14 files changed

+134
-320
lines changed

examples/zktls/host/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ fn verify_by_zkvm(
126126
notary_pub_key: &NotaryPubKey,
127127
presentation: &Presentation,
128128
) -> Result<(Vec<u8>, ZkTlsProof, Receipt), Box<dyn std::error::Error>> {
129-
let mut presentation = presentation.clone();
130-
presentation.precompute_encodings()?;
129+
let presentation = presentation.clone();
131130

132131
let presentation_batch = PresentationBatch {
133132
notary_pub_key: notary_pub_key.clone(),

examples/zktls/ic-verifier/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub mod state;
1515
pub mod utils;
1616

1717
const ZKVM_IMAGE_ID: [u32; 8] = [
18-
1587164378, 3897773235, 1946063679, 3490198458, 3764178775, 283742902, 3039206025, 1480104475,
18+
3272774196, 2425320109, 1919992434, 1125400035, 2700290721, 2894536758, 2671926308, 321562171,
1919
];
2020

2121
/// Initializes the canister with an optional environment configuration

fixtures/assets/presentation/presentation_1kb.json

Lines changed: 54 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@
33
"signature": {
44
"alg": 1,
55
"data": [
6-
139, 141, 132, 95, 225, 23, 146, 91, 249, 150, 59, 155, 44, 155, 232,
7-
183, 225, 212, 181, 237, 127, 255, 218, 120, 50, 44, 248, 122, 172, 7,
8-
156, 55, 4, 127, 60, 213, 121, 174, 66, 137, 152, 175, 226, 83, 128, 28,
9-
69, 130, 247, 24, 194, 69, 245, 78, 88, 201, 216, 33, 33, 115, 220, 154,
10-
3, 109
6+
73, 174, 66, 162, 189, 171, 96, 214, 236, 185, 121, 132, 36, 175, 189,
7+
227, 138, 106, 242, 152, 198, 185, 18, 96, 142, 94, 205, 248, 219, 148,
8+
117, 68, 73, 198, 5, 219, 79, 79, 93, 214, 55, 134, 203, 147, 9, 129,
9+
69, 180, 131, 161, 91, 29, 171, 127, 208, 197, 206, 174, 180, 210, 219,
10+
199, 56, 104
1111
]
1212
},
1313
"header": {
1414
"id": [
15-
130, 129, 39, 243, 246, 222, 168, 77, 171, 144, 87, 159, 7, 63, 46, 58
15+
167, 147, 128, 174, 127, 172, 6, 153, 58, 107, 249, 64, 88, 188, 66, 128
1616
],
1717
"version": 0,
1818
"root": {
1919
"alg": 2,
2020
"value": [
21-
62, 158, 73, 155, 124, 18, 29, 12, 129, 230, 55, 77, 97, 96, 120, 253,
22-
129, 51, 7, 67, 158, 98, 81, 139, 189, 182, 129, 116, 19, 131, 114,
23-
125
21+
165, 158, 38, 52, 84, 241, 13, 225, 94, 77, 174, 219, 102, 36, 206,
22+
182, 22, 190, 117, 209, 111, 5, 175, 66, 14, 234, 48, 22, 237, 153,
23+
43, 152
2424
]
2525
}
2626
},
@@ -40,24 +40,21 @@
4040
"connection_info": {
4141
"id": 1,
4242
"data": {
43-
"time": 1757719544,
43+
"time": 1758227342,
4444
"version": "v1_2",
45-
"transcript_length": {
46-
"sent": 187,
47-
"received": 1274
48-
}
45+
"transcript_length": { "sent": 187, "received": 1274 }
4946
}
5047
},
5148
"server_ephemeral_key": {
5249
"id": 2,
5350
"data": {
5451
"type": "secp256r1",
5552
"key": [
56-
4, 250, 113, 152, 102, 112, 133, 52, 206, 188, 54, 92, 164, 99,
57-
85, 166, 4, 22, 46, 202, 154, 114, 99, 32, 92, 223, 70, 239, 61,
58-
99, 252, 91, 107, 209, 143, 171, 71, 46, 242, 3, 15, 226, 100, 95,
59-
236, 70, 189, 152, 48, 243, 26, 194, 70, 237, 93, 7, 28, 6, 186,
60-
135, 62, 24, 147, 122, 128
53+
4, 25, 200, 93, 168, 120, 131, 88, 23, 76, 4, 13, 113, 200, 60, 3,
54+
140, 200, 35, 45, 135, 141, 64, 135, 12, 148, 154, 18, 65, 51,
55+
187, 150, 135, 153, 90, 72, 187, 144, 33, 119, 41, 219, 24, 62,
56+
189, 132, 190, 192, 233, 226, 126, 93, 109, 32, 87, 23, 9, 232,
57+
101, 28, 43, 82, 103, 234, 170
6158
]
6259
}
6360
},
@@ -66,9 +63,9 @@
6663
"data": {
6764
"alg": 2,
6865
"value": [
69-
198, 34, 230, 11, 29, 204, 20, 133, 13, 100, 5, 205, 139, 160, 36,
70-
172, 255, 213, 41, 99, 179, 167, 220, 84, 186, 153, 108, 164, 174,
71-
53, 103, 124
66+
4, 225, 144, 109, 126, 153, 34, 142, 177, 95, 119, 105, 212, 142,
67+
225, 93, 23, 182, 32, 254, 151, 19, 205, 167, 92, 254, 135, 226,
68+
251, 249, 131, 225
7269
]
7370
}
7471
},
@@ -78,27 +75,21 @@
7875
"root": {
7976
"alg": 2,
8077
"value": [
81-
102, 7, 184, 138, 14, 85, 77, 134, 208, 35, 82, 206, 132, 111,
82-
153, 46, 34, 52, 152, 12, 176, 203, 80, 94, 151, 180, 101, 36,
83-
149, 136, 143, 145
78+
209, 227, 116, 194, 5, 81, 5, 123, 123, 116, 86, 132, 93, 175,
79+
97, 61, 212, 32, 31, 190, 105, 219, 142, 188, 159, 245, 238,
80+
120, 160, 196, 159, 148
8481
]
8582
},
8683
"seed": [
87-
91, 157, 197, 97, 69, 99, 11, 196, 215, 78, 110, 201, 14, 131,
88-
197, 237, 216, 9, 149, 187, 137, 172, 100, 83, 157, 226, 48, 0,
89-
96, 129, 108, 194
84+
123, 2, 37, 41, 138, 108, 225, 223, 239, 101, 104, 145, 175, 223,
85+
186, 175, 116, 185, 19, 48, 202, 155, 77, 28, 235, 171, 125, 38,
86+
156, 253, 164, 143
9087
]
9188
}
9289
},
9390
"plaintext_hashes": []
9491
},
95-
"proof": {
96-
"alg": 2,
97-
"tree_len": 5,
98-
"proof": {
99-
"proof_hashes": []
100-
}
101-
}
92+
"proof": { "alg": 2, "tree_len": 5, "proof": { "proof_hashes": [] } }
10293
}
10394
},
10495
"identity": {
@@ -243,40 +234,40 @@
243234
"sig": {
244235
"scheme": "ecdsa_nistp384_sha384",
245236
"sig": [
246-
48, 69, 2, 32, 102, 160, 122, 160, 216, 111, 95, 158, 70, 210, 55,
247-
242, 205, 18, 145, 192, 167, 17, 202, 207, 115, 41, 46, 102, 205,
248-
160, 58, 255, 170, 62, 112, 148, 2, 33, 0, 149, 47, 36, 191, 52, 12,
249-
6, 63, 48, 13, 126, 116, 66, 225, 163, 243, 252, 98, 61, 137, 151,
250-
125, 128, 60, 124, 227, 6, 25, 167, 21, 240, 183
237+
48, 68, 2, 32, 101, 230, 219, 87, 9, 97, 150, 27, 19, 82, 106, 251,
238+
211, 141, 231, 227, 110, 103, 54, 199, 160, 46, 65, 91, 234, 201,
239+
212, 214, 38, 179, 44, 167, 2, 32, 101, 32, 68, 52, 112, 222, 99,
240+
13, 158, 49, 52, 18, 188, 37, 41, 25, 128, 188, 170, 138, 171, 45,
241+
97, 172, 176, 112, 155, 190, 205, 69, 176, 213
251242
]
252243
},
253244
"handshake": {
254245
"v1_2": {
255246
"client_random": [
256-
80, 161, 177, 154, 17, 54, 152, 62, 186, 156, 71, 70, 74, 234,
257-
189, 189, 139, 98, 126, 146, 196, 159, 177, 126, 77, 237, 194,
258-
215, 159, 14, 172, 13
247+
50, 204, 57, 166, 242, 101, 162, 208, 148, 114, 17, 129, 142, 101,
248+
214, 26, 46, 223, 226, 11, 22, 123, 4, 78, 8, 137, 128, 16, 189,
249+
198, 70, 234
259250
],
260251
"server_random": [
261-
53, 38, 36, 7, 244, 115, 218, 106, 51, 163, 208, 239, 122, 8, 166,
262-
156, 205, 239, 140, 71, 129, 2, 49, 76, 68, 79, 87, 78, 71, 82,
263-
68, 1
252+
32, 82, 42, 123, 19, 42, 25, 206, 125, 121, 236, 184, 157, 213,
253+
114, 130, 158, 68, 90, 68, 236, 123, 126, 249, 68, 79, 87, 78, 71,
254+
82, 68, 1
264255
],
265256
"server_ephemeral_key": {
266257
"type": "secp256r1",
267258
"key": [
268-
4, 250, 113, 152, 102, 112, 133, 52, 206, 188, 54, 92, 164, 99,
269-
85, 166, 4, 22, 46, 202, 154, 114, 99, 32, 92, 223, 70, 239, 61,
270-
99, 252, 91, 107, 209, 143, 171, 71, 46, 242, 3, 15, 226, 100,
271-
95, 236, 70, 189, 152, 48, 243, 26, 194, 70, 237, 93, 7, 28, 6,
272-
186, 135, 62, 24, 147, 122, 128
259+
4, 25, 200, 93, 168, 120, 131, 88, 23, 76, 4, 13, 113, 200, 60,
260+
3, 140, 200, 35, 45, 135, 141, 64, 135, 12, 148, 154, 18, 65,
261+
51, 187, 150, 135, 153, 90, 72, 187, 144, 33, 119, 41, 219, 24,
262+
62, 189, 132, 190, 192, 233, 226, 126, 93, 109, 32, 87, 23, 9,
263+
232, 101, 28, 43, 82, 103, 234, 170
273264
]
274265
}
275266
}
276267
}
277268
},
278269
"blinder": [
279-
212, 229, 12, 55, 148, 236, 81, 220, 226, 21, 124, 253, 206, 24, 222, 33
270+
86, 68, 54, 71, 37, 40, 50, 244, 173, 130, 251, 43, 197, 218, 55, 225
280271
]
281272
}
282273
},
@@ -285,27 +276,20 @@
285276
"inclusion_proof": {
286277
"alg": 2,
287278
"tree_len": 2,
288-
"proof": {
289-
"proof_hashes": []
290-
}
279+
"proof": { "proof_hashes": [] }
291280
},
292281
"openings": {
293282
"0": {
294283
"direction": "Received",
295284
"seq": {
296-
"idx": [
297-
{
298-
"start": 0,
299-
"end": 1274
300-
}
301-
],
285+
"idx": [{ "start": 0, "end": 1274 }],
302286
"data": [
303287
72, 84, 84, 80, 47, 49, 46, 49, 32, 50, 48, 48, 32, 79, 75, 13,
304288
10, 83, 101, 114, 118, 101, 114, 58, 32, 110, 103, 105, 110, 120,
305289
47, 49, 46, 50, 52, 46, 48, 32, 40, 85, 98, 117, 110, 116, 117,
306-
41, 13, 10, 68, 97, 116, 101, 58, 32, 70, 114, 105, 44, 32, 49,
307-
50, 32, 83, 101, 112, 32, 50, 48, 50, 53, 32, 50, 51, 58, 50, 53,
308-
58, 52, 55, 32, 71, 77, 84, 13, 10, 67, 111, 110, 116, 101, 110,
290+
41, 13, 10, 68, 97, 116, 101, 58, 32, 84, 104, 117, 44, 32, 49,
291+
56, 32, 83, 101, 112, 32, 50, 48, 50, 53, 32, 50, 48, 58, 50, 57,
292+
58, 48, 54, 32, 71, 77, 84, 13, 10, 67, 111, 110, 116, 101, 110,
309293
116, 45, 84, 121, 112, 101, 58, 32, 97, 112, 112, 108, 105, 99,
310294
97, 116, 105, 111, 110, 47, 106, 115, 111, 110, 13, 10, 67, 111,
311295
110, 116, 101, 110, 116, 45, 76, 101, 110, 103, 116, 104, 58, 32,
@@ -393,24 +377,13 @@
393377
]
394378
},
395379
"blinder": [
396-
222, 82, 182, 82, 57, 59, 157, 43, 228, 168, 141, 144, 210, 26, 73,
397-
253
398-
],
399-
"encoding": null
380+
25, 75, 95, 126, 9, 46, 169, 203, 10, 177, 233, 160, 73, 18, 211, 71
381+
]
400382
},
401383
"1": {
402384
"direction": "Sent",
403385
"seq": {
404-
"idx": [
405-
{
406-
"start": 0,
407-
"end": 173
408-
},
409-
{
410-
"start": 183,
411-
"end": 187
412-
}
413-
],
386+
"idx": [{ "start": 0, "end": 173 }, { "start": 183, "end": 187 }],
414387
"data": [
415388
71, 69, 84, 32, 104, 116, 116, 112, 115, 58, 47, 47, 109, 111, 99,
416389
107, 46, 118, 101, 114, 105, 116, 121, 46, 117, 115, 104, 101,
@@ -428,10 +401,9 @@
428401
]
429402
},
430403
"blinder": [
431-
80, 210, 185, 201, 253, 177, 124, 136, 108, 110, 28, 190, 61, 172,
432-
96, 66
433-
],
434-
"encoding": null
404+
184, 8, 57, 29, 96, 79, 227, 174, 128, 235, 246, 227, 88, 111, 126,
405+
30
406+
]
435407
}
436408
}
437409
},

0 commit comments

Comments
 (0)