Class

Keypair

Keypair(keys)

Keypair represents public (and secret) keys of the account.

Currently Keypair only supports ed25519 but in a future this class can be abstraction layer for other public-key signature systems.

Use more convenient methods to create Keypair object:

Constructor

# new Keypair(keys)

Parameters:
Name Type Attributes Description
keys object

At least one of keys must be provided.

type string

Public-key signature system name. (currently only ed25519 keys are supported)

publicKey Buffer <optional>

Raw public key

secretKey Buffer <optional>

Raw secret key (32-byte secret seed in ed25519`)

View Source js-stellar-base/src/keypair.js, line 28

Classes

Keypair

Methods

# canSign() → {boolean}

Returns true if this Keypair object contains secret key and can sign.

View Source js-stellar-base/src/keypair.js, line 206

boolean

# publicKey() → {string}

Returns public key associated with this Keypair object.

View Source js-stellar-base/src/keypair.js, line 174

string

# rawPublicKey() → {Buffer}

Returns raw public key

View Source js-stellar-base/src/keypair.js, line 160

Buffer

# rawSecretKey() → {Buffer}

Returns raw secret key.

View Source js-stellar-base/src/keypair.js, line 198

Buffer

# secret() → {string}

Returns secret key associated with this Keypair object

View Source js-stellar-base/src/keypair.js, line 182

string

# sign(data) → {Buffer}

Signs data.

Parameters:
Name Type Description
data Buffer

Data to sign

View Source js-stellar-base/src/keypair.js, line 215

Buffer

# signDecorated(data) → {xdr.DecoratedSignature}

Returns the decorated signature (hint+sig) for arbitrary data.

Parameters:
Name Type Description
data Buffer

arbitrary data to sign

See:
  • TransactionBase.addDecoratedSignature

View Source js-stellar-base/src/keypair.js, line 242

the raw signature structure which can be added directly to a transaction envelope

xdr.DecoratedSignature

# signPayloadDecorated(data) → {xdr.DecoratedSignature}

Returns the raw decorated signature (hint+sig) for a signed payload signer.

The hint is defined as the last 4 bytes of the signer key XORed with last 4 bytes of the payload (zero-left-padded if necessary).

Parameters:
Name Type Description
data Buffer

data to both sign and treat as the payload

See:

View Source js-stellar-base/src/keypair.js, line 261

xdr.DecoratedSignature

# verify(data, signature) → {boolean}

Verifies if signature for data is valid.

Parameters:
Name Type Description
data Buffer

Signed data

signature Buffer

Signature

View Source js-stellar-base/src/keypair.js, line 229

boolean

# xdrMuxedAccount(idopt) → {xdr.MuxedAccount}

Creates a xdr.MuxedAccount object from the public key.

You will get a different type of muxed account depending on whether or not you pass an ID.

Parameters:
Name Type Attributes Description
id string <optional>

stringified integer indicating the underlying muxed ID of the new account object

View Source js-stellar-base/src/keypair.js, line 139

xdr.MuxedAccount

# static fromPublicKey(publicKey) → {Keypair}

Creates a new Keypair object from public key.

Parameters:
Name Type Description
publicKey string

public key (ex. GB3KJPLFUYN5VL6R3GU3EGCGVCKFDSD7BEDX42HWG5BWFKB3KQGJJRMA)

View Source js-stellar-base/src/keypair.js, line 103

Keypair

# static fromRawEd25519Seed(rawSeed) → {Keypair}

Creates a new Keypair object from ed25519 secret key seed raw bytes.

Parameters:
Name Type Description
rawSeed Buffer

Raw 32-byte ed25519 secret key seed

View Source js-stellar-base/src/keypair.js, line 79

Keypair

# static fromSecret(secret) → {Keypair}

Creates a new Keypair instance from secret. This can either be secret key or secret seed depending on underlying public-key signature system. Currently Keypair only supports ed25519.

Parameters:
Name Type Description
secret string

secret key (ex. SDAKFNYEIAORZKKCYRILFQKLLOCNPL5SWJ3YY5NM3ZH6GJSZGXHZEPQS)

View Source js-stellar-base/src/keypair.js, line 68

Keypair

# static master(networkPassphrase) → {Keypair}

Returns Keypair object representing network master key.

Parameters:
Name Type Description
networkPassphrase string

passphrase of the target stellar network (e.g. "Public Global Stellar Network ; September 2015").

View Source js-stellar-base/src/keypair.js, line 88

Keypair

# static random() → {Keypair}

Create a random Keypair object.

View Source js-stellar-base/src/keypair.js, line 115

Keypair