@synet/core
Version:
Core cryptographic and identity primitives for Synet agents.
47 lines (46 loc) • 1.56 kB
TypeScript
export type KeyType = "rsa" | "ed25519" | "wireguard";
export interface KeyPair {
privateKey: string;
publicKey: string;
type: KeyType;
}
export interface KeyProvider {
generateKeyPair(): KeyPair;
}
export declare function getKeyProvider(type: KeyType): KeyProvider;
/**
*
* @param type The type of key to generate (e.g., '
* rsa', 'ed25519', 'wireguard')
* @returns A key pair object containing the private and public keys
* @throws Error if the key type is unsupported
* @returns
*/
export declare function generateKeyPair(type: KeyType): KeyPair;
/**
* Extract the public key from a private key
* @param privateKey The private key in PEM format
* @returns The corresponding public key in PEM format, or null if extraction fails
*/
export declare function derivePublicKey(privateKey: string): string | null;
/**
* Compute a short identifier from a public key
* @param publicKey The public key in PEM format
* @returns A 16-character hexadecimal identifier
*/
export declare function getShortId(publicKey: string): string;
/**
* Compute a fingerprint from a public key
* @param publicKey The public key in PEM format
* @returns A 64-character hexadecimal fingerprint
*/
export declare function getFingerprint(publicKey: string): string;
/**
* @deprecated Use generateKeyPair('wireguard') instead.
* Generates a WireGuard-compatible key pair using TweetNaCl.
* @returns A key pair object with WireGuard-compatible keys
*/
export declare function generateWireGuardKeyPair(): {
privateKey: string;
publicKey: string;
};