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.
Inherited Members
Namespace: Libplanet.Crypto
Assembly: Libplanet.dll
Syntax
[Equals]
public class PublicKey
Remarks
Every PublicKey object is immutable.
Constructors
| Improve this Doc View SourcePublicKey(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
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 Byte array representation.
Declaration
[Pure]
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 Byte array representation. It can recover a PublicKey object again using its constructor (i.e., PublicKey(Byte[])) regardless of compression. |
See Also
| Improve this Doc View SourceVerify(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
|
Byte[] | signature | A signature that was created from the
|
Returns
Type | Description |
---|---|
Boolean |
|