• 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<T>
    • ActionTypeAttribute
    • AddressStateMap
    • IAccountStateDelta
    • IAction
    • IActionContext
    • IRandom
    • MissingActionTypeException
    • PolymorphicAction<T>
  • Libplanet.Blockchain
    • BlockChain<T>
    • IncompleteBlockStatesException
    • MineBlockEventArgs<T>
  • Libplanet.Blockchain.Policies
    • BlockPolicy<T>
    • BlockPolicyExtension
    • IBlockPolicy<T>
  • Libplanet.Blocks
    • Block<T>
    • InvalidBlockDifficultyException
    • InvalidBlockException
    • InvalidBlockHashException
    • InvalidBlockIndexException
    • InvalidBlockNonceException
    • InvalidBlockPreviousHashException
    • InvalidBlockTimestampException
  • Libplanet.Crypto
    • InvalidCiphertextException
    • PrivateKey
    • PublicKey
    • SymmetricKey
  • Libplanet.Net
    • BlockDownloadState
    • DifferentAppProtocolVersionException
    • DifferentProtocolVersionEventArgs
    • IceServer
    • IceServerException
    • InvalidMessageException
    • NoSwarmContextException
    • Peer
    • PeerNotFoundException
    • PeerSetDelta
    • Swarm<T>
    • SwarmException
  • Libplanet.Serialization
    • BencodexFormatter<T>
    • SerializationInfoExtension
  • Libplanet.Store
    • BaseIndex<TKey, TVal>
    • BaseStore
    • BlockSet<T>
    • FileStore
    • IStore
    • LiteDBStore
    • NamespaceNotFoundException
    • StoreExtension
    • TransactionSet<T>
  • Libplanet.Tx
    • InvalidTxException
    • InvalidTxIdException
    • InvalidTxNonceException
    • InvalidTxPublicKeyException
    • InvalidTxSignatureException
    • InvalidTxUpdatedAddressesException
    • Transaction<T>
    • TxId
    • UnexpectedlyTerminatedTxRehearsalException

Class PublicKey

A public part of a key pair involved in ECDSA, the digital signature algorithm on which the Libplanet is based. It can be used to verify signatures created with the corresponding PrivateKey and to encrypt messages for someone possessing the corresponding PrivateKey. This can be distributed publicly, hence the name.

Note that it uses secp256k1 as the parameters of the elliptic curve, which is same to Bitcoin and Ethereum. It means public keys generated for Bitcoin/Ethereum can be used by Libplanet-backed games/apps too.

Inheritance
Object
PublicKey
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: Libplanet.Crypto
Assembly: Libplanet.dll
Syntax
[Equals]
public class PublicKey
Remarks

Every PublicKey object is immutable.

Constructors

| Improve this Doc View Source

PublicKey(Byte[])

Creates a PublicKey instance from the given Byte array (i.e., publicKey), which encodes a valid ECDSA public key.

Declaration
public PublicKey(byte[] publicKey)
Parameters
Type Name Description
Byte[] publicKey

A valid Byte array that encodes an ECDSA public key. It can be either compressed or not.

Remarks

A valid Byte array for a PublicKey can be encoded using Format(Boolean) method.

See Also
Format(Boolean)

Methods

| Improve this Doc View Source

Encrypt(Byte[])

Converts a plain message to a ciphertext which can be decrypted with the corresponding PrivateKey.

Declaration
public byte[] Encrypt(byte[] message)
Parameters
Type Name Description
Byte[] message

A binary data to be encrypted.

Returns
Type Description
Byte[]

A ciphertext that was encrypted from the message and can be decrypted with the corresponding PrivateKey. (Although the word “ciphertext” has the word “text”, a returned ciphertext is not a Unicode String, but a Byte array.)

See Also
Decrypt(Byte[])
| Improve this Doc View Source

Format(Boolean)

Encodes this public key into a Byte array representation.

Declaration
[Pure]
public byte[] Format(bool compress)
Parameters
Type Name Description
Boolean compress

Returns a short length representation if it is true. This option does not lose any information.

Returns
Type Description
Byte[]

An encoded Byte array representation. It can recover a PublicKey object again using its constructor (i.e., PublicKey(Byte[])) regardless of compression.

See Also
PublicKey(Byte[])
| Improve this Doc View Source

Verify(Byte[], Byte[])

Verifies whether a signature was created from a message with the corresponding PrivateKey.

Declaration
[Pure]
public bool Verify(byte[] message, byte[] signature)
Parameters
Type Name Description
Byte[] message

A plain message that the signature was created from. That is, a data which was passed as an argument to Sign(Byte[]).

Byte[] signature

A signature that was created from the message. That is, a data which was returned by Sign(Byte[]).

Returns
Type Description
Boolean

true if the signature was created from the message with the corresponding PrivateKey. Otherwise false.

Extension Methods

AddressExtension.ToAddress(PublicKey)

See Also

PrivateKey
Address
  • Improve this Doc
  • View Source
Back to top Copyright © 2019 Planetarium
Generated by DocFX