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.
Namespace: Libplanet.Crypto
Assembly: Libplanet.dll
Syntax
public class PublicKey : object
Remarks
Every PublicKey object is immutable.
Constructors
| Improve this Doc View SourcePublicKey(Byte[])
Creates a PublicKey instance from the given
publicKey
),
which encodes a valid
ECDSA public key.
Declaration
public PublicKey(byte[] publicKey)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | publicKey | A valid |
Remarks
A valid
See Also
Methods
| Improve this Doc View SourceEncrypt(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 |
See Also
| Improve this Doc View SourceFormat(Boolean)
Encodes this public key into a
Declaration
public byte[] Format(bool compress)
Parameters
Type | Name | Description |
---|---|---|
Boolean | compress | Returns a short length representation if
it is |
Returns
Type | Description |
---|---|
Byte[] | An encoded |
See Also
| Improve this Doc View SourceVerify(Byte[], Byte[])
Verifies whether a signature
was created from
a message
with the corresponding
PrivateKey.
Declaration
public bool Verify(byte[] message, byte[] signature)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | message | A plain message that the
|
Byte[] | signature | A signature that was created from the
|
Returns
Type | Description |
---|---|
Boolean |
|
Operators
| Improve this Doc View SourceEquality(PublicKey, PublicKey)
Declaration
public static bool operator ==(PublicKey left, PublicKey right)
Parameters
Type | Name | Description |
---|---|---|
PublicKey | left | |
PublicKey | right |
Returns
Type | Description |
---|---|
Boolean |
Inequality(PublicKey, PublicKey)
Declaration
public static bool operator !=(PublicKey left, PublicKey right)
Parameters
Type | Name | Description |
---|---|---|
PublicKey | left | |
PublicKey | right |
Returns
Type | Description |
---|---|
Boolean |