dcp/wallet.PrivateKey(privateKey, testOnly)


# new PrivateKey(privateKey, testOnly)

Class which represents an Ethereum private key used in DCP for things like proof of user identity, bank account ownership, etc.

Name Type Description
privateKey string | object

The private key we want to represent. If the passed private key is a string, it should (but is not required to) have the 0x prefix. If privateKey is an object, we coerce the object with toString(16) before working with it (BigNumber and similar objects are expected to "just work").

testOnly boolean

when true, return true only when the privateKey argument could be used to construct without throwing

TypeError when privateKey is invalid

TypeError when privateKey is a number; eg a programmer typed in a hexadecimal literal.

instance of PrivateKey whose value is a checksummed string of hex digits with leading 0x.


# ct(address) → {boolean}

Corresponds-To method. Determines if this PrivateKey corresponds to the passed address.

Name Type Description
address string | object

An instance of Address or a value suitable for the Address constructor


true when this address corresponds to the passed privateKey


# eq(privateKey2) → {boolean}

Equality comparsion.

Name Type Description
privateKey2 string | object

The private key we want to compare. May be used as an argument to the PrivateKey() constructor.

true if privateKey2 represents the same eth private key as this instance; false otherwise.


# toAddress() → {module:dcp/wallet.Address}

Determine the address (public key) associated with this instance of PrivateKey. Only performs the hash once, no matter how many times you call the method. note - This has a side effect of converting the method call from an inherited property to an own property on first call.

# toString()

An Ethereum private key including leading 0x.