@libp2p/peer-id
Version:
Implementation of @libp2p/interface-peer-id
31 lines • 1.81 kB
TypeScript
/**
* @packageDocumentation
*
* An implementation of a peer id
*
* @example
*
* ```TypeScript
* import { peerIdFromString } from '@libp2p/peer-id'
* const peer = peerIdFromString('12D3KooWKnDdG3iXw9eTFijk3EWSunZcFi54Zka4wmtqtt6rPxc8')
*
* console.log(peer.toCID()) // CID(bafzaa...)
* console.log(peer.toString()) // "12D3K..."
* ```
*/
import { CID } from 'multiformats/cid';
import type { Ed25519PeerId, RSAPeerId, URLPeerId, Secp256k1PeerId, PeerId, PublicKey, Ed25519PublicKey, Secp256k1PublicKey, RSAPublicKey, Ed25519PrivateKey, Secp256k1PrivateKey, RSAPrivateKey, PrivateKey } from '@libp2p/interface';
import type { MultibaseDecoder } from 'multiformats/cid';
import type { MultihashDigest } from 'multiformats/hashes/interface';
export declare function peerIdFromString(str: string, decoder?: MultibaseDecoder<any>): Ed25519PeerId | Secp256k1PeerId | RSAPeerId | URLPeerId;
export declare function peerIdFromPublicKey(publicKey: Ed25519PublicKey): Ed25519PeerId;
export declare function peerIdFromPublicKey(publicKey: Secp256k1PublicKey): Secp256k1PeerId;
export declare function peerIdFromPublicKey(publicKey: RSAPublicKey): RSAPeerId;
export declare function peerIdFromPublicKey(publicKey: PublicKey): PeerId;
export declare function peerIdFromPrivateKey(privateKey: Ed25519PrivateKey): Ed25519PeerId;
export declare function peerIdFromPrivateKey(privateKey: Secp256k1PrivateKey): Secp256k1PeerId;
export declare function peerIdFromPrivateKey(privateKey: RSAPrivateKey): RSAPeerId;
export declare function peerIdFromPrivateKey(privateKey: PrivateKey): PeerId;
export declare function peerIdFromMultihash(multihash: MultihashDigest): PeerId;
export declare function peerIdFromCID(cid: CID): Ed25519PeerId | Secp256k1PeerId | RSAPeerId | URLPeerId;
//# sourceMappingURL=index.d.ts.map