본문으로 건너뛰기
버전: 3.3.2

KeyPair

This is the main class that used to create IOST account keyPairs.

constructor

constructor method is a special method for creating and initializing KeyPair class.

Parameters

NameTypeDescription
priKeyBytesBufferprivate key
algTypeNumberAlgorithm.Secp256k1 or Algorithm.Ed25519

Algorithm

NameTypeDescription
Secp256k1Number1
Ed25519Number2

Returns

KeyPair object instance.

Example

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

newKeyPair

newKeyPair create new public/private key pair

Parameters

NameTypeDescription
algTypeNumberAlgorithm.Secp256k1 or Algorithm.Ed25519

Returns

KeyPair object instance.

Example

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

B58SecKey

B58SecKey return current KeyPair's base 58 encode secret key.

Returns

return current KeyPair's base 58 encode secret key.

Example

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

B58PubKey

B58SecKey return current KeyPair's base 58 encode public key.

Returns

return current KeyPair's base 58 encode public key.

Example

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