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
Namespace: Libplanet.Crypto
Assembly: Libplanet.Crypto.dll
Syntax
public class PublicKey : IEquatable<PublicKey>
Remarks
Every PublicKey object is immutable.
Constructors
| Improve this Doc View SourcePublicKey(IReadOnlyList<Byte>)
Creates a PublicKey instance from the given
publicKey
),
which encodes a valid
ECDSA public key.
Declaration
public PublicKey(IReadOnlyList<byte> publicKey)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyList<System.Byte> | publicKey | A valid |
Remarks
A valid
See Also
Properties
| Improve this Doc View SourceAddress
Declaration
public Address Address { get; }
Property Value
Type | Description |
---|---|
Address |
Remarks
Every PublicKey object is immutable.
See Also
Methods
| Improve this Doc View SourceEncrypt(ImmutableArray<Byte>)
Encrypts a plaintext message
to a ciphertext, which can be decrypted
with the corresponding PrivateKey.
Declaration
public ImmutableArray<byte> Encrypt(ImmutableArray<byte> message)
Parameters
Type | Name | Description |
---|---|---|
ImmutableArray<System.Byte> | message | A binary data to encrypt. |
Returns
Type | Description |
---|---|
ImmutableArray<System.Byte> | A ciphertext that was encrypted from the original |
Remarks
Although the word “ciphertext” has the word “text”,
a returned ciphertext is not a Unicode
See Also
| Improve this Doc View SourceEncrypt(Byte[])
Encrypts a plaintext message
to a ciphertext, which can be decrypted
with the corresponding PrivateKey.
Declaration
public byte[] Encrypt(byte[] message)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | message | A binary data to encrypt. |
Returns
Type | Description |
---|---|
System.Byte[] | A ciphertext that was encrypted from the original |
Remarks
Although the word “ciphertext” has the word “text”,
a returned ciphertext is not a Unicode
See Also
| Improve this Doc View SourceEquals(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.
Declaration
public bool Equals(PublicKey other)
Parameters
Type | Name | Description |
---|---|---|
PublicKey | other |
Returns
Type | Description |
---|---|
System.Boolean |
Remarks
Every PublicKey object is immutable.
See Also
| Improve this Doc View SourceEquals(Nullable<Object>)
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.
Declaration
public override bool Equals(object? obj)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.Object> | obj |
Returns
Type | Description |
---|---|
System.Boolean |
Remarks
Every PublicKey object is immutable.
See Also
| Improve this Doc View SourceFormat(Boolean)
Encodes this public key into a mutable
To get an immutable one, use ToImmutableArray(Boolean) method instead.
Declaration
public byte[] Format(bool compress)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | compress | Returns a short length representation if it is true. This option does not lose any information. |
Returns
Type | Description |
---|---|
System.Byte[] | An encoded mutable |
Remarks
Every PublicKey object is immutable.
See Also
| Improve this Doc View SourceFromHex(String)
Creates a PublicKey instance from its hexadecimal representation.
Declaration
public static PublicKey FromHex(string hex)
Parameters
Type | Name | Description |
---|---|---|
System.String | hex | The hexadecimal representation of the public key to load. Case insensitive, and accepts either compressed or uncompressed. |
Returns
Type | Description |
---|---|
PublicKey | The parsed PublicKey. |
Remarks
Every PublicKey object is immutable.
See Also
| Improve this Doc View SourceGetHashCode()
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.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 |
Remarks
Every PublicKey object is immutable.
See Also
| Improve this Doc View SourceToHex(Boolean)
Gets the public key's hexadecimal representation in compressed form.
Declaration
public string ToHex(bool compress)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | compress | Returns a short length representation if it is true. This option does not lose any information. |
Returns
Type | Description |
---|---|
System.String | The hexadecimal string of the public key's compressed bytes. |
Remarks
Every PublicKey object is immutable.
See Also
| Improve this Doc View SourceToImmutableArray(Boolean)
Encodes this public key into a immutable
To get an mutable one, use Format(Boolean) method instead.
Declaration
public ImmutableArray<byte> ToImmutableArray(bool compress)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | compress | Returns a short length representation if it is true. This option does not lose any information. |
Returns
Type | Description |
---|---|
ImmutableArray<System.Byte> | An encoded immutable |
Remarks
Every PublicKey object is immutable.
See Also
| Improve this Doc View SourceToString()
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.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String |
Remarks
Every PublicKey object is immutable.
See Also
| Improve this Doc View SourceVerify(IReadOnlyList<Byte>, IReadOnlyList<Byte>)
Verifies whether a signature
proves authenticity of
message
with the corresponding PrivateKey.
Declaration
public bool Verify(IReadOnlyList<byte> message, IReadOnlyList<byte> signature)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyList<System.Byte> | message | A original plaintext message that the |
IReadOnlyList<System.Byte> | signature | A signature which tries to authenticity of
|
Returns
Type | Description |
---|---|
System.Boolean | true if the |
Remarks
Every PublicKey object is immutable.
See Also
Operators
| Improve this Doc View SourceEquality(PublicKey, 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.
Declaration
public static bool operator ==(PublicKey left, PublicKey right)
Parameters
Type | Name | Description |
---|---|---|
PublicKey | left | |
PublicKey | right |
Returns
Type | Description |
---|---|
System.Boolean |
Remarks
Every PublicKey object is immutable.
See Also
| Improve this Doc View SourceInequality(PublicKey, 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.
Declaration
public static bool operator !=(PublicKey left, PublicKey right)
Parameters
Type | Name | Description |
---|---|---|
PublicKey | left | |
PublicKey | right |
Returns
Type | Description |
---|---|
System.Boolean |
Remarks
Every PublicKey object is immutable.