Class PrivateKey
A secret part of a key pair involved in
ECDSA, the digital
signature algorithm on which the Libplanet is based. It can be used to
create signatures, which can be verified with the corresponding
Public
Note that it uses secp256k1 as the parameters of the elliptic curve, which is the same to Bitcoin and Ethereum. It means private 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 PrivateKey
Remarks
These (and any derived representations, e.g., Byte
Every Private
Constructors
| Improve this Doc View SourcePrivateKey()
Generates a new unique Private
Declaration
public PrivateKey()
PrivateKey(Byte[])
Creates a PrivateprivateKey
),
which encodes a valid
ECDSA private key.
Declaration
public PrivateKey(byte[] privateKey)
Parameters
Remarks
A valid Byte array for
a Private
See Also
Properties
| Improve this Doc View SourceByteArray
A Byte array encoding of this private key.
Declaration
[Pure]
public byte[] ByteArray { get; }
Property Value
Type | Description |
---|---|
Byte[] |
Remarks
An encoded Byte array representation can recover
a Private
As like Private
See Also
| Improve this Doc View SourcePublicKey
The corresponding Public
Declaration
[Pure]
[IgnoreDuringEquals]
public PublicKey PublicKey { get; }
Property Value
Type | Description |
---|---|
Public |
Methods
| Improve this Doc View SourceDecrypt(Byte[])
Converts a ciphertext
which was encrypted with
the corresponding Public
Declaration
[Pure]
public byte[] Decrypt(byte[] ciphertext)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | ciphertext | The encrypted data. |
Returns
Type | Description |
---|---|
Byte[] | The plain data the |
Remarks
Although the parameter name ciphertext
has the
word “text”, both a ciphertext
and a returned message are a Byte string,
not a Unicode String.
Exceptions
Type | Condition |
---|---|
Invalid |
Thrown when the given
|
See Also
| Improve this Doc View SourceExchangeKey(PublicKey)
Securely exchange a Symmetric
Technically it is ECDH, a Diffie–Hellman key exchange of elliptic-curve version.
Declaration
[Pure]
public SymmetricKey ExchangeKey(PublicKey publicKey)
Parameters
Type | Name | Description |
---|---|---|
Public |
publicKey | The Public |
Returns
Type | Description |
---|---|
Symmetric |
An exchanged (agreed) Symmetric |
Sign(Byte[])
Creates a signature from the given message
.
A created signature can be verified by the corresponding
Public
Signatures can be created by only the Private
To sum up, a signature is used to guarantee:
- that the
message
was created by someone possessing the corresponding PrivateKey , - that the possessor cannot deny having sent the
message
, and - that the
message
was not forged in the middle of transit.
Declaration
public byte[] Sign(byte[] message)
Parameters
Returns
Type | Description |
---|---|
Byte[] | A signature that verifies the |