From 1f59efbb445d4750912f4eeb6ac6cdd8535982a8 Mon Sep 17 00:00:00 2001 From: ethella Date: Fri, 27 May 2022 17:09:10 -0700 Subject: [PATCH 1/7] * initial commit --- .gitignore | 29 +++++++++++++ .metadata | 10 +++++ CHANGELOG.md | 3 ++ analysis_options.yaml | 4 ++ lib/blockchain_signer.dart | 3 ++ lib/signer/remote/remote_signer.dart | 23 +++++++++++ lib/signer/response/sign_result.dart | 22 ++++++++++ lib/signer/response/sign_result.g.dart | 22 ++++++++++ lib/signer/signer.dart | 17 ++++++++ pubspec.yaml | 57 ++++++++++++++++++++++++++ test/blockchain_signer_test.dart | 6 +++ 11 files changed, 196 insertions(+) create mode 100644 .gitignore create mode 100644 .metadata create mode 100644 CHANGELOG.md create mode 100644 analysis_options.yaml create mode 100644 lib/blockchain_signer.dart create mode 100644 lib/signer/remote/remote_signer.dart create mode 100644 lib/signer/response/sign_result.dart create mode 100644 lib/signer/response/sign_result.g.dart create mode 100644 lib/signer/signer.dart create mode 100644 pubspec.yaml create mode 100644 test/blockchain_signer_test.dart diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9be145f --- /dev/null +++ b/.gitignore @@ -0,0 +1,29 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +.packages +build/ diff --git a/.metadata b/.metadata new file mode 100644 index 0000000..c24d00d --- /dev/null +++ b/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: 5464c5bac742001448fe4fc0597be939379f88ea + channel: stable + +project_type: package diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..41cc7d8 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.0.1 + +* TODO: Describe initial release. diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..a5744c1 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:flutter_lints/flutter.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/lib/blockchain_signer.dart b/lib/blockchain_signer.dart new file mode 100644 index 0000000..158cc04 --- /dev/null +++ b/lib/blockchain_signer.dart @@ -0,0 +1,3 @@ +library blockchain_signer; + +export 'signer/remote/remote_signer.dart'; diff --git a/lib/signer/remote/remote_signer.dart b/lib/signer/remote/remote_signer.dart new file mode 100644 index 0000000..ed73c07 --- /dev/null +++ b/lib/signer/remote/remote_signer.dart @@ -0,0 +1,23 @@ +import 'dart:typed_data'; +import 'package:blockchain_signer/signer/signer.dart'; +import '../response/sign_result.dart'; + +/// Remote Sign +/// A remote signer layer that provides signature service from non-custodial key management solutions +abstract class RemoteSigner extends Signer { + + @override + Future sign(String op, Uint8List bytes); + + @override + String? get publicKey; + + @override + String? get address; + + @override + String? get secretKey; + + // verifySignature +} + diff --git a/lib/signer/response/sign_result.dart b/lib/signer/response/sign_result.dart new file mode 100644 index 0000000..dd74d42 --- /dev/null +++ b/lib/signer/response/sign_result.dart @@ -0,0 +1,22 @@ +import 'package:json_annotation/json_annotation.dart'; + +part './sign_result.g.dart'; + +@JsonSerializable(explicitToJson: true) +class SignResult { + // https://github.com/ecadlabs/taquito/blob/e5c9dcc54b5a806dbe7c0d0a2e8232a8bcde2074/packages/taquito-utils/src/taquito-utils.ts#L56 + // signature is hex 64 + + /// b58c encoded signature from bytes hash + String sig; // b58cencode(signature, prefix.sig), + String prefixSig; // b58cencode(signature, pref[this.curve].sig), + String bytes; // Original bytes + String sbytes; // bytes + hex signature + + SignResult({required this.bytes, required this.sig, required this.prefixSig, required this.sbytes}); + + factory SignResult.fromJson(Map json) => + _$SignResultFromJson(json); + + Map toJson() => _$SignResultToJson(this); +} diff --git a/lib/signer/response/sign_result.g.dart b/lib/signer/response/sign_result.g.dart new file mode 100644 index 0000000..95b7186 --- /dev/null +++ b/lib/signer/response/sign_result.g.dart @@ -0,0 +1,22 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of './sign_result.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +SignResult _$SignResultFromJson(Map json) => SignResult( + bytes: json['bytes'] as String, + sig: json['sig'] as String, + prefixSig: json['prefixSig'] as String, + sbytes: json['sbytes'] as String, + ); + +Map _$SignResultToJson(SignResult instance) => + { + 'bytes': instance.bytes, + 'sig': instance.sig, + 'prefixSig': instance.prefixSig, + 'sbytes': instance.sbytes, + }; diff --git a/lib/signer/signer.dart b/lib/signer/signer.dart new file mode 100644 index 0000000..411911d --- /dev/null +++ b/lib/signer/signer.dart @@ -0,0 +1,17 @@ +import 'dart:typed_data'; +import 'package:blockchain_signer/signer/response/sign_result.dart'; + +/// Basic Signer that provides developers with signing interfaces for any blockchain. +/// This is not yet the final version yet. Anything would be subjected to change +/// +abstract class Signer { + + Future sign(String op, Uint8List bytes); + + String? get publicKey; + String? get address; + String? get secretKey; + +// verifySignature +} + diff --git a/pubspec.yaml b/pubspec.yaml new file mode 100644 index 0000000..00e878e --- /dev/null +++ b/pubspec.yaml @@ -0,0 +1,57 @@ +name: blockchain_signer +description: A new Flutter package project. +version: 0.0.1 +homepage: + +environment: + sdk: ">=2.16.2 <3.0.0" + flutter: ">=1.17.0" + +dependencies: + flutter: + sdk: flutter + json_annotation: ^4.5.0 + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^1.0.0 + build_runner: ^2.1.11 + json_serializable: ^6.2.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter. +flutter: + + # To add assets to your package, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + # + # For details regarding assets in packages, see + # https://flutter.dev/assets-and-images/#from-packages + # + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware. + + # To add custom fonts to your package, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts in packages, see + # https://flutter.dev/custom-fonts/#from-packages diff --git a/test/blockchain_signer_test.dart b/test/blockchain_signer_test.dart new file mode 100644 index 0000000..b3f114d --- /dev/null +++ b/test/blockchain_signer_test.dart @@ -0,0 +1,6 @@ +import 'package:flutter_test/flutter_test.dart'; + +import 'package:blockchain_signer/blockchain_signer.dart'; + +void main() { +} From 0ab1e20ee7b2c67fd62f0c8b8e03aa56754e8261 Mon Sep 17 00:00:00 2001 From: ethella Date: Fri, 27 May 2022 18:17:10 -0700 Subject: [PATCH 2/7] * move to flutter folder --- .gitignore => flutter/.gitignore | 2 +- .metadata => flutter/.metadata | 0 CHANGELOG.md => flutter/CHANGELOG.md | 0 LICENSE => flutter/LICENSE | 0 README.md => flutter/README.md | 0 analysis_options.yaml => flutter/analysis_options.yaml | 0 {lib => flutter/lib}/blockchain_signer.dart | 0 {lib => flutter/lib}/signer/remote/remote_signer.dart | 0 {lib => flutter/lib}/signer/response/sign_result.dart | 2 +- {lib => flutter/lib}/signer/response/sign_result.g.dart | 2 +- {lib => flutter/lib}/signer/signer.dart | 0 {test => flutter/test}/blockchain_signer_test.dart | 0 12 files changed, 3 insertions(+), 3 deletions(-) rename .gitignore => flutter/.gitignore (98%) rename .metadata => flutter/.metadata (100%) rename CHANGELOG.md => flutter/CHANGELOG.md (100%) rename LICENSE => flutter/LICENSE (100%) rename README.md => flutter/README.md (100%) rename analysis_options.yaml => flutter/analysis_options.yaml (100%) rename {lib => flutter/lib}/blockchain_signer.dart (100%) rename {lib => flutter/lib}/signer/remote/remote_signer.dart (100%) rename {lib => flutter/lib}/signer/response/sign_result.dart (96%) rename {lib => flutter/lib}/signer/response/sign_result.g.dart (95%) rename {lib => flutter/lib}/signer/signer.dart (100%) rename {test => flutter/test}/blockchain_signer_test.dart (100%) diff --git a/.gitignore b/flutter/.gitignore similarity index 98% rename from .gitignore rename to flutter/.gitignore index 9be145f..396cd08 100644 --- a/.gitignore +++ b/flutter/.gitignore @@ -13,7 +13,7 @@ *.iml *.ipr *.iws -.idea/ +../.idea/ # The .vscode folder contains launch configuration and tasks you configure in # VS Code which you may wish to be included in version control, so this line diff --git a/.metadata b/flutter/.metadata similarity index 100% rename from .metadata rename to flutter/.metadata diff --git a/CHANGELOG.md b/flutter/CHANGELOG.md similarity index 100% rename from CHANGELOG.md rename to flutter/CHANGELOG.md diff --git a/LICENSE b/flutter/LICENSE similarity index 100% rename from LICENSE rename to flutter/LICENSE diff --git a/README.md b/flutter/README.md similarity index 100% rename from README.md rename to flutter/README.md diff --git a/analysis_options.yaml b/flutter/analysis_options.yaml similarity index 100% rename from analysis_options.yaml rename to flutter/analysis_options.yaml diff --git a/lib/blockchain_signer.dart b/flutter/lib/blockchain_signer.dart similarity index 100% rename from lib/blockchain_signer.dart rename to flutter/lib/blockchain_signer.dart diff --git a/lib/signer/remote/remote_signer.dart b/flutter/lib/signer/remote/remote_signer.dart similarity index 100% rename from lib/signer/remote/remote_signer.dart rename to flutter/lib/signer/remote/remote_signer.dart diff --git a/lib/signer/response/sign_result.dart b/flutter/lib/signer/response/sign_result.dart similarity index 96% rename from lib/signer/response/sign_result.dart rename to flutter/lib/signer/response/sign_result.dart index dd74d42..2b2ab5a 100644 --- a/lib/signer/response/sign_result.dart +++ b/flutter/lib/signer/response/sign_result.dart @@ -1,6 +1,6 @@ import 'package:json_annotation/json_annotation.dart'; -part './sign_result.g.dart'; +part 'sign_result.g.dart'; @JsonSerializable(explicitToJson: true) class SignResult { diff --git a/lib/signer/response/sign_result.g.dart b/flutter/lib/signer/response/sign_result.g.dart similarity index 95% rename from lib/signer/response/sign_result.g.dart rename to flutter/lib/signer/response/sign_result.g.dart index 95b7186..faa01dc 100644 --- a/lib/signer/response/sign_result.g.dart +++ b/flutter/lib/signer/response/sign_result.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of './sign_result.dart'; +part of 'sign_result.dart'; // ************************************************************************** // JsonSerializableGenerator diff --git a/lib/signer/signer.dart b/flutter/lib/signer/signer.dart similarity index 100% rename from lib/signer/signer.dart rename to flutter/lib/signer/signer.dart diff --git a/test/blockchain_signer_test.dart b/flutter/test/blockchain_signer_test.dart similarity index 100% rename from test/blockchain_signer_test.dart rename to flutter/test/blockchain_signer_test.dart From 505adf16c1792fa1a9d49e455d9d02dd4a66f1ad Mon Sep 17 00:00:00 2001 From: ethella Date: Fri, 27 May 2022 18:17:20 -0700 Subject: [PATCH 3/7] * move to flutter folder --- pubspec.yaml => flutter/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename pubspec.yaml => flutter/pubspec.yaml (98%) diff --git a/pubspec.yaml b/flutter/pubspec.yaml similarity index 98% rename from pubspec.yaml rename to flutter/pubspec.yaml index 00e878e..a812c33 100644 --- a/pubspec.yaml +++ b/flutter/pubspec.yaml @@ -1,4 +1,4 @@ -name: blockchain_signer +name: blockchain_mobile_signer description: A new Flutter package project. version: 0.0.1 homepage: From 396410c3d8bd6b68cd7a700b3a50d258f08fbaee Mon Sep 17 00:00:00 2001 From: ethella Date: Tue, 31 May 2022 11:26:53 -0700 Subject: [PATCH 4/7] Rename sign_result to Signed Result --- flutter/lib/signer/remote/remote_signer.dart | 4 ++-- .../response/{sign_result.dart => signed_result.dart} | 8 ++++---- .../response/{sign_result.g.dart => signed_result.g.dart} | 6 +++--- flutter/lib/signer/signer.dart | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) rename flutter/lib/signer/response/{sign_result.dart => signed_result.dart} (73%) rename flutter/lib/signer/response/{sign_result.g.dart => signed_result.g.dart} (76%) diff --git a/flutter/lib/signer/remote/remote_signer.dart b/flutter/lib/signer/remote/remote_signer.dart index ed73c07..1b49e8a 100644 --- a/flutter/lib/signer/remote/remote_signer.dart +++ b/flutter/lib/signer/remote/remote_signer.dart @@ -1,13 +1,13 @@ import 'dart:typed_data'; import 'package:blockchain_signer/signer/signer.dart'; -import '../response/sign_result.dart'; +import '../response/signed_result.dart'; /// Remote Sign /// A remote signer layer that provides signature service from non-custodial key management solutions abstract class RemoteSigner extends Signer { @override - Future sign(String op, Uint8List bytes); + Future sign(String op, Uint8List bytes); @override String? get publicKey; diff --git a/flutter/lib/signer/response/sign_result.dart b/flutter/lib/signer/response/signed_result.dart similarity index 73% rename from flutter/lib/signer/response/sign_result.dart rename to flutter/lib/signer/response/signed_result.dart index 2b2ab5a..d165cf8 100644 --- a/flutter/lib/signer/response/sign_result.dart +++ b/flutter/lib/signer/response/signed_result.dart @@ -1,9 +1,9 @@ import 'package:json_annotation/json_annotation.dart'; -part 'sign_result.g.dart'; +part 'signed_result.g.dart'; @JsonSerializable(explicitToJson: true) -class SignResult { +class SignedResult { // https://github.com/ecadlabs/taquito/blob/e5c9dcc54b5a806dbe7c0d0a2e8232a8bcde2074/packages/taquito-utils/src/taquito-utils.ts#L56 // signature is hex 64 @@ -13,9 +13,9 @@ class SignResult { String bytes; // Original bytes String sbytes; // bytes + hex signature - SignResult({required this.bytes, required this.sig, required this.prefixSig, required this.sbytes}); + SignedResult({required this.bytes, required this.sig, required this.prefixSig, required this.sbytes}); - factory SignResult.fromJson(Map json) => + factory SignedResult.fromJson(Map json) => _$SignResultFromJson(json); Map toJson() => _$SignResultToJson(this); diff --git a/flutter/lib/signer/response/sign_result.g.dart b/flutter/lib/signer/response/signed_result.g.dart similarity index 76% rename from flutter/lib/signer/response/sign_result.g.dart rename to flutter/lib/signer/response/signed_result.g.dart index faa01dc..4ab0700 100644 --- a/flutter/lib/signer/response/sign_result.g.dart +++ b/flutter/lib/signer/response/signed_result.g.dart @@ -1,19 +1,19 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'sign_result.dart'; +part of 'signed_result.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** -SignResult _$SignResultFromJson(Map json) => SignResult( +SignedResult _$SignResultFromJson(Map json) => SignedResult( bytes: json['bytes'] as String, sig: json['sig'] as String, prefixSig: json['prefixSig'] as String, sbytes: json['sbytes'] as String, ); -Map _$SignResultToJson(SignResult instance) => +Map _$SignResultToJson(SignedResult instance) => { 'bytes': instance.bytes, 'sig': instance.sig, diff --git a/flutter/lib/signer/signer.dart b/flutter/lib/signer/signer.dart index 411911d..11f948b 100644 --- a/flutter/lib/signer/signer.dart +++ b/flutter/lib/signer/signer.dart @@ -1,12 +1,12 @@ import 'dart:typed_data'; -import 'package:blockchain_signer/signer/response/sign_result.dart'; +import 'package:blockchain_signer/signer/response/signed_result.dart'; /// Basic Signer that provides developers with signing interfaces for any blockchain. /// This is not yet the final version yet. Anything would be subjected to change /// abstract class Signer { - Future sign(String op, Uint8List bytes); + Future sign(String op, Uint8List bytes); String? get publicKey; String? get address; From ba4e5926ee7548c80a45cdb9de083e4be52fe562 Mon Sep 17 00:00:00 2001 From: ethella Date: Tue, 31 May 2022 13:52:25 -0700 Subject: [PATCH 5/7] Rename sign_result to Signed Result Fix package name --- flutter/lib/blockchain_signer.dart | 2 +- flutter/lib/signer/remote/remote_signer.dart | 2 +- flutter/lib/signer/response/signed_result.dart | 4 ++-- flutter/lib/signer/response/signed_result.g.dart | 4 ++-- flutter/lib/signer/signer.dart | 2 +- flutter/test/blockchain_signer_test.dart | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/flutter/lib/blockchain_signer.dart b/flutter/lib/blockchain_signer.dart index 158cc04..acc9b63 100644 --- a/flutter/lib/blockchain_signer.dart +++ b/flutter/lib/blockchain_signer.dart @@ -1,3 +1,3 @@ -library blockchain_signer; +library blockchain_mobile_signer; export 'signer/remote/remote_signer.dart'; diff --git a/flutter/lib/signer/remote/remote_signer.dart b/flutter/lib/signer/remote/remote_signer.dart index 1b49e8a..b4b95c0 100644 --- a/flutter/lib/signer/remote/remote_signer.dart +++ b/flutter/lib/signer/remote/remote_signer.dart @@ -1,5 +1,5 @@ import 'dart:typed_data'; -import 'package:blockchain_signer/signer/signer.dart'; +import 'package:blockchain_mobile_signer/signer/signer.dart'; import '../response/signed_result.dart'; /// Remote Sign diff --git a/flutter/lib/signer/response/signed_result.dart b/flutter/lib/signer/response/signed_result.dart index d165cf8..b4a3bdc 100644 --- a/flutter/lib/signer/response/signed_result.dart +++ b/flutter/lib/signer/response/signed_result.dart @@ -16,7 +16,7 @@ class SignedResult { SignedResult({required this.bytes, required this.sig, required this.prefixSig, required this.sbytes}); factory SignedResult.fromJson(Map json) => - _$SignResultFromJson(json); + _$SignedResultFromJson(json); - Map toJson() => _$SignResultToJson(this); + Map toJson() => _$SignedResultToJson(this); } diff --git a/flutter/lib/signer/response/signed_result.g.dart b/flutter/lib/signer/response/signed_result.g.dart index 4ab0700..64e2d93 100644 --- a/flutter/lib/signer/response/signed_result.g.dart +++ b/flutter/lib/signer/response/signed_result.g.dart @@ -6,14 +6,14 @@ part of 'signed_result.dart'; // JsonSerializableGenerator // ************************************************************************** -SignedResult _$SignResultFromJson(Map json) => SignedResult( +SignedResult _$SignedResultFromJson(Map json) => SignedResult( bytes: json['bytes'] as String, sig: json['sig'] as String, prefixSig: json['prefixSig'] as String, sbytes: json['sbytes'] as String, ); -Map _$SignResultToJson(SignedResult instance) => +Map _$SignedResultToJson(SignedResult instance) => { 'bytes': instance.bytes, 'sig': instance.sig, diff --git a/flutter/lib/signer/signer.dart b/flutter/lib/signer/signer.dart index 11f948b..2e5670e 100644 --- a/flutter/lib/signer/signer.dart +++ b/flutter/lib/signer/signer.dart @@ -1,5 +1,5 @@ import 'dart:typed_data'; -import 'package:blockchain_signer/signer/response/signed_result.dart'; +import 'package:blockchain_mobile_signer/signer/response/signed_result.dart'; /// Basic Signer that provides developers with signing interfaces for any blockchain. /// This is not yet the final version yet. Anything would be subjected to change diff --git a/flutter/test/blockchain_signer_test.dart b/flutter/test/blockchain_signer_test.dart index b3f114d..3a2c1f1 100644 --- a/flutter/test/blockchain_signer_test.dart +++ b/flutter/test/blockchain_signer_test.dart @@ -1,6 +1,6 @@ import 'package:flutter_test/flutter_test.dart'; -import 'package:blockchain_signer/blockchain_signer.dart'; +import 'package:blockchain_mobile_signer/blockchain_signer.dart'; void main() { } From b15ad6dd789ef1ea236ec7e388fca270df7dfc54 Mon Sep 17 00:00:00 2001 From: ethella Date: Tue, 31 May 2022 14:07:59 -0700 Subject: [PATCH 6/7] Rename blockchain_mobile_signer to blockchain_signer --- flutter/lib/blockchain_signer.dart | 2 +- flutter/lib/signer/remote/remote_signer.dart | 2 +- flutter/lib/signer/signer.dart | 2 +- flutter/pubspec.yaml | 4 ++-- flutter/test/blockchain_signer_test.dart | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/flutter/lib/blockchain_signer.dart b/flutter/lib/blockchain_signer.dart index acc9b63..158cc04 100644 --- a/flutter/lib/blockchain_signer.dart +++ b/flutter/lib/blockchain_signer.dart @@ -1,3 +1,3 @@ -library blockchain_mobile_signer; +library blockchain_signer; export 'signer/remote/remote_signer.dart'; diff --git a/flutter/lib/signer/remote/remote_signer.dart b/flutter/lib/signer/remote/remote_signer.dart index b4b95c0..1b49e8a 100644 --- a/flutter/lib/signer/remote/remote_signer.dart +++ b/flutter/lib/signer/remote/remote_signer.dart @@ -1,5 +1,5 @@ import 'dart:typed_data'; -import 'package:blockchain_mobile_signer/signer/signer.dart'; +import 'package:blockchain_signer/signer/signer.dart'; import '../response/signed_result.dart'; /// Remote Sign diff --git a/flutter/lib/signer/signer.dart b/flutter/lib/signer/signer.dart index 2e5670e..11f948b 100644 --- a/flutter/lib/signer/signer.dart +++ b/flutter/lib/signer/signer.dart @@ -1,5 +1,5 @@ import 'dart:typed_data'; -import 'package:blockchain_mobile_signer/signer/response/signed_result.dart'; +import 'package:blockchain_signer/signer/response/signed_result.dart'; /// Basic Signer that provides developers with signing interfaces for any blockchain. /// This is not yet the final version yet. Anything would be subjected to change diff --git a/flutter/pubspec.yaml b/flutter/pubspec.yaml index a812c33..cc29920 100644 --- a/flutter/pubspec.yaml +++ b/flutter/pubspec.yaml @@ -1,7 +1,7 @@ -name: blockchain_mobile_signer +name: blockchain_signer description: A new Flutter package project. version: 0.0.1 -homepage: +homepage: https://github environment: sdk: ">=2.16.2 <3.0.0" diff --git a/flutter/test/blockchain_signer_test.dart b/flutter/test/blockchain_signer_test.dart index 3a2c1f1..b3f114d 100644 --- a/flutter/test/blockchain_signer_test.dart +++ b/flutter/test/blockchain_signer_test.dart @@ -1,6 +1,6 @@ import 'package:flutter_test/flutter_test.dart'; -import 'package:blockchain_mobile_signer/blockchain_signer.dart'; +import 'package:blockchain_signer/blockchain_signer.dart'; void main() { } From aa88f35f8c07c4c7c36788b62bc792e19104a4f4 Mon Sep 17 00:00:00 2001 From: ethella Date: Tue, 31 May 2022 16:04:33 -0700 Subject: [PATCH 7/7] * Add example * Linter check --- flutter/example/example.dart | 72 +++++++++++++++++++ flutter/lib/signer/remote/remote_signer.dart | 2 - .../lib/signer/response/signed_result.dart | 6 +- flutter/lib/signer/signer.dart | 2 - flutter/prepublish.sh | 21 ++++++ flutter/pubspec.yaml | 7 +- 6 files changed, 102 insertions(+), 8 deletions(-) create mode 100644 flutter/example/example.dart create mode 100644 flutter/prepublish.sh diff --git a/flutter/example/example.dart b/flutter/example/example.dart new file mode 100644 index 0000000..7e027e3 --- /dev/null +++ b/flutter/example/example.dart @@ -0,0 +1,72 @@ +// Copyright (c), Magic Labs +// All rights reserved. Use of this source code is governed by a +// MIT license that can be found in the LICENSE file. + +import 'package:blockchain_signer/signer/remote/remote_signer.dart'; +import 'package:blockchain_signer/signer/response/signed_result.dart'; + +/// +/// This is a simple example of using blockchain signer interface to sign +/// given payloads. The payload will be sent to designated wallet provider for signature +/// +Future main() async { + TezosSigner signer = TezosSigner(provider); + + await signer.init(); + + /// operation in hex + const operationInHex = 'a356d122'; + /// watermark in bytes + const watermarkInBytes = Uint8List.fromList(crypto.hexDecode('03')); + SignedResult res = await signer.sign(operationInHex, watermarkInBytes); + + /// This creates a signature object from taquito + /// https://github.com/ecadlabs/taquito/blob/e5c9dcc54b5a806dbe7c0d0a2e8232a8bcde2074/packages/taquito-signer/src/ec-key.ts#L62 + print(res.sig); + print(res.sbytes); + print(res.bytes); + print(res.prefixSig); +} + +/// +/// This is a simple example of using blockchain signer interface to build +/// Tezos remote signer module on the wallet provider side +/// +class TezosSigner extends BlockchainModule implements RemoteSigner { + TezosSigner(RpcProvider provider) + : super(provider); + + late String _pk; + late String _pkh; + + static TezosSigner? instance; + + @override + String get address => _pkh; + + @override + String get publicKey => _pk; + + + @override + String get secretKey => + throw UnsupportedError('Secret key is not available'); + + /// sends unsigned payload to the Signer and wait for it to be signed + /// + /// @param [op] Operation to sign + /// @param [magicByte] Magic bytes 1 for block, 2 for endorsement, 3 for generic, 5 for the PACK format of michelson + Future init() async { + await response = sendToProvider(method: TezosMethod.taquito_getPublicKeyAndHash, params: []); + _pk = response.result.pk; + _pkh = response.result.pkh; + } + @override + Future sign(String op, Uint8List magicByte) async { + final params = {"bytes": op, "watermark": magicByte}; + + await response = sendToProvider(method: TezosMethod.taquito_sign, params: [params]); + return response; + } +} + diff --git a/flutter/lib/signer/remote/remote_signer.dart b/flutter/lib/signer/remote/remote_signer.dart index 1b49e8a..30114aa 100644 --- a/flutter/lib/signer/remote/remote_signer.dart +++ b/flutter/lib/signer/remote/remote_signer.dart @@ -5,7 +5,6 @@ import '../response/signed_result.dart'; /// Remote Sign /// A remote signer layer that provides signature service from non-custodial key management solutions abstract class RemoteSigner extends Signer { - @override Future sign(String op, Uint8List bytes); @@ -20,4 +19,3 @@ abstract class RemoteSigner extends Signer { // verifySignature } - diff --git a/flutter/lib/signer/response/signed_result.dart b/flutter/lib/signer/response/signed_result.dart index b4a3bdc..32b5884 100644 --- a/flutter/lib/signer/response/signed_result.dart +++ b/flutter/lib/signer/response/signed_result.dart @@ -13,7 +13,11 @@ class SignedResult { String bytes; // Original bytes String sbytes; // bytes + hex signature - SignedResult({required this.bytes, required this.sig, required this.prefixSig, required this.sbytes}); + SignedResult( + {required this.bytes, + required this.sig, + required this.prefixSig, + required this.sbytes}); factory SignedResult.fromJson(Map json) => _$SignedResultFromJson(json); diff --git a/flutter/lib/signer/signer.dart b/flutter/lib/signer/signer.dart index 11f948b..544e1ee 100644 --- a/flutter/lib/signer/signer.dart +++ b/flutter/lib/signer/signer.dart @@ -5,7 +5,6 @@ import 'package:blockchain_signer/signer/response/signed_result.dart'; /// This is not yet the final version yet. Anything would be subjected to change /// abstract class Signer { - Future sign(String op, Uint8List bytes); String? get publicKey; @@ -14,4 +13,3 @@ abstract class Signer { // verifySignature } - diff --git a/flutter/prepublish.sh b/flutter/prepublish.sh new file mode 100644 index 0000000..aaa491c --- /dev/null +++ b/flutter/prepublish.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +prepublishCheck (){ + + echo "=== Formatting source package $1 ===" + flutter format "$1" + tempFolderPath="./$1_copy/" + + echo + echo "=== Start prepublish check $1 ===" + + cp -r "./$1" "$tempFolderPath" + dart pub global run pana "$tempFolderPath" + rm -r "$tempFolderPath" + + echo + echo "=== Prepublish Check for $1 is completed! === " + echo +} + +prepublishCheck "lib" diff --git a/flutter/pubspec.yaml b/flutter/pubspec.yaml index cc29920..aa75ffd 100644 --- a/flutter/pubspec.yaml +++ b/flutter/pubspec.yaml @@ -1,7 +1,8 @@ name: blockchain_signer -description: A new Flutter package project. -version: 0.0.1 -homepage: https://github +description: A flutter universal blockchain signer protocol for third-party library to enable Remote signing and third part wallet provider +version: 0.1.0 +homepage: https://github.com/magiclabs/blockchain-mobile-signer +repository: https://github.com/magiclabs/blockchain-mobile-signer environment: sdk: ">=2.16.2 <3.0.0"