@dfinity/identity
Version:
JavaScript and TypeScript library to manage identity with the Internet Computer
67 lines • 2.75 kB
TypeScript
import { type DerEncodedPublicKey, type KeyPair, type PublicKey, type Signature, SignIdentity } from '@dfinity/agent';
export declare class Ed25519PublicKey implements PublicKey {
#private;
/**
* Construct Ed25519PublicKey from an existing PublicKey
* @param {unknown} maybeKey - existing PublicKey, ArrayBuffer, DerEncodedPublicKey, or hex string
* @returns {Ed25519PublicKey} Instance of Ed25519PublicKey
*/
static from(maybeKey: unknown): Ed25519PublicKey;
static fromRaw(rawKey: Uint8Array): Ed25519PublicKey;
static fromDer(derKey: DerEncodedPublicKey): Ed25519PublicKey;
private static RAW_KEY_LENGTH;
private static derEncode;
private static derDecode;
get rawKey(): Uint8Array;
get derKey(): DerEncodedPublicKey;
private constructor();
toDer(): DerEncodedPublicKey;
toRaw(): Uint8Array;
}
/**
* Ed25519KeyIdentity is an implementation of SignIdentity that uses Ed25519 keys. This class is used to sign and verify messages for an agent.
*/
export declare class Ed25519KeyIdentity extends SignIdentity {
#private;
/**
* Generate a new Ed25519KeyIdentity.
* @param seed a 32-byte seed for the private key. If not provided, a random seed will be generated.
* @returns Ed25519KeyIdentity
*/
static generate(seed?: Uint8Array): Ed25519KeyIdentity;
static fromParsedJson(obj: JsonnableEd25519KeyIdentity): Ed25519KeyIdentity;
static fromJSON(json: string): Ed25519KeyIdentity;
static fromKeyPair(publicKey: Uint8Array, privateKey: Uint8Array): Ed25519KeyIdentity;
static fromSecretKey(secretKey: Uint8Array): Ed25519KeyIdentity;
protected constructor(publicKey: PublicKey, privateKey: Uint8Array);
/**
* Serialize this key to JSON.
*/
toJSON(): JsonnableEd25519KeyIdentity;
/**
* Return a copy of the key pair.
*/
getKeyPair(): KeyPair;
/**
* Return the public key.
*/
getPublicKey(): Required<PublicKey>;
/**
* Signs a blob of data, with this identity's private key.
* @param challenge - challenge to sign with this identity's secretKey, producing a signature
*/
sign(challenge: Uint8Array): Promise<Signature>;
/**
* Verify
* @param sig - signature to verify
* @param msg - message to verify
* @param pk - public key
* @returns - true if the signature is valid, false otherwise
*/
static verify(sig: ArrayBuffer | Uint8Array | string, msg: ArrayBuffer | Uint8Array | string, pk: ArrayBuffer | Uint8Array | string): boolean;
}
type PublicKeyHex = string;
type SecretKeyHex = string;
export type JsonnableEd25519KeyIdentity = [PublicKeyHex, SecretKeyHex];
export {};
//# sourceMappingURL=ed25519.d.ts.map