crypto_sign_ed25519_sk_to_x25519_sk static method

int crypto_sign_ed25519_sk_to_x25519_sk(
  1. Uint8List x25519_sk,
  2. Uint8List ed25519_sk
)

Converts Ed25519 private/signing key to Curve25519 private key. It's just simply the SHA512 and prone-to-buffered seed.

Implementation

static int crypto_sign_ed25519_sk_to_x25519_sk(
    Uint8List x25519_sk, Uint8List ed25519_sk) {
  final h = Uint8List(64);

  TweetNaCl._crypto_hash_off(h, ed25519_sk, 0, 32);

  h[0] &= 248;
  h[31] &= 127;
  h[31] |= 64;

  for (var i = 0; i < 32; i++) {
    x25519_sk[i] = h[i];
  }

  for (var i = 0; i < 64; i++) {
    h[i] = 0;
  }
  return 0;
}