dvote 0.5.29

  • Readme
  • Changelog
  • Example
  • Installing
  • 77

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.29 #

  • Fix on genProof

0.5.28 #

  • Minor change on the census

0.5.27 #

  • Adding checkProof

0.5.26 #

  • Polishing the envelope helpers

0.5.25 #

  • Updating the Process contract return indexes

0.5.24 #

  • Updating the time estimation functions form the Vote API

0.5.23 #

  • Updating the Voting Process smart contract definition

0.5.22 #

  • Adding getTimeUntilStart and getTimeUntilEnd

0.5.21 #

  • Internal improvements

0.5.20 #

  • Adding getSize to the Census API

0.5.19 #

  • Integrating Poseidon hashes from Go DVote Mobile
  • Restructuring the example project

0.5.18 #

  • Allowing to fetch voting processes from an Entity

0.5.17 #

  • Allowing to fetch the boot nodes URI from the blockchain

0.5.16 #

  • Fetching gateway info from boot nodes

0.5.15 #

  • Republishing

0.5.14 #

  • Republishing

0.5.13 #

  • Adding support for for ENS domain resolution

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 entityRef = EntityReference();
entityRef.entityId = "0x1234...";

final gwInfo = await getRandomDefaultGatewayInfo("goerli");
final DVoteGateway dvoteGw = DVoteGateway(gwInfo.dvote, publicKey: gwInfo.publicKey);
final Web3Gateway web3Gw = Web3Gateway(gwInfo.web3);

final entityMeta = await fetchEntity(entityRef, dvoteGw, web3Gw);
dvoteGw.disconnect();

Process API #

Use a Vocdoni Gateway to fetch the active voting processes of an Entity

import 'package:dvote/dvote.dart';

EntityReference entityRef = EntityReference();
entityRef.entityId = "0x1234...";

final gwInfo = await getRandomDefaultGatewayInfo("goerli");
final DVoteGateway dvoteGw = DVoteGateway(gwInfo.dvote, publicKey: gwInfo.publicKey);
final Web3Gateway web3Gw = Web3Gateway(gwInfo.web3);

// All active from an Entity
final List<ProcessMetadata>> processes = await fetchActiveProcesses(entityRef, dvoteGw, web3Gw);

// A specific Voting Process
final pid = "0x1234...";
final ProcessMetadataprocessMeta = await getProcessMetadata(pid, dvoteGw, web3Gw);

dvoteGw.disconnect();

File API #

Use a Vocdoni Gateway to fetch static content from the net

import 'package:dvote/dvote.dart';

final gwInfo = await getRandomDefaultGatewayInfo("goerli");
final DVoteGateway dvoteGw = DVoteGateway(gwInfo.dvote, publicKey: gwInfo.publicKey);
final Web3Gateway web3Gw = Web3Gateway(gwInfo.web3);

final contentUri = ContentURI("ipfs://QmSsfizN4rpSDLRZw3X3WooCPpnBktZ5bEShvmLZuf88iw,https://my-server/file.txt");

final content = await fetchFileString(contentUri, dvoteGw, web3Gw);

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);

// 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_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.29

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]
58
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
77
Learn more about scoring.

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

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/blockchain/vote-contract.dart.

Run flutter format to format lib/blockchain/vote-contract.dart.

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.

Fix additional 23 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/models/dart/entity.pbjson.dart (Run flutter format to format lib/models/dart/entity.pbjson.dart.)
  • 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/net/gateway-bootnodes.dart (Run flutter format to format lib/net/gateway-bootnodes.dart.)

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (protobuf).

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.16+1 1.0.0
web3dart ^1.0.0 1.2.1
web_socket_channel ^1.0.13 1.1.0
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.11 1.14.12
crypto 2.1.3
fixnum 0.10.9
http_parser 3.1.3
isolate 2.0.2
json_rpc_2 2.1.0
meta 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