@@ -136,6 +136,11 @@ pub struct BackedUpRoomKey {
136
136
137
137
/// Chain of Curve25519 keys through which this session was forwarded, via
138
138
/// m.forwarded_room_key events.
139
+ #[ serde(
140
+ default ,
141
+ deserialize_with = "deserialize_curve_key_vec" ,
142
+ serialize_with = "serialize_curve_key_vec"
143
+ ) ]
139
144
pub forwarding_curve25519_key_chain : Vec < Curve25519PublicKey > ,
140
145
}
141
146
@@ -245,3 +250,33 @@ impl TryFrom<ForwardedRoomKeyContent> for ExportedRoomKey {
245
250
}
246
251
}
247
252
}
253
+
254
+ #[ cfg( test) ]
255
+ mod tests {
256
+ use serde_json:: json;
257
+
258
+ use super :: BackedUpRoomKey ;
259
+
260
+ #[ test]
261
+ fn test_deserialize_backed_up_key ( ) {
262
+ let data = json ! ( {
263
+ "algorithm" : "m.megolm.v1.aes-sha2" ,
264
+ "room_id" : "!room:id" ,
265
+ "sender_key" : "FOvlmz18LLI3k/llCpqRoKT90+gFF8YhuL+v1YBXHlw" ,
266
+ "session_id" : "/2K+V777vipCxPZ0gpY9qcpz1DYaXwuMRIu0UEP0Wa0" ,
267
+ "session_key" : "AQAAAAAclzWVMeWBKH+B/WMowa3rb4ma3jEl6n5W4GCs9ue65CruzD3ihX+85pZ9hsV9Bf6fvhjp76WNRajoJYX0UIt7aosjmu0i+H+07hEQ0zqTKpVoSH0ykJ6stAMhdr6Q4uW5crBmdTTBIsqmoWsNJZKKoE2+ldYrZ1lrFeaJbjBIY/9ivle++74qQsT2dIKWPanKc9Q2Gl8LjESLtFBD9Fmt" ,
268
+ "sender_claimed_keys" : {
269
+ "ed25519" : "F4P7f1Z0RjbiZMgHk1xBCG3KC4/Ng9PmxLJ4hQ13sHA"
270
+ } ,
271
+ "forwarding_curve25519_key_chain" : [ "DBPC2zr6c9qimo9YRFK3RVr0Two/I6ODb9mbsToZN3Q" , "bBc/qzZFOOKshMMT+i4gjS/gWPDoKfGmETs9yfw9430" ]
272
+ } ) ;
273
+
274
+ let backed_up_room_key: BackedUpRoomKey = serde_json:: from_value ( data)
275
+ . expect ( "We should be able to deserialize the backed up room key." ) ;
276
+ assert_eq ! (
277
+ backed_up_room_key. forwarding_curve25519_key_chain. len( ) ,
278
+ 2 ,
279
+ "The number of forwarding Curve25519 chains should be two."
280
+ ) ;
281
+ }
282
+ }
0 commit comments