-
Notifications
You must be signed in to change notification settings - Fork 436
/
index.ts
39 lines (35 loc) · 1.26 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import type { Uint8ArrayList } from 'uint8arraylist'
export interface PublicKey<Type extends KeyType = 'Ed25519'> {
readonly bytes: Uint8Array
verify(data: Uint8Array | Uint8ArrayList, sig: Uint8Array): boolean | Promise<boolean>
marshal(): Uint8Array
equals(key: PublicKey<Type>): boolean
hash(): Uint8Array | Promise<Uint8Array>
}
/**
* Generic private key interface
*/
export interface PrivateKey<Type extends KeyType = 'Ed25519'> {
readonly public: PublicKey<Type>
readonly bytes: Uint8Array
sign(data: Uint8Array | Uint8ArrayList): Uint8Array | Promise<Uint8Array>
marshal(): Uint8Array
equals(key: PrivateKey<Type>): boolean
hash(): Uint8Array | Promise<Uint8Array>
/**
* Gets the ID of the key.
*
* The key id is the base58 encoding of the SHA-256 multihash of its public key.
* The public key is a protobuf encoding containing a type and the DER encoding
* of the PKCS SubjectPublicKeyInfo.
*/
id(): Promise<string>
/**
* Exports the password protected key in the format specified.
*/
export(password: string, format?: 'pkcs-8' | string): Promise<string>
}
export const Ed25519 = 'Ed25519'
export const RSA = 'RSA'
export const secp256k1 = 'secp256k1'
export type KeyType = typeof Ed25519 | typeof RSA | typeof secp256k1