@@ -72,8 +72,7 @@ pub fn compute_encrypted_note_log<Note, let N: u32, let M: u32>(
72
72
ovpk : OvpkM ,
73
73
ivpk : IvpkM ,
74
74
recipient : AztecAddress ,
75
- note : Note ,
76
- num_public_values : u8 // Number of values to be appended to the log in public (used in partial note flow).
75
+ note : Note
77
76
) -> [u8 ; M ] where Note : NoteInterface <N > {
78
77
let (eph_sk , eph_pk ) = generate_ephemeral_key_pair ();
79
78
@@ -87,29 +86,27 @@ pub fn compute_encrypted_note_log<Note, let N: u32, let M: u32>(
87
86
let mut encrypted_bytes : [u8 ; M ] = [0 ; M ];
88
87
// @todo We ignore the tags for now
89
88
90
- encrypted_bytes [64 ] = num_public_values ; // TODO(#8558): This can be just a single bit if we store info about partial fields in ABI
91
89
let eph_pk_bytes = point_to_bytes (eph_pk );
92
90
for i in 0 ..32 {
93
- encrypted_bytes [65 + i ] = eph_pk_bytes [i ];
91
+ encrypted_bytes [64 + i ] = eph_pk_bytes [i ];
94
92
}
95
93
for i in 0 ..48 {
96
- encrypted_bytes [97 + i ] = incoming_header_ciphertext [i ];
97
- encrypted_bytes [145 + i ] = outgoing_header_ciphertext [i ];
94
+ encrypted_bytes [96 + i ] = incoming_header_ciphertext [i ];
95
+ encrypted_bytes [144 + i ] = outgoing_header_ciphertext [i ];
98
96
}
99
97
for i in 0 ..144 {
100
- encrypted_bytes [193 + i ] = outgoing_body_ciphertext [i ];
98
+ encrypted_bytes [192 + i ] = outgoing_body_ciphertext [i ];
101
99
}
102
100
// Then we fill in the rest as the incoming body ciphertext
103
- let size = M - 337 ;
101
+ let size = M - 336 ;
104
102
assert_eq (size , incoming_body_ciphertext .len (), "ciphertext length mismatch" );
105
103
for i in 0 ..size {
106
- encrypted_bytes [337 + i ] = incoming_body_ciphertext [i ];
104
+ encrypted_bytes [336 + i ] = incoming_body_ciphertext [i ];
107
105
}
108
106
109
107
// Current unoptimized size of the encrypted log
110
108
// incoming_tag (32 bytes)
111
109
// outgoing_tag (32 bytes)
112
- // num_public_values (1 byte)
113
110
// eph_pk (32 bytes)
114
111
// incoming_header (48 bytes)
115
112
// outgoing_header (48 bytes)
@@ -173,88 +170,22 @@ mod test {
173
170
let _ = OracleMock ::mock ("getRandomField" ).returns (eph_sk );
174
171
175
172
let recipient = AztecAddress ::from_field (0x10ee41ee4b62703b16f61e03cb0d88c4b306a9eb4a6ceeb2aff13428541689a2 );
176
- let num_public_values : u8 = 0 ;
177
173
178
- let log : [u8 ; 449 ] = compute_encrypted_note_log (
174
+ let log : [u8 ; 448 ] = compute_encrypted_note_log (
179
175
contract_address ,
180
176
storage_slot ,
181
177
ovsk_app ,
182
178
ovpk_m ,
183
179
ivpk_m ,
184
180
recipient ,
185
- note ,
186
- num_public_values
181
+ note
187
182
);
188
183
189
184
// The following value was generated by `tagged_log.test.ts`
190
185
// --> Run the test with AZTEC_GENERATE_TEST_DATA=1 flag to update test data.
191
186
let encrypted_note_log_from_typescript = [
192
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 141, 70, 12, 14, 67, 77, 132, 110, 193, 234, 40, 110, 64, 144, 235, 86, 55, 111, 242, 123, 221, 193, 170, 202, 225, 216, 86, 84, 159, 112, 31, 167, 126, 79, 51, 186, 47, 71, 253, 172, 99, 112, 241, 59, 197, 241, 107, 186, 232, 87, 187, 230, 171, 62, 228, 234, 42, 51, 145, 146, 238, 242, 42, 71, 206, 13, 244, 66, 111, 195, 20, 203, 98, 148, 204, 242, 145, 183, 156, 29, 141, 54, 44, 220, 194, 35, 229, 16, 32, 204, 211, 49, 142, 112, 82, 202, 116, 241, 254, 146, 42, 217, 20, 189, 70, 228, 182, 171, 205, 104, 27, 99, 171, 28, 91, 244, 21, 30, 130, 240, 5, 72, 174, 124, 97, 197, 157, 248, 193, 23, 193, 76, 46, 141, 144, 70, 211, 45, 67, 167, 218, 129, 140, 104, 190, 41, 110, 249, 209, 68, 106, 135, 164, 80, 235, 63, 101, 80, 32, 13, 38, 99, 145, 91, 11, 173, 151, 231, 247, 65, 153, 117, 229, 167, 64, 239, 182, 126, 235, 83, 4, 169, 8, 8, 160, 4, 235, 252, 21, 96, 84, 161, 69, 145, 145, 215, 254, 161, 117, 246, 198, 65, 89, 179, 194, 90, 19, 121, 12, 202, 114, 80, 195, 14, 60, 128, 105, 142, 100, 86, 90, 108, 157, 219, 22, 172, 20, 121, 195, 25, 159, 236, 2, 70, 75, 42, 37, 34, 2, 17, 149, 20, 176, 32, 18, 204, 56, 117, 121, 34, 15, 3, 88, 123, 64, 68, 74, 233, 63, 59, 131, 222, 194, 192, 167, 110, 217, 10, 128, 73, 129, 172, 205, 103, 212, 60, 151, 141, 10, 151, 222, 151, 180, 43, 91, 148, 201, 110, 165, 10, 238, 32, 134, 235, 99, 216, 200, 182, 31, 22, 156, 18, 209, 222, 172, 239, 193, 212, 86, 99, 62, 70, 182, 45, 175, 241, 91, 202, 179, 225, 236, 95, 71, 66, 151, 225, 203, 53, 216, 85, 102, 130, 6, 8, 25, 180, 86, 58, 140, 198, 105, 102, 177, 42, 94, 115, 247, 145, 147, 24, 231, 39, 73, 27, 10, 219, 130, 115, 188, 74, 114, 5, 177, 199, 83, 183, 106, 87, 204, 238, 231, 72, 45, 240, 39, 174, 25, 98, 53, 187, 156, 159, 244, 38
187
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 141, 70, 12, 14, 67, 77, 132, 110, 193, 234, 40, 110, 64, 144, 235, 86, 55, 111, 242, 123, 221, 193, 170, 202, 225, 216, 86, 84, 159, 112, 31, 167, 126, 79, 51, 186, 47, 71, 253, 172, 99, 112, 241, 59, 197, 241, 107, 186, 232, 87, 187, 230, 171, 62, 228, 234, 42, 51, 145, 146, 238, 242, 42, 71, 206, 13, 244, 66, 111, 195, 20, 203, 98, 148, 204, 242, 145, 183, 156, 29, 141, 54, 44, 220, 194, 35, 229, 16, 32, 204, 211, 49, 142, 112, 82, 202, 116, 241, 254, 146, 42, 217, 20, 189, 70, 228, 182, 171, 205, 104, 27, 99, 171, 28, 91, 244, 21, 30, 130, 240, 5, 72, 174, 124, 97, 197, 157, 248, 193, 23, 193, 76, 46, 141, 144, 70, 211, 45, 67, 167, 218, 129, 140, 104, 190, 41, 110, 249, 209, 68, 106, 135, 164, 80, 235, 63, 101, 80, 32, 13, 38, 99, 145, 91, 11, 173, 151, 231, 247, 65, 153, 117, 229, 167, 64, 239, 182, 126, 235, 83, 4, 169, 8, 8, 160, 4, 235, 252, 21, 96, 84, 161, 69, 145, 145, 215, 254, 161, 117, 246, 198, 65, 89, 179, 194, 90, 19, 121, 12, 202, 114, 80, 195, 14, 60, 128, 105, 142, 100, 86, 90, 108, 157, 219, 22, 172, 20, 121, 195, 25, 159, 236, 2, 70, 75, 42, 37, 34, 2, 17, 149, 20, 176, 32, 18, 204, 56, 117, 121, 34, 15, 3, 88, 123, 64, 68, 74, 233, 63, 59, 131, 222, 194, 192, 167, 110, 217, 10, 128, 73, 129, 172, 205, 103, 212, 60, 151, 141, 10, 151, 222, 151, 180, 43, 91, 148, 201, 110, 165, 10, 238, 32, 134, 235, 99, 216, 200, 182, 31, 22, 156, 18, 209, 222, 172, 239, 193, 212, 86, 99, 62, 70, 182, 45, 175, 241, 91, 202, 179, 225, 236, 95, 71, 66, 151, 225, 203, 53, 216, 85, 102, 130, 6, 8, 25, 180, 86, 58, 140, 198, 105, 102, 177, 42, 94, 115, 247, 145, 147, 24, 231, 39, 73, 27, 10, 219, 130, 115, 188, 74, 114, 5, 177, 199, 83, 183, 106, 87, 204, 238, 231, 72, 45, 240, 39, 174, 25, 98, 53, 187, 156, 159, 244, 38
193
188
];
194
189
assert_eq (encrypted_note_log_from_typescript , log );
195
190
}
196
-
197
- #[test]
198
- unconstrained fn test_encrypted_note_log_of_finalized_partial_note_matches_typescript () {
199
- // All the values in this test were copied over from `tagged_log.test.ts`
200
- let contract_address = AztecAddress ::from_field (0x10f48cd9eff7ae5b209c557c70de2e657ee79166868676b787e9417e19260e04 );
201
- let storage_slot = 0x0fe46be583b71f4ab5b70c2657ff1d05cccf1d292a9369628d1a194f944e6599 ;
202
- let ovsk_app = 0x03a6513d6def49f41d20373d2cec894c23e7492794b08fc50c0e8a1bd2512612 ;
203
- let ovpk_m = OvpkM {
204
- inner : Point {
205
- x : 0x1961448682803198631f299340e4206bb12809d4bebbf012b30f59af73ba1a15 ,
206
- y : 0x133674060c3925142aceb4f1dcd9f9137d0217d37ff8729ee5ceaa6e2790353d ,
207
- is_infinite : false
208
- }
209
- };
210
- let ivpk_m = IvpkM {
211
- inner : Point {
212
- x : 0x260cd3904f6df16e974c29944fdc839e40fb5cf293f03df2eb370851d3a527bc ,
213
- y : 0x0eef2964fe6640e84c82b5d2915892409b38e9e25d39f68dd79edb725c55387f ,
214
- is_infinite : false
215
- }
216
- };
217
-
218
- let note_value = 0x301640ceea758391b2e161c92c0513f129020f4125256afdae2646ce31099f5c ;
219
- let note_public_value1 = 0x14172339287e8d281545c177313f02b6aa2fedfd628cfd8b7f11a136fd0d6557 ;
220
- let note_public_value2 = 0x0834d81e3f73c7e2809b08ae38600ffc76a2554473eeab6de7bff4b33a84feac ;
221
- let note = MockNoteBuilder ::new (note_value ).contract_address (contract_address ).storage_slot (storage_slot ).build ();
222
-
223
- let eph_sk = 0x1358d15019d4639393d62b97e1588c095957ce74a1c32d6ec7d62fe6705d9538 ;
224
- let _ = OracleMock ::mock ("getRandomField" ).returns (eph_sk );
225
-
226
- let recipient = AztecAddress ::from_field (0x10ee41ee4b62703b16f61e03cb0d88c4b306a9eb4a6ceeb2aff13428541689a2 );
227
- let num_public_values : u8 = 2 ;
228
-
229
- // First we compute the encrypted log without the public values
230
- let log_without_public_values : [u8 ; 449 ] = compute_encrypted_note_log (
231
- contract_address ,
232
- storage_slot ,
233
- ovsk_app ,
234
- ovpk_m ,
235
- ivpk_m ,
236
- recipient ,
237
- note ,
238
- num_public_values
239
- );
240
-
241
- // Then we "append" the public values to the log by copying both the original log and the current log into a new byte array
242
- let mut log : [u8 ; 513 ] = [0 ; 513 ];
243
- for i in 0 ..449 {
244
- log [i ] = log_without_public_values [i ];
245
- }
246
- let note_public_value1_bytes : [u8 ; 32 ] = note_public_value1 .to_be_bytes ();
247
- let note_public_value2_bytes : [u8 ; 32 ] = note_public_value2 .to_be_bytes ();
248
- for i in 0 ..32 {
249
- log [449 + i ] = note_public_value1_bytes [i ];
250
- log [481 + i ] = note_public_value2_bytes [i ];
251
- }
252
-
253
- // The following value was generated by `tagged_log.test.ts`
254
- // --> Run the test with AZTEC_GENERATE_TEST_DATA=1 flag to update test data.
255
- let encrypted_note_log_of_finalized_partial_from_typescript = [
256
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 141, 70, 12, 14, 67, 77, 132, 110, 193, 234, 40, 110, 64, 144, 235, 86, 55, 111, 242, 123, 221, 193, 170, 202, 225, 216, 86, 84, 159, 112, 31, 167, 126, 79, 51, 186, 47, 71, 253, 172, 99, 112, 241, 59, 197, 241, 107, 186, 232, 87, 187, 230, 171, 62, 228, 234, 42, 51, 145, 146, 238, 242, 42, 71, 206, 13, 244, 66, 111, 195, 20, 203, 98, 148, 204, 242, 145, 183, 156, 29, 141, 54, 44, 220, 194, 35, 229, 16, 32, 204, 211, 49, 142, 112, 82, 202, 116, 241, 254, 146, 42, 217, 20, 189, 70, 228, 182, 171, 205, 104, 27, 99, 171, 28, 91, 244, 21, 30, 130, 240, 5, 72, 174, 124, 97, 197, 157, 248, 193, 23, 193, 76, 46, 141, 144, 70, 211, 45, 67, 167, 218, 129, 140, 104, 190, 41, 110, 249, 209, 68, 106, 135, 164, 80, 235, 63, 101, 80, 32, 13, 38, 99, 145, 91, 11, 173, 151, 231, 247, 65, 153, 117, 229, 167, 64, 239, 182, 126, 235, 83, 4, 169, 8, 8, 160, 4, 235, 252, 21, 96, 84, 161, 69, 145, 145, 215, 254, 161, 117, 246, 198, 65, 89, 179, 194, 90, 19, 121, 12, 202, 114, 80, 195, 14, 60, 128, 105, 142, 100, 86, 90, 108, 157, 219, 22, 172, 20, 121, 195, 25, 159, 236, 2, 70, 75, 42, 37, 34, 2, 17, 149, 20, 176, 32, 18, 204, 56, 117, 121, 34, 15, 3, 88, 123, 64, 68, 74, 233, 63, 59, 131, 222, 194, 192, 167, 110, 217, 10, 128, 73, 129, 172, 205, 103, 212, 60, 151, 141, 10, 151, 222, 151, 180, 43, 91, 148, 201, 110, 165, 10, 238, 32, 134, 235, 99, 216, 200, 182, 31, 22, 156, 18, 209, 222, 172, 239, 193, 212, 86, 99, 62, 70, 182, 45, 175, 241, 91, 202, 179, 225, 236, 95, 71, 66, 151, 225, 203, 53, 216, 85, 102, 130, 6, 8, 25, 180, 86, 58, 140, 198, 105, 102, 177, 42, 94, 115, 247, 145, 147, 24, 231, 39, 73, 27, 10, 219, 130, 115, 188, 74, 114, 5, 177, 199, 83, 183, 106, 87, 204, 238, 231, 72, 45, 240, 39, 174, 25, 98, 53, 187, 156, 159, 244, 38, 20, 23, 35, 57, 40, 126, 141, 40, 21, 69, 193, 119, 49, 63, 2, 182, 170, 47, 237, 253, 98, 140, 253, 139, 127, 17, 161, 54, 253, 13, 101, 87, 8, 52, 216, 30, 63, 115, 199, 226, 128, 155, 8, 174, 56, 96, 15, 252, 118, 162, 85, 68, 115, 238, 171, 109, 231, 191, 244, 179, 58, 132, 254, 172
257
- ];
258
- assert_eq (encrypted_note_log_of_finalized_partial_from_typescript , log );
259
- }
260
191
}
0 commit comments