dvote 0.5.12

DVote Flutter #

A Dart/Flutter plugin to interact with Vocdoni voting processes.

It provides Dart libraries as well as native modules written in Go to perform cryptographic and specialized operations natively.

More details: https://pub.dev/packages/dvote

Example #

  • See example/README.md to get started.
  • See example/lib/main.dart for a usage example.

0.5.12 #

  • Updating the Entity data models

0.5.11 #

  • Allowing to parse and fetch process metadata
  • Updating the data models

0.5.10 #

  • Improving the Metadata parser

0.5.9 #

  • Adding support for register entity actions

0.5.8 #

  • Adding a JSON Feed protobuf parser
  • Simplifying the JSON Feed model

0.5.7 #

  • Correcting the identity data model

0.5.6 #

  • Improving the data model

0.5.5 #

  • Updated data models

0.5.4 #

  • Updated data models

0.5.3 #

  • Parsing Entity metadata for use with protobuf

0.5.2 #

  • Export the Gateway data model

0.5.1 #

  • Improve the data models

0.5.0 #

  • Rearranging the structure of methods and how functions are invoked
  • Adding the definitions of identity management operations

0.4.2 #

  • Checking response timestamps from Gateways

0.4.1 #

  • Exporting EntityAction and classes extended from it
  • Allowing to define entryPoints

0.4.0 #

  • Signing using the Ethereum prefix for web compatibility
  • Allowing to set the origin of the metadata of an Entity

0.3.1 #

0.3.0 #

  • Allowing to fetch Entity metadata from ENS+IPFS
  • Providing a class to wrap the metadata of an Entity
  • Arranging the API methods so they can be used by just importing dvote.dart

0.2.3 #

  • Adding the missing bindings from 0.2.2
  • Provide a better example/Readme.md

0.2.2 #

  • Allow to sign and verify signatures using go-ethereum ECDSA

0.2.1 #

  • Allow to sign messages using go-ethereum ECDSA

0.2.0 #

  • Allow to encrypt/decrypt strings using AES-GCM

0.1.1 #

  • Allow to use optional named parameters

0.1.0 #

  • Provide support for mnemonic to private/public key and address conversion

0.0.1 #

  • Initial scaffold of the plugin

example/README.md

DVote example #

This plugin provides cryptographic and communication libraries to interact with decentralized votes running on the Vocdoni platform.

Getting Started #

Import the Dart library on your project and use the static functions available on the Dvote class

import 'package:dvote/dvote.dart';

HD Wallet management #

Generating mnemonics and computing private/public keys

final mnemonic = await generateMnemonic();
final privateKey = await mnemonicToPrivateKey(mnemonic, hdPath: "m/44'/60'/0'/0/5");
final publicKey = await mnemonicToPublicKey(mnemonic);
final address = await mnemonicToAddress(mnemonic);

Signing #

Computing signatures using ECDSA cryptography

final signature = await signString(messageToSign, privateKey);
final valid = await verifySignature(signature, messageToSign, publicKey);

Encryption #

Using symmetric AES-GCM encryption to store private data on a mobile device

final encrypted = await encryptString(myText, myPassphrase);
final decrypted = await decryptString(encrypted, myPassphrase);

Entity API #

Use a Vocdoni Gateway to fetch the metadata of an Entity

import 'package:dvote/dvote.dart';

EntityReference entity = EntityReference();
entity.entityId = "0x1234...";
entity.resolverAddress = "0x2345...";

final entityMeta = await fetchEntity(entity, vocGateway, web3Gateway);

File API #

Use a Vocdoni Gateway to fetch static content from the net

import 'package:dvote/dvote.dart';

final contentUri = ContentURI("ipfs://QmSsfizN4rpSDLRZw3X3WooCPpnBktZ5bEShvmLZuf88iw,https://my-server/file.txt");
final gatewayUri = "ws://hostname:2082/dvote";
final gwPublicKey = "02325f284f50fa52d53579c7873a480b351cc20f7780fa556929f5017283ad2449"

final content = await fetchFileString(contentUri, gatewayUri, gatewayPublicKey: gwPublicKey);

Data models and storage #

DVote Flutter exports multiple Dart classes that allow to wrap, parse, serialize and deserialize the most relevant data schemes used within the platform.

import 'package:dvote/dvote.dart';

// Parse from JSON
Entity entity = parseEntityMetadata("{ ... }");
print(entity.name["en"]);
print(entity.media.avatar);
print(entity.contracts.resolverAddress);

// Serialize into a binary file
File file1 = File("./my-entity.dat");
file1.writeAsBytes(entity.writeToBuffer());

// Reading back from a file
File file3 = File("./my-entity.dat");
final entityBytes = await file3.readAsBytes();
Entity entity2 = Entity.fromBuffer(entityBytes);
print(entity2.name["en"]);

// Storing a collection of entities
EntitiesStore store = EntitiesStore();
store.entities.addAll([entity, entity2]);
File file2 = File("./entities.dat");
await file2.writeAsBytes(store.writeToBuffer());

Classes #

The following classes are exported:

  • Entity
    • EntityStore
    • Entity_ContractsInfo
    • Entity_VotingProcesses
    • Entity_Media
    • Entity_Action_ImageSource
    • Entity_Action
    • Entity_GatewayBootNode
    • Entity_GatewyUpdate
    • Entity_Relay
    • Entity_EntityReference
    • EntitySummary
  • Process
    • Process_Census
    • Process_Details
    • Process_Details_Question
    • Process_Details_Question_VoteOption
  • Feed
    • FeedsStore
    • FeedPost_Author
    • FeedPost
  • Gateway
    • GatewaysStore
  • Identity
    • IdentitiesStore
    • Identity_Claim
  • Key

Parsers #

Raw JSON data can't be directly serialized into a Protobuf object. For this reason, several parsers are provided:

  • Entity parseEntityMetadata(String json)
    • List<Entity_Action> parseEntityActions(List actions)
    • List<Entity_GatewayBootNode> parseBootNodes(List bootNodes)
    • List<Entity_EntityReference> parseEntityReferences(List entities)
  • Process parseProcessMetadata(String json)
    • List<Process_Details_Question> parseQuestions(List items)
  • Feed parseFeed(String json)

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  dvote: ^0.5.12

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:dvote/dvote.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
51
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
75
Learn more about scoring.

We analyzed this package on Aug 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/models/dart/entity.pb.dart.

Run flutter format to format lib/models/dart/entity.pb.dart.

Format lib/models/dart/entity.pbenum.dart.

Run flutter format to format lib/models/dart/entity.pbenum.dart.

Format lib/models/dart/entity.pbjson.dart.

Run flutter format to format lib/models/dart/entity.pbjson.dart.

Fix additional 22 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/models/dart/entity.pbserver.dart (Run flutter format to format lib/models/dart/entity.pbserver.dart.)
  • lib/models/dart/feed.pb.dart (Run flutter format to format lib/models/dart/feed.pb.dart.)
  • lib/models/dart/feed.pbenum.dart (Run flutter format to format lib/models/dart/feed.pbenum.dart.)
  • lib/models/dart/feed.pbjson.dart (Run flutter format to format lib/models/dart/feed.pbjson.dart.)
  • lib/models/dart/feed.pbserver.dart (Run flutter format to format lib/models/dart/feed.pbserver.dart.)
  • lib/models/dart/gateway.pb.dart (Run flutter format to format lib/models/dart/gateway.pb.dart.)
  • lib/models/dart/gateway.pbenum.dart (Run flutter format to format lib/models/dart/gateway.pbenum.dart.)
  • lib/models/dart/gateway.pbjson.dart (Run flutter format to format lib/models/dart/gateway.pbjson.dart.)
  • lib/models/dart/gateway.pbserver.dart (Run flutter format to format lib/models/dart/gateway.pbserver.dart.)
  • lib/models/dart/identity.pb.dart (Run flutter format to format lib/models/dart/identity.pb.dart.)
  • lib/models/dart/identity.pbenum.dart (Run flutter format to format lib/models/dart/identity.pbenum.dart.)
  • lib/models/dart/identity.pbjson.dart (Run flutter format to format lib/models/dart/identity.pbjson.dart.)
  • lib/models/dart/identity.pbserver.dart (Run flutter format to format lib/models/dart/identity.pbserver.dart.)
  • lib/models/dart/key.pb.dart (Run flutter format to format lib/models/dart/key.pb.dart.)
  • lib/models/dart/key.pbenum.dart (Run flutter format to format lib/models/dart/key.pbenum.dart.)
  • lib/models/dart/key.pbjson.dart (Run flutter format to format lib/models/dart/key.pbjson.dart.)
  • lib/models/dart/key.pbserver.dart (Run flutter format to format lib/models/dart/key.pbserver.dart.)
  • lib/models/dart/process.pb.dart (Run flutter format to format lib/models/dart/process.pb.dart.)
  • lib/models/dart/process.pbenum.dart (Run flutter format to format lib/models/dart/process.pbenum.dart.)
  • lib/models/dart/process.pbjson.dart (Run flutter format to format lib/models/dart/process.pbjson.dart.)
  • lib/models/dart/process.pbserver.dart (Run flutter format to format lib/models/dart/process.pbserver.dart.)
  • lib/util/parsers.dart (Run flutter format to format lib/util/parsers.dart.)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.0 <3.0.0
convert ^2.1.1 2.1.1
flutter 0.0.0
http ^0.12.0+2 0.12.0+2
protobuf ^0.13.15 0.13.15
web3dart ^1.0.0 1.1.1+1
web_socket_channel ^1.0.13 1.0.15
Transitive dependencies
async 2.3.0
charcode 1.1.2
collection 1.14.11 1.14.12
crypto 2.1.2
fixnum 0.10.9
http_parser 3.1.3
isolate 2.0.2
json_rpc_2 2.1.0
meta 1.1.6 1.1.7
path 1.6.4
pedantic 1.8.0+1
pointycastle 1.0.1
sky_engine 0.0.99
source_span 1.5.5
stack_trace 1.9.3
stream_channel 2.0.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
uuid 2.0.2
vector_math 2.0.8
Dev dependencies
flutter_test