chloride.sign

Members

Aliases

makeSigningSeed
alias makeSigningSeed = randomArray!SigningSeed

Generate a seed that can be used to generate key pairs with makeSigningKeys.

Functions

makeSigningKeys
SigningKeys makeSigningKeys()

Generate a new random key pair suitable for public key signatures.

makeSigningKeys
SigningKeys makeSigningKeys(in SigningSeed seed)

Generate a key pair from a seed.

messageSignature
ubyte[SignatureLength] messageSignature(in ubyte[] message, in SignPrivateKey key)

Compute a signature for a message using a private key. Unlike signMessage this does not include the original message.

openSignedMessage
ubyte[] openSignedMessage(in ubyte[] signed, in SignPublicKey key)

Verify a signed message using the public key corresponding to the private key used to sign it. If verification succeeds return the message (without the signature), otherwise return null.

signMessage
ubyte[] signMessage(in ubyte[] message, in SignPrivateKey key)

Sign a message using a private key by prepending a signature to the message.

verifySignature
bool verifySignature(in ubyte[] message, in ubyte[SignatureLength] signature, in SignPublicKey key)

Verify a signed message using the public key corresponding to the private key used to sign it. Returns true on success and false on failure. This method is passed the message and signature separately.

Examples

1 import std.string : representation;
2 immutable ubyte[] message = representation("hello");
3 auto keys = makeSigningKeys();
4 auto signed = signMessage(message, keys.privateKey);
5 assert(openSignedMessage(signed, keys.publicKey) == message);
1 import std.string : representation;
2 immutable ubyte[] message = representation("hello");
3 auto keys = makeSigningKeys();
4 auto sig = messageSignature(message, keys.privateKey);
5 assert(verifySignature(message, sig, keys.publicKey));

Meta