MixinNetwork / libsignal_protocol_dart

Signal Protocol library for Dart/Flutter
https://pub.dev/packages/libsignal_protocol_dart
GNU General Public License v3.0
159 stars 42 forks source link

PreKeyBundle to Server #69

Closed Nitish987 closed 1 year ago

Nitish987 commented 1 year ago

Can anyone tell about how can i send PreKeyBundle to server. I have implemented with some approach but theres a problem in converting Uint8List PreKey to ECPublicKey Class Object on getting PreKeyBundleModel back from the server.

I have created this PreKeyBundleModel which is coming from server after deserializing but i have to convert this PreKeyBundleModel to PreKeyBundle. Problem occurs when i want to convert Uinit8List PreKey to ECPublicKey as PreKeyBundle requires ECPublicKey Object as parameters. Is there any method to convert Uini8List to ECPublicKey.

` @JsonSerializable() class PreKeyBundleModel { int? registrationId; int? deviceId; List? preKeys; SignedPreKeyModel? signedPreKey; String? identityKey;

PreKeyBundleModel({this.registrationId, this.deviceId, this.preKeys, this.signedPreKey, this.identityKey});

factory PreKeyBundleModel.fromJson(Map<String, dynamic> json) => _$PreKeyBundleModelFromJson(json);

Map<String, dynamic> toJson() => _$PreKeyBundleModelToJson(this); }

@JsonSerializable() class PreKeyModel { int? id; String? key;

PreKeyModel({this.id, this.key});

factory PreKeyModel.fromJson(Map<String, dynamic> json) => _$PreKeyModelFromJson(json);

Map<String, dynamic> toJson() => _$PreKeyModelToJson(this); }

@JsonSerializable() class SignedPreKeyModel { int? id; String? key; String? signature;

SignedPreKeyModel({this.id, this.key, this.signature});

factory SignedPreKeyModel.fromJson(Map<String, dynamic> json) => _$SignedPreKeyModelFromJson(json);

Map<String, dynamic> toJson() => _$SignedPreKeyModelToJson(this); } `

Tougee commented 1 year ago

You can try DjbECPublicKey which has a constructor that accepts Uint8List as a parameter.

Nitish987 commented 1 year ago

Thank you so much i solved my code error.