• Overview
  • Design
  • API Reference
  • Changelog
  • Contribute
Show / Hide Table of Contents
  • Libplanet
    • Address
    • AddressExtension
    • ByteUtil
    • Hashcash
    • Hashcash.Stamp
    • HashDigest<T>
    • HashDigestExtension
    • Nonce
  • Libplanet.Action
    • AccountStateGetter
    • ActionEvaluation
    • ActionTypeAttribute
    • IAccountStateDelta
    • IAction
    • IActionContext
    • IRandom
    • MissingActionTypeException
    • PolymorphicAction<T>
    • RandomExtension
    • UnexpectedlyTerminatedActionException
  • Libplanet.Blockchain
    • BlockChain<T>
    • BlockChain<T>.TipChangedEventArgs
    • IncompleteBlockStatesException
    • MineBlockEventArgs<T>
  • Libplanet.Blockchain.Policies
    • BlockPolicy<T>
    • IBlockPolicy<T>
  • Libplanet.Blocks
    • Block<T>
    • InvalidBlockDifficultyException
    • InvalidBlockException
    • InvalidBlockHashException
    • InvalidBlockIndexException
    • InvalidBlockNonceException
    • InvalidBlockPreviousHashException
    • InvalidBlockTimestampException
    • InvalidGenesisBlockException
  • Libplanet.Crypto
    • CryptoConfig
    • DefaultCryptoBackend
    • ICryptoBackend
    • InvalidCiphertextException
    • PrivateKey
    • PublicKey
    • SymmetricKey
  • Libplanet.KeyStore
    • IncorrectPassphraseException
    • InvalidKeyJsonException
    • KeyJsonException
    • MismatchedAddressException
    • ProtectedPrivateKey
    • UnsupportedKeyJsonException
  • Libplanet.KeyStore.Ciphers
    • Aes128Ctr
    • ICipher
  • Libplanet.KeyStore.Kdfs
    • IKdf
    • Pbkdf2<T>
    • Scrypt
  • Libplanet.Net
    • ActionExecutionState
    • BlockDownloadState
    • BoundPeer
    • DifferentAppProtocolVersionException
    • DifferentProtocolVersionEventArgs
    • IceServer
    • IceServerException
    • InvalidMessageException
    • NoSwarmContextException
    • Peer
    • PeerNotFoundException
    • PeerState
    • PreloadBlockDownloadFailEventArgs
    • PreloadState
    • StateDownloadState
    • Swarm<T>
    • SwarmException
  • Libplanet.Net.Protocols
    • PeerDiscoveryException
  • Libplanet.Serialization
    • SerializationInfoExtension
  • Libplanet.Store
    • BaseIndex<TKey, TVal>
    • BaseStore
    • BlockSet<T>
    • ChainIdNotFoundException
    • DefaultStore
    • IStore
    • StoreExtension
    • TransactionSet<T>
  • Libplanet.Tx
    • InvalidTxException
    • InvalidTxIdException
    • InvalidTxNonceException
    • InvalidTxPublicKeyException
    • InvalidTxSignatureException
    • InvalidTxUpdatedAddressesException
    • Transaction<T>
    • TxId

Class ProtectedPrivateKey

Protects a PrivateKey with a passphrase (i.e., password).

Inheritance
Object
ProtectedPrivateKey
Namespace: Libplanet.KeyStore
Assembly: Libplanet.dll
Syntax
public sealed class ProtectedPrivateKey : object

Constructors

| Improve this Doc View Source

ProtectedPrivateKey(Address, IKdf, ImmutableArray<Byte>, ICipher, ImmutableArray<Byte>)

Loads a protected private key.

Declaration
public ProtectedPrivateKey(Address address, IKdf kdf, ImmutableArray<byte> mac, ICipher cipher, ImmutableArray<byte> ciphertext)
Parameters
Type Name Description
Address address

The address of the protected private key.

IKdf kdf

A key derivation function to derive a symmetric key to decrypt a PrivateKey.

ImmutableArray<Byte> mac

MAC digest to check if a derived key is correct or not.

ICipher cipher

A symmetric cipher to decrypt a PrivateKey.

ImmutableArray<Byte> ciphertext

An encrypted PrivateKey.

| Improve this Doc View Source

ProtectedPrivateKey(Address, IKdf, Byte[], ICipher, Byte[])

Loads a protected private key.

Declaration
public ProtectedPrivateKey(Address address, IKdf kdf, byte[] mac, ICipher cipher, byte[] ciphertext)
Parameters
Type Name Description
Address address

The address of the protected private key.

IKdf kdf

A key derivation function to derive a symmetric key to decrypt a PrivateKey.

Byte[] mac

MAC digest to check if a derived key is correct or not.

ICipher cipher

A symmetric cipher to decrypt a PrivateKey.

Byte[] ciphertext

An encrypted PrivateKey.

Properties

| Improve this Doc View Source

Address

The address of the protected private key.

Declaration
public Address Address { get; }
Property Value
Type Description
Address
| Improve this Doc View Source

Cipher

A symmetric cipher to decrypt a PrivateKey.

Declaration
public ICipher Cipher { get; }
Property Value
Type Description
ICipher
| Improve this Doc View Source

Ciphertext

An encrypted PrivateKey.

Declaration
public ImmutableArray<byte> Ciphertext { get; }
Property Value
Type Description
ImmutableArray<Byte>
| Improve this Doc View Source

Kdf

A key derivation function to derive a symmetric key to decrypt a PrivateKey.

Declaration
public IKdf Kdf { get; }
Property Value
Type Description
IKdf
| Improve this Doc View Source

Mac

Declaration
public ImmutableArray<byte> Mac { get; }
Property Value
Type Description
ImmutableArray<Byte>

Methods

| Improve this Doc View Source

FromJson(String)

Loads a ProtectedPrivateKey from a JSON, according to Ethereum's Web3 Secret Storage Definition.

Declaration
public static ProtectedPrivateKey FromJson(string json)
Parameters
Type Name Description
String json

A JSON string that encodes a ProtectedPrivateKey.

Returns
Type Description
ProtectedPrivateKey

A protected private key loaded from the given json.

Exceptions
Type Condition
InvalidKeyJsonException

Thrown when the given key data lacks some required fields or consists of wrong types.

UnsupportedKeyJsonException

Thrown when the given key data depends on an unsupported features (e.g., KDF).

| Improve this Doc View Source

Protect(PrivateKey, String)

Protects a bare PrivateKey using a user input passphrase.

Declaration
public static ProtectedPrivateKey Protect(PrivateKey privateKey, string passphrase)
Parameters
Type Name Description
PrivateKey privateKey

A bare private key to protect.

String passphrase

A user input passphrase (i.e., password).

Returns
Type Description
ProtectedPrivateKey

A passphrase-protected private key.

| Improve this Doc View Source

Unprotect(String)

Gets the protected PrivateKey using a user input passphrase.

Declaration
public PrivateKey Unprotect(string passphrase)
Parameters
Type Name Description
String passphrase

A user input passphrase (i.e., password).

Returns
Type Description
PrivateKey

A bare PrivateKey.

Exceptions
Type Condition
IncorrectPassphraseException

Thrown when the given passphrase does not match to the ProtectedPrivateKey's passphrase.

MismatchedAddressException

Thrown when the unprotected PrivateKey does not match to the expected Address.

| Improve this Doc View Source

WriteJson(Stream, Nullable<Guid>)

Dumps the cipher parameters as a JSON representation according to Ethereum's Web3 Secret Storage Definition.

Declaration
public void WriteJson(Stream stream, in Guid? id = null)
Parameters
Type Name Description
Stream stream

The destination for writing JSON text.

Nullable<Guid> id

A unique identifier, which goes to the id field in the key JSON file. If null (which is default) it is random-generated.

| Improve this Doc View Source

WriteJson(Utf8JsonWriter, Nullable<Guid>)

Dumps the cipher parameters as a JSON representation according to Ethereum's Web3 Secret Storage Definition.

Declaration
public void WriteJson(Utf8JsonWriter writer, in Guid? id = null)
Parameters
Type Name Description
Utf8JsonWriter writer

A JSON writer which has not begun object nor array.

Nullable<Guid> id

A unique identifier, which goes to the id field in the key JSON file. If null (which is default) it is random-generated.

  • Improve this Doc
  • View Source
Back to top Copyright © 2019–2020 Planetarium