DefinitelyTyped/types/ed25519/index.d.ts
Erik Mavrinac b8660a296a Create @types/ed25519 for ed25519 NPM package (#20966)
* Revert "Add tsline file"

This reverts commit a0f8c9acc3.

* Revert "Rename .d.ts file per guidelines"

This reverts commit 7eb6f76ab5.

* Revert "Add types for ZeroMQ.js, derived from the 'zmq' type definitions"

This reverts commit d5d3cd0fca.

* Add new types for the ed25519 NPM package
2017-10-24 11:36:34 -07:00

47 lines
1.5 KiB
TypeScript

// Type definitions for ed25519 0.0
// Project: https://github.com/dazoe/ed25519
// Definitions by: Erik Mavrinac <https://github.com/erikma>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Main site: https://ed25519.cr.yp.to/
// Manually generated and maintained because the package is a
// veneer on an underlying C library; auto-generation won't work.
// The JavaScript-C interface is well described at
// https://github.com/dazoe/ed25519/blob/master/src/ed25519.cc
/// <reference types="node" />
/** The key material returned from a call to MakeKeypair(). */
export interface CurveKeyPair {
/**
* A Buffer containing the public portion of the Curve25519 key.
*/
publicKey: Buffer;
/**
* A Buffer containing the private, secret portion of the Curve25519 key.
*/
privateKey: Buffer;
}
/**
* Uses the crytpographically strong random seed to generate a
* Curve25519 key pair.
* @return The public and private key pair.
*/
export function MakeKeypair(seed: Buffer): CurveKeyPair;
/**
* Signs a plaintext message buffer using the private key generated using
* MakeKeypair().
* @return The signature calculated on the plaintext.
*/
export function Sign(message: Buffer, privateKeyOrKeyPair: Buffer | CurveKeyPair): Buffer;
/**
* Verifies a signature for a message buffer using a
* public key generated using MakeKeypair().
* @return True if the signature validates correctly, false otherwise.
*/
export function Verify(message: Buffer, signature: Buffer, publicKey: Buffer): boolean;