2023-07-16 21:41:40 -04:00
|
|
|
import 'dart:typed_data';
|
|
|
|
|
2023-12-27 22:56:24 -05:00
|
|
|
import '../veilid_support.dart' as veilid;
|
|
|
|
import 'veilid.pb.dart' as proto;
|
2023-07-16 21:41:40 -04:00
|
|
|
|
2023-12-27 22:56:24 -05:00
|
|
|
export 'veilid.pb.dart';
|
|
|
|
export 'veilid.pbenum.dart';
|
|
|
|
export 'veilid.pbjson.dart';
|
|
|
|
export 'veilid.pbserver.dart';
|
2023-07-26 14:20:29 -04:00
|
|
|
|
2023-07-16 21:41:40 -04:00
|
|
|
/// CryptoKey protobuf marshaling
|
|
|
|
///
|
2023-12-27 22:56:24 -05:00
|
|
|
extension CryptoKeyProto on veilid.CryptoKey {
|
2023-07-16 21:41:40 -04:00
|
|
|
proto.CryptoKey toProto() {
|
2023-08-03 00:49:48 -04:00
|
|
|
final b = decode().buffer.asByteData();
|
2023-07-26 17:42:11 -04:00
|
|
|
final out = proto.CryptoKey()
|
2023-08-03 00:49:48 -04:00
|
|
|
..u0 = b.getUint32(0 * 4)
|
|
|
|
..u1 = b.getUint32(1 * 4)
|
|
|
|
..u2 = b.getUint32(2 * 4)
|
|
|
|
..u3 = b.getUint32(3 * 4)
|
|
|
|
..u4 = b.getUint32(4 * 4)
|
|
|
|
..u5 = b.getUint32(5 * 4)
|
|
|
|
..u6 = b.getUint32(6 * 4)
|
|
|
|
..u7 = b.getUint32(7 * 4);
|
2023-07-16 21:41:40 -04:00
|
|
|
return out;
|
|
|
|
}
|
2024-02-12 09:10:07 -05:00
|
|
|
}
|
2023-07-16 21:41:40 -04:00
|
|
|
|
2024-02-12 09:10:07 -05:00
|
|
|
extension ProtoCryptoKey on proto.CryptoKey {
|
|
|
|
veilid.CryptoKey toVeilid() {
|
2023-08-03 00:49:48 -04:00
|
|
|
final b = ByteData(32)
|
2024-02-12 09:10:07 -05:00
|
|
|
..setUint32(0 * 4, u0)
|
|
|
|
..setUint32(1 * 4, u1)
|
|
|
|
..setUint32(2 * 4, u2)
|
|
|
|
..setUint32(3 * 4, u3)
|
|
|
|
..setUint32(4 * 4, u4)
|
|
|
|
..setUint32(5 * 4, u5)
|
|
|
|
..setUint32(6 * 4, u6)
|
|
|
|
..setUint32(7 * 4, u7);
|
2023-12-27 22:56:24 -05:00
|
|
|
return veilid.CryptoKey.fromBytes(Uint8List.view(b.buffer));
|
2023-07-16 21:41:40 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Signature protobuf marshaling
|
|
|
|
///
|
2023-12-27 22:56:24 -05:00
|
|
|
extension SignatureProto on veilid.Signature {
|
2023-07-16 21:41:40 -04:00
|
|
|
proto.Signature toProto() {
|
2023-08-03 00:49:48 -04:00
|
|
|
final b = decode().buffer.asByteData();
|
2023-07-26 17:42:11 -04:00
|
|
|
final out = proto.Signature()
|
2023-08-03 00:49:48 -04:00
|
|
|
..u0 = b.getUint32(0 * 4)
|
|
|
|
..u1 = b.getUint32(1 * 4)
|
|
|
|
..u2 = b.getUint32(2 * 4)
|
|
|
|
..u3 = b.getUint32(3 * 4)
|
|
|
|
..u4 = b.getUint32(4 * 4)
|
|
|
|
..u5 = b.getUint32(5 * 4)
|
|
|
|
..u6 = b.getUint32(6 * 4)
|
|
|
|
..u7 = b.getUint32(7 * 4)
|
|
|
|
..u8 = b.getUint32(8 * 4)
|
|
|
|
..u9 = b.getUint32(9 * 4)
|
|
|
|
..u10 = b.getUint32(10 * 4)
|
|
|
|
..u11 = b.getUint32(11 * 4)
|
|
|
|
..u12 = b.getUint32(12 * 4)
|
|
|
|
..u13 = b.getUint32(13 * 4)
|
|
|
|
..u14 = b.getUint32(14 * 4)
|
|
|
|
..u15 = b.getUint32(15 * 4);
|
2023-07-16 21:41:40 -04:00
|
|
|
return out;
|
|
|
|
}
|
2024-02-12 09:10:07 -05:00
|
|
|
}
|
2023-07-16 21:41:40 -04:00
|
|
|
|
2024-02-12 09:10:07 -05:00
|
|
|
extension ProtoSignature on proto.Signature {
|
|
|
|
veilid.Signature toVeilid() {
|
2023-08-03 00:49:48 -04:00
|
|
|
final b = ByteData(64)
|
2024-02-12 09:10:07 -05:00
|
|
|
..setUint32(0 * 4, u0)
|
|
|
|
..setUint32(1 * 4, u1)
|
|
|
|
..setUint32(2 * 4, u2)
|
|
|
|
..setUint32(3 * 4, u3)
|
|
|
|
..setUint32(4 * 4, u4)
|
|
|
|
..setUint32(5 * 4, u5)
|
|
|
|
..setUint32(6 * 4, u6)
|
|
|
|
..setUint32(7 * 4, u7)
|
|
|
|
..setUint32(8 * 4, u8)
|
|
|
|
..setUint32(9 * 4, u9)
|
|
|
|
..setUint32(10 * 4, u10)
|
|
|
|
..setUint32(11 * 4, u11)
|
|
|
|
..setUint32(12 * 4, u12)
|
|
|
|
..setUint32(13 * 4, u13)
|
|
|
|
..setUint32(14 * 4, u14)
|
|
|
|
..setUint32(15 * 4, u15);
|
2023-12-27 22:56:24 -05:00
|
|
|
return veilid.Signature.fromBytes(Uint8List.view(b.buffer));
|
2023-07-16 21:41:40 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Nonce protobuf marshaling
|
|
|
|
///
|
2023-12-27 22:56:24 -05:00
|
|
|
extension NonceProto on veilid.Nonce {
|
2023-08-03 00:49:48 -04:00
|
|
|
proto.Nonce toProto() {
|
|
|
|
final b = decode().buffer.asByteData();
|
|
|
|
final out = proto.Nonce()
|
|
|
|
..u0 = b.getUint32(0 * 4)
|
|
|
|
..u1 = b.getUint32(1 * 4)
|
|
|
|
..u2 = b.getUint32(2 * 4)
|
|
|
|
..u3 = b.getUint32(3 * 4)
|
|
|
|
..u4 = b.getUint32(4 * 4)
|
|
|
|
..u5 = b.getUint32(5 * 4);
|
2023-07-16 21:41:40 -04:00
|
|
|
return out;
|
|
|
|
}
|
2024-02-11 23:18:20 -05:00
|
|
|
}
|
2023-07-16 21:41:40 -04:00
|
|
|
|
2024-02-11 23:18:20 -05:00
|
|
|
extension ProtoNonce on proto.Nonce {
|
|
|
|
veilid.Nonce toVeilid() {
|
2023-08-03 00:49:48 -04:00
|
|
|
final b = ByteData(24)
|
2024-02-11 23:18:20 -05:00
|
|
|
..setUint32(0 * 4, u0)
|
|
|
|
..setUint32(1 * 4, u1)
|
|
|
|
..setUint32(2 * 4, u2)
|
|
|
|
..setUint32(3 * 4, u3)
|
|
|
|
..setUint32(4 * 4, u4)
|
|
|
|
..setUint32(5 * 4, u5);
|
2023-12-27 22:56:24 -05:00
|
|
|
return veilid.Nonce.fromBytes(Uint8List.view(b.buffer));
|
2023-07-16 21:41:40 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// TypedKey protobuf marshaling
|
|
|
|
///
|
2023-12-27 22:56:24 -05:00
|
|
|
extension TypedKeyProto on veilid.TypedKey {
|
2023-07-16 21:41:40 -04:00
|
|
|
proto.TypedKey toProto() {
|
2023-07-26 17:42:11 -04:00
|
|
|
final out = proto.TypedKey()
|
|
|
|
..kind = kind
|
|
|
|
..value = value.toProto();
|
2023-07-16 21:41:40 -04:00
|
|
|
return out;
|
|
|
|
}
|
2024-02-11 23:18:20 -05:00
|
|
|
}
|
2023-07-16 21:41:40 -04:00
|
|
|
|
2024-02-11 23:18:20 -05:00
|
|
|
extension ProtoTypedKey on proto.TypedKey {
|
|
|
|
veilid.TypedKey toVeilid() =>
|
2024-02-12 09:10:07 -05:00
|
|
|
veilid.TypedKey(kind: kind, value: value.toVeilid());
|
2023-07-16 21:41:40 -04:00
|
|
|
}
|
2023-08-01 00:39:50 -04:00
|
|
|
|
|
|
|
/// KeyPair protobuf marshaling
|
|
|
|
///
|
2023-12-27 22:56:24 -05:00
|
|
|
extension KeyPairProto on veilid.KeyPair {
|
2023-08-01 00:39:50 -04:00
|
|
|
proto.KeyPair toProto() {
|
|
|
|
final out = proto.KeyPair()
|
|
|
|
..key = key.toProto()
|
|
|
|
..secret = secret.toProto();
|
|
|
|
return out;
|
|
|
|
}
|
2024-02-12 09:10:07 -05:00
|
|
|
}
|
2023-08-01 00:39:50 -04:00
|
|
|
|
2024-02-12 09:10:07 -05:00
|
|
|
extension ProtoKeyPair on proto.KeyPair {
|
|
|
|
veilid.KeyPair toVeilid() =>
|
|
|
|
veilid.KeyPair(key: key.toVeilid(), secret: secret.toVeilid());
|
2023-08-01 00:39:50 -04:00
|
|
|
}
|