Module agora.crypto.Key
Holds primitive types for key operations
Example
Simple signature example
import std .string : representation;
KeyPair kp = KeyPair .random();
Signature sign = kp .secret .sign("Hello World" .representation);
assert(kp .address .verify(sign, "Hello World" .representation));
// Message can't be changed
assert(!kp .address .verify(sign, "Hello World?" .representation));
// Another keypair won't verify it
KeyPair other = KeyPair .random();
assert(!other .address .verify(sign, "Hello World" .representation));
// Signature can't be changed
Signature sign2 = kp .secret .sign("Hello" .representation);
assert(!kp .address .verify(sign2, "Hello World" .representation));
Structs
Name | Description |
---|---|
KeyPair
|
A structure to hold a secret key + public key + seed
Can be constructed from a seed
To construct addresses (PublicKey), see fromString
|
PublicKey
|
Represent a public key / address |
SecretKey
|
A secret key. Since we mostly expose seed and public key to the user, this does not expose any Stellar serialization shenanigans. |
Enums
Name | Description |
---|---|
VersionByte
|
Discriminant for Stellar binary-encoded user-facing data |