Giter Club home page Giter Club logo

curve25519-dart's People

Contributors

k-s-t-i avatar ks-ks-ks avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

raqeta randsoy

curve25519-dart's Issues

Add benchmarks for sign and verify seems kinda slow

Thanks for this implementations, a good choice for Signal XVEdDSA.

core benchmark code

import 'dart:typed_data';

import 'package:curve25519_vrf/curve25519_vrf.dart';
import 'rate_benchmark.dart';

class CurveBenchmark extends RateBenchmark {
  CurveBenchmark(Type type, [int dataLength = 1024 * 1024])
      : _type = type,
        _data = Uint8List(dataLength),
        _curve25519 = Curve25519(),
        super('${type.name}');

  final Curve25519 _curve25519;
  final Uint8List _data;
  final Type _type;
  late final KeyPair _keyPair;
  late Signature _signatureStandard;
  late Signature _signatureVrf;

  @override
  void setup() {
    _keyPair = _curve25519.newKeyPair();
    _signatureStandard = _curve25519.sign(_keyPair, _data, SignatureType.STANDARD);
    _signatureVrf = _curve25519.sign(_keyPair, _data, SignatureType.VRF);
  }

  @override
  void run() {
    if (_type == Type.signStandard) {
      _curve25519.sign(_keyPair, _data, SignatureType.STANDARD);
    } else if (_type == Type.verifyStandard) {
      _curve25519.verify(_data, _signatureStandard);
    } else if (_type == Type.signVrf) {
      _curve25519.sign(_keyPair, _data, SignatureType.VRF);
    } else {
      _curve25519.verify(_data, _signatureVrf);
    }
    addSample(_data.length);
  }
}

enum Type {
  signStandard, verifyStandard, signVrf, verifyVrf
}

void main() {
  CurveBenchmark(Type.signStandard).report();
  CurveBenchmark(Type.verifyStandard).report();
  CurveBenchmark(Type.signVrf).report();
  CurveBenchmark(Type.verifyVrf).report();
}

results on MacBook Pro (16-inch, 2019), macOS Big Sur, with 2.4GHz i9 32GB

type rate iterations time data throughput
signStandard 1.75 MB/s 9 iterations 5131 ms 9.00 MB
verifyStandard 3.65 MB/s 19 iterations 5212 ms 19.00 MB
signVrf 1.33 MB/s 7 iterations 5259 ms 7.00 MB
verifyVrf 1.74 MB/s 9 iterations 5177 ms 9.00 MB

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.