Skip to content

Commit

Permalink
feat(grpc): add bls public key and signature aggregate methods (#1587)
Browse files Browse the repository at this point in the history
Co-authored-by: Javad Rajabzadeh <ja7ad@live.com>
  • Loading branch information
alidevjimmy and Ja7ad authored Nov 8, 2024
1 parent cc18fa3 commit e89feff
Show file tree
Hide file tree
Showing 25 changed files with 5,574 additions and 56 deletions.
6 changes: 6 additions & 0 deletions www/grpc/buf/grpc-gateway.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,9 @@ http:

- selector: pactus.Utils.VerifyMessage
get: "/pactus/Utils/verify_message"

- selector: pactus.Utils.BLSPublicKeyAggregation
get: "/pactus/Utils/bls_public_key_aggregation"

- selector: pactus.Utils.BLSSignatureAggregation
get: "/pactus/Utils/bls_signature_aggregation"
184 changes: 184 additions & 0 deletions www/grpc/gen/dart/utils.pb.dart
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,182 @@ class VerifyMessageResponse extends $pb.GeneratedMessage {
void clearIsValid() => clearField(1);
}

class BLSPublicKeyAggregationRequest extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'BLSPublicKeyAggregationRequest', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'pactus'), createEmptyInstance: create)
..pPS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'publicKeys')
..hasRequiredFields = false
;

BLSPublicKeyAggregationRequest._() : super();
factory BLSPublicKeyAggregationRequest({
$core.Iterable<$core.String>? publicKeys,
}) {
final _result = create();
if (publicKeys != null) {
_result.publicKeys.addAll(publicKeys);
}
return _result;
}
factory BLSPublicKeyAggregationRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory BLSPublicKeyAggregationRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
BLSPublicKeyAggregationRequest clone() => BLSPublicKeyAggregationRequest()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
BLSPublicKeyAggregationRequest copyWith(void Function(BLSPublicKeyAggregationRequest) updates) => super.copyWith((message) => updates(message as BLSPublicKeyAggregationRequest)) as BLSPublicKeyAggregationRequest; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static BLSPublicKeyAggregationRequest create() => BLSPublicKeyAggregationRequest._();
BLSPublicKeyAggregationRequest createEmptyInstance() => create();
static $pb.PbList<BLSPublicKeyAggregationRequest> createRepeated() => $pb.PbList<BLSPublicKeyAggregationRequest>();
@$core.pragma('dart2js:noInline')
static BLSPublicKeyAggregationRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<BLSPublicKeyAggregationRequest>(create);
static BLSPublicKeyAggregationRequest? _defaultInstance;

@$pb.TagNumber(1)
$core.List<$core.String> get publicKeys => $_getList(0);
}

class BLSPublicKeyAggregationResponse extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'BLSPublicKeyAggregationResponse', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'pactus'), createEmptyInstance: create)
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'publicKey')
..hasRequiredFields = false
;

BLSPublicKeyAggregationResponse._() : super();
factory BLSPublicKeyAggregationResponse({
$core.String? publicKey,
}) {
final _result = create();
if (publicKey != null) {
_result.publicKey = publicKey;
}
return _result;
}
factory BLSPublicKeyAggregationResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory BLSPublicKeyAggregationResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
BLSPublicKeyAggregationResponse clone() => BLSPublicKeyAggregationResponse()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
BLSPublicKeyAggregationResponse copyWith(void Function(BLSPublicKeyAggregationResponse) updates) => super.copyWith((message) => updates(message as BLSPublicKeyAggregationResponse)) as BLSPublicKeyAggregationResponse; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static BLSPublicKeyAggregationResponse create() => BLSPublicKeyAggregationResponse._();
BLSPublicKeyAggregationResponse createEmptyInstance() => create();
static $pb.PbList<BLSPublicKeyAggregationResponse> createRepeated() => $pb.PbList<BLSPublicKeyAggregationResponse>();
@$core.pragma('dart2js:noInline')
static BLSPublicKeyAggregationResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<BLSPublicKeyAggregationResponse>(create);
static BLSPublicKeyAggregationResponse? _defaultInstance;

@$pb.TagNumber(1)
$core.String get publicKey => $_getSZ(0);
@$pb.TagNumber(1)
set publicKey($core.String v) { $_setString(0, v); }
@$pb.TagNumber(1)
$core.bool hasPublicKey() => $_has(0);
@$pb.TagNumber(1)
void clearPublicKey() => clearField(1);
}

class BLSSignatureAggregationRequest extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'BLSSignatureAggregationRequest', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'pactus'), createEmptyInstance: create)
..pPS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'signatures')
..hasRequiredFields = false
;

BLSSignatureAggregationRequest._() : super();
factory BLSSignatureAggregationRequest({
$core.Iterable<$core.String>? signatures,
}) {
final _result = create();
if (signatures != null) {
_result.signatures.addAll(signatures);
}
return _result;
}
factory BLSSignatureAggregationRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory BLSSignatureAggregationRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
BLSSignatureAggregationRequest clone() => BLSSignatureAggregationRequest()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
BLSSignatureAggregationRequest copyWith(void Function(BLSSignatureAggregationRequest) updates) => super.copyWith((message) => updates(message as BLSSignatureAggregationRequest)) as BLSSignatureAggregationRequest; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static BLSSignatureAggregationRequest create() => BLSSignatureAggregationRequest._();
BLSSignatureAggregationRequest createEmptyInstance() => create();
static $pb.PbList<BLSSignatureAggregationRequest> createRepeated() => $pb.PbList<BLSSignatureAggregationRequest>();
@$core.pragma('dart2js:noInline')
static BLSSignatureAggregationRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<BLSSignatureAggregationRequest>(create);
static BLSSignatureAggregationRequest? _defaultInstance;

@$pb.TagNumber(1)
$core.List<$core.String> get signatures => $_getList(0);
}

class BLSSignatureAggregationResponse extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'BLSSignatureAggregationResponse', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'pactus'), createEmptyInstance: create)
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'signature')
..hasRequiredFields = false
;

BLSSignatureAggregationResponse._() : super();
factory BLSSignatureAggregationResponse({
$core.String? signature,
}) {
final _result = create();
if (signature != null) {
_result.signature = signature;
}
return _result;
}
factory BLSSignatureAggregationResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory BLSSignatureAggregationResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
BLSSignatureAggregationResponse clone() => BLSSignatureAggregationResponse()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
BLSSignatureAggregationResponse copyWith(void Function(BLSSignatureAggregationResponse) updates) => super.copyWith((message) => updates(message as BLSSignatureAggregationResponse)) as BLSSignatureAggregationResponse; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static BLSSignatureAggregationResponse create() => BLSSignatureAggregationResponse._();
BLSSignatureAggregationResponse createEmptyInstance() => create();
static $pb.PbList<BLSSignatureAggregationResponse> createRepeated() => $pb.PbList<BLSSignatureAggregationResponse>();
@$core.pragma('dart2js:noInline')
static BLSSignatureAggregationResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<BLSSignatureAggregationResponse>(create);
static BLSSignatureAggregationResponse? _defaultInstance;

@$pb.TagNumber(1)
$core.String get signature => $_getSZ(0);
@$pb.TagNumber(1)
set signature($core.String v) { $_setString(0, v); }
@$pb.TagNumber(1)
$core.bool hasSignature() => $_has(0);
@$pb.TagNumber(1)
void clearSignature() => clearField(1);
}

class UtilsApi {
$pb.RpcClient _client;
UtilsApi(this._client);
Expand All @@ -252,5 +428,13 @@ class UtilsApi {
var emptyResponse = VerifyMessageResponse();
return _client.invoke<VerifyMessageResponse>(ctx, 'Utils', 'VerifyMessage', request, emptyResponse);
}
$async.Future<BLSPublicKeyAggregationResponse> bLSPublicKeyAggregation($pb.ClientContext? ctx, BLSPublicKeyAggregationRequest request) {
var emptyResponse = BLSPublicKeyAggregationResponse();
return _client.invoke<BLSPublicKeyAggregationResponse>(ctx, 'Utils', 'BLSPublicKeyAggregation', request, emptyResponse);
}
$async.Future<BLSSignatureAggregationResponse> bLSSignatureAggregation($pb.ClientContext? ctx, BLSSignatureAggregationRequest request) {
var emptyResponse = BLSSignatureAggregationResponse();
return _client.invoke<BLSSignatureAggregationResponse>(ctx, 'Utils', 'BLSSignatureAggregation', request, emptyResponse);
}
}

48 changes: 47 additions & 1 deletion www/grpc/gen/dart/utils.pbjson.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,53 @@ const VerifyMessageResponse$json = const {

/// Descriptor for `VerifyMessageResponse`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List verifyMessageResponseDescriptor = $convert.base64Decode('ChVWZXJpZnlNZXNzYWdlUmVzcG9uc2USGQoIaXNfdmFsaWQYASABKAhSB2lzVmFsaWQ=');
@$core.Deprecated('Use bLSPublicKeyAggregationRequestDescriptor instead')
const BLSPublicKeyAggregationRequest$json = const {
'1': 'BLSPublicKeyAggregationRequest',
'2': const [
const {'1': 'public_keys', '3': 1, '4': 3, '5': 9, '10': 'publicKeys'},
],
};

/// Descriptor for `BLSPublicKeyAggregationRequest`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List bLSPublicKeyAggregationRequestDescriptor = $convert.base64Decode('Ch5CTFNQdWJsaWNLZXlBZ2dyZWdhdGlvblJlcXVlc3QSHwoLcHVibGljX2tleXMYASADKAlSCnB1YmxpY0tleXM=');
@$core.Deprecated('Use bLSPublicKeyAggregationResponseDescriptor instead')
const BLSPublicKeyAggregationResponse$json = const {
'1': 'BLSPublicKeyAggregationResponse',
'2': const [
const {'1': 'public_key', '3': 1, '4': 1, '5': 9, '10': 'publicKey'},
],
};

/// Descriptor for `BLSPublicKeyAggregationResponse`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List bLSPublicKeyAggregationResponseDescriptor = $convert.base64Decode('Ch9CTFNQdWJsaWNLZXlBZ2dyZWdhdGlvblJlc3BvbnNlEh0KCnB1YmxpY19rZXkYASABKAlSCXB1YmxpY0tleQ==');
@$core.Deprecated('Use bLSSignatureAggregationRequestDescriptor instead')
const BLSSignatureAggregationRequest$json = const {
'1': 'BLSSignatureAggregationRequest',
'2': const [
const {'1': 'signatures', '3': 1, '4': 3, '5': 9, '10': 'signatures'},
],
};

/// Descriptor for `BLSSignatureAggregationRequest`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List bLSSignatureAggregationRequestDescriptor = $convert.base64Decode('Ch5CTFNTaWduYXR1cmVBZ2dyZWdhdGlvblJlcXVlc3QSHgoKc2lnbmF0dXJlcxgBIAMoCVIKc2lnbmF0dXJlcw==');
@$core.Deprecated('Use bLSSignatureAggregationResponseDescriptor instead')
const BLSSignatureAggregationResponse$json = const {
'1': 'BLSSignatureAggregationResponse',
'2': const [
const {'1': 'signature', '3': 1, '4': 1, '5': 9, '10': 'signature'},
],
};

/// Descriptor for `BLSSignatureAggregationResponse`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List bLSSignatureAggregationResponseDescriptor = $convert.base64Decode('Ch9CTFNTaWduYXR1cmVBZ2dyZWdhdGlvblJlc3BvbnNlEhwKCXNpZ25hdHVyZRgBIAEoCVIJc2lnbmF0dXJl');
const $core.Map<$core.String, $core.dynamic> UtilsServiceBase$json = const {
'1': 'Utils',
'2': const [
const {'1': 'SignMessageWithPrivateKey', '2': '.pactus.SignMessageWithPrivateKeyRequest', '3': '.pactus.SignMessageWithPrivateKeyResponse'},
const {'1': 'VerifyMessage', '2': '.pactus.VerifyMessageRequest', '3': '.pactus.VerifyMessageResponse'},
const {'1': 'BLSPublicKeyAggregation', '2': '.pactus.BLSPublicKeyAggregationRequest', '3': '.pactus.BLSPublicKeyAggregationResponse'},
const {'1': 'BLSSignatureAggregation', '2': '.pactus.BLSSignatureAggregationRequest', '3': '.pactus.BLSSignatureAggregationResponse'},
],
};

Expand All @@ -65,7 +107,11 @@ const $core.Map<$core.String, $core.Map<$core.String, $core.dynamic>> UtilsServi
'.pactus.SignMessageWithPrivateKeyResponse': SignMessageWithPrivateKeyResponse$json,
'.pactus.VerifyMessageRequest': VerifyMessageRequest$json,
'.pactus.VerifyMessageResponse': VerifyMessageResponse$json,
'.pactus.BLSPublicKeyAggregationRequest': BLSPublicKeyAggregationRequest$json,
'.pactus.BLSPublicKeyAggregationResponse': BLSPublicKeyAggregationResponse$json,
'.pactus.BLSSignatureAggregationRequest': BLSSignatureAggregationRequest$json,
'.pactus.BLSSignatureAggregationResponse': BLSSignatureAggregationResponse$json,
};

/// Descriptor for `Utils`. Decode as a `google.protobuf.ServiceDescriptorProto`.
final $typed_data.Uint8List utilsServiceDescriptor = $convert.base64Decode('CgVVdGlscxJwChlTaWduTWVzc2FnZVdpdGhQcml2YXRlS2V5EigucGFjdHVzLlNpZ25NZXNzYWdlV2l0aFByaXZhdGVLZXlSZXF1ZXN0GikucGFjdHVzLlNpZ25NZXNzYWdlV2l0aFByaXZhdGVLZXlSZXNwb25zZRJMCg1WZXJpZnlNZXNzYWdlEhwucGFjdHVzLlZlcmlmeU1lc3NhZ2VSZXF1ZXN0Gh0ucGFjdHVzLlZlcmlmeU1lc3NhZ2VSZXNwb25zZQ==');
final $typed_data.Uint8List utilsServiceDescriptor = $convert.base64Decode('CgVVdGlscxJwChlTaWduTWVzc2FnZVdpdGhQcml2YXRlS2V5EigucGFjdHVzLlNpZ25NZXNzYWdlV2l0aFByaXZhdGVLZXlSZXF1ZXN0GikucGFjdHVzLlNpZ25NZXNzYWdlV2l0aFByaXZhdGVLZXlSZXNwb25zZRJMCg1WZXJpZnlNZXNzYWdlEhwucGFjdHVzLlZlcmlmeU1lc3NhZ2VSZXF1ZXN0Gh0ucGFjdHVzLlZlcmlmeU1lc3NhZ2VSZXNwb25zZRJqChdCTFNQdWJsaWNLZXlBZ2dyZWdhdGlvbhImLnBhY3R1cy5CTFNQdWJsaWNLZXlBZ2dyZWdhdGlvblJlcXVlc3QaJy5wYWN0dXMuQkxTUHVibGljS2V5QWdncmVnYXRpb25SZXNwb25zZRJqChdCTFNTaWduYXR1cmVBZ2dyZWdhdGlvbhImLnBhY3R1cy5CTFNTaWduYXR1cmVBZ2dyZWdhdGlvblJlcXVlc3QaJy5wYWN0dXMuQkxTU2lnbmF0dXJlQWdncmVnYXRpb25SZXNwb25zZQ==');
6 changes: 6 additions & 0 deletions www/grpc/gen/dart/utils.pbserver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ export 'utils.pb.dart';
abstract class UtilsServiceBase extends $pb.GeneratedService {
$async.Future<$3.SignMessageWithPrivateKeyResponse> signMessageWithPrivateKey($pb.ServerContext ctx, $3.SignMessageWithPrivateKeyRequest request);
$async.Future<$3.VerifyMessageResponse> verifyMessage($pb.ServerContext ctx, $3.VerifyMessageRequest request);
$async.Future<$3.BLSPublicKeyAggregationResponse> bLSPublicKeyAggregation($pb.ServerContext ctx, $3.BLSPublicKeyAggregationRequest request);
$async.Future<$3.BLSSignatureAggregationResponse> bLSSignatureAggregation($pb.ServerContext ctx, $3.BLSSignatureAggregationRequest request);

$pb.GeneratedMessage createRequest($core.String method) {
switch (method) {
case 'SignMessageWithPrivateKey': return $3.SignMessageWithPrivateKeyRequest();
case 'VerifyMessage': return $3.VerifyMessageRequest();
case 'BLSPublicKeyAggregation': return $3.BLSPublicKeyAggregationRequest();
case 'BLSSignatureAggregation': return $3.BLSSignatureAggregationRequest();
default: throw $core.ArgumentError('Unknown method: $method');
}
}
Expand All @@ -31,6 +35,8 @@ abstract class UtilsServiceBase extends $pb.GeneratedService {
switch (method) {
case 'SignMessageWithPrivateKey': return this.signMessageWithPrivateKey(ctx, request as $3.SignMessageWithPrivateKeyRequest);
case 'VerifyMessage': return this.verifyMessage(ctx, request as $3.VerifyMessageRequest);
case 'BLSPublicKeyAggregation': return this.bLSPublicKeyAggregation(ctx, request as $3.BLSPublicKeyAggregationRequest);
case 'BLSSignatureAggregation': return this.bLSSignatureAggregation(ctx, request as $3.BLSSignatureAggregationRequest);
default: throw $core.ArgumentError('Unknown method: $method');
}
}
Expand Down
Loading

0 comments on commit e89feff

Please sign in to comment.