Skip to content

zkmopro/semaphore_flutter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Semaphore Flutter Package

This is a Flutter package for Semaphore protocol.

Getting Started

Follow these steps to integrate the Semaphore Flutter package into your project.

Adding a package dependency to an app

  1. Add Dependency: You can add semaphore to your project using the command line or by manually editing pubspec.yaml.

    • Manual Edit (Required for local path or specific Git dependencies): Open your pubspec.yaml file and add semaphore under dependencies.

      dependencies:
          flutter:
              sdk: flutter
      
          semaphore:
              git:
                  url: https://github.com/zkmopro/semaphore_flutter.git
  2. Install Package: Run the following command in your terminal from the root of your Flutter project:

    flutter pub get

Usage Example

Identity

import 'package:semaphore/semaphore.dart';

final privateKey = utf8.encode("secret");

final identity = Identity(privateKey);
final commitment = await identity.commitment();
final privateKey = await identity.privateKey();
final secretScalar = await identity.secretScalar();
final toElement = await identity.toElement();

Group

import 'package:semaphore/semaphore.dart';

final member1 = await identity1.toElement();
final member2 = await identity2.toElement();
final group = Group([member1, member2]);
// get root
await group.root();

Proof

import 'package:semaphore/semaphore.dart';

final message = "message";
final scope = "scope";
final treeDepth = 16;

final proof = await generateSemaphoreProof(
    identity,
    group,
    message,
    scope,
    treeDepth,
);

final valid = await verifySemaphoreProof(proof);

Flutter Example App

  • Open the example app that uses the defined flutter package in the example/ folder
    cd example
  • Install the dependencies
    flutter pub get
  • Open an iOS simulator/device or an Android emulator/device and run the example app
    flutter run
  • Clean the cache if you update the bindings and it throws errors
    flutter clean

How to Build the Package

iOS

Android

Flutter Library

Community

  • X account:
  • Telegram group:

Acknowledgements

This work was initially sponsored by a joint grant from PSE and 0xPARC. It is currently incubated by PSE.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published