Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Dart instead of Go implement the XEdDSA signature #1

Closed
crossle opened this issue Jul 31, 2020 · 1 comment
Closed

Use Dart instead of Go implement the XEdDSA signature #1

crossle opened this issue Jul 31, 2020 · 1 comment

Comments

@crossle
Copy link
Member

crossle commented Jul 31, 2020

Now we use Dart ffi call Go for XEdDSA signature, we should use Dart implement it

Uint8List sha512HashFunc(Uint8List m) {
  var digest = sha512.convert(m).bytes;
  digest[0] &= 248;
  digest[31] &= 127;
  digest[31] |= 64;
  return digest;
}

Uint8List signature(Uint8List privateKey, Uint8List message, Uint8List random) {
  var pk = Ed25519.publickey(sha512HashFunc, privateKey);
  // Calculate r
  var diversifier = Uint8List.fromList([
    0xFE,
    0xFF,
    0xFF,
    0xFF,
    0xFF,
    0xFF,
    0xFF,
    0xFF,
    0xFF,
    0xFF,
    0xFF,
    0xFF,
    0xFF,
    0xFF,
    0xFF,
    0xFF,
    0xFF,
    0xFF,
    0xFF,
    0xFF,
    0xFF,
    0xFF,
    0xFF,
    0xFF,
    0xFF,
    0xFF,
    0xFF,
    0xFF,
    0xFF,
    0xFF,
    0xFF,
    0xFF
  ]);

  var output = new AccumulatorSink<Digest>();
  var input = sha512.startChunkedConversion(output);
  input.add(diversifier);
  input.add(privateKey);
  input.add(message);
  input.add(random);
  input.close();
  var r = output.events.single.bytes;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants