跳到主要内容
版本:3.3.2

KeyPair

IOST账户中的秘钥对

constructor​

构造函数

Parameters​

NameTypeDescription
priKeyBytesBuffer私钥
algTypeNumberAlgorithm.Secp256k1 or Algorithm.Ed25519

Algorithm​

NameTypeDescription
Secp256k1Number1
Ed25519Number2

Returns​

KeyPair object instance.

Example​

const kp = new KeyPair(bs58.decode('2yquS3ySrGWPEKywCPzX4RTJugqRh7kJSo5aehsLYPEWkUxBWA39oMrZ7ZxuM4fgyXYs2cPwh5n8aNNpH5x2VyK1'));

newKeyPair​

新建一个秘钥对

Parameters​

NameTypeDescription
algTypeNumberAlgorithm.Secp256k1 or Algorithm.Ed25519

Returns​

KeyPair object instance.

Example​

const kp = KeyPair.newKeyPair(Algorithm.Ed25519);

B58SecKey​

获取当前私钥的base58编码字符串

Returns​

当前私钥的base58编码字符串

Example​

const kp = KeyPair.newKeyPair(Algorithm.Ed25519);
console.log(kp.B58SecKey())

B58PubKey​

获取当前公钥的base58编码字符串

Returns​

当前公钥的base58编码字符串

Example​

const kp = KeyPair.newKeyPair(Algorithm.Ed25519);
console.log(kp.B58PubKey())