2019-11-11 21:58:04 +01:00
|
|
|
import { x25519 } from 'bcrypto';
|
|
|
|
import * as crypto from 'libp2p-crypto';
|
|
|
|
|
2019-11-20 13:23:36 +01:00
|
|
|
import { KeyPair } from "./@types/libp2p";
|
|
|
|
import { bytes } from "./@types/basic";
|
2019-11-11 21:58:04 +01:00
|
|
|
|
|
|
|
export async function generateKeypair() : Promise<KeyPair> {
|
|
|
|
const privateKey = x25519.privateKeyGenerate();
|
|
|
|
const publicKey = x25519.publicKeyCreate(privateKey);
|
|
|
|
|
|
|
|
return {
|
|
|
|
publicKey,
|
|
|
|
privateKey,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function signPayload(privateKey: bytes, payload: bytes) {
|
|
|
|
const Ed25519PrivateKey = crypto.keys.supportedKeys.ed25519.Ed25519PrivateKey;
|
|
|
|
// const ed25519 = Ed25519PrivateKey(privateKey, "need-to-get-public-key");
|
|
|
|
// return ed25519.sign(privateKey, payload);
|
|
|
|
}
|