Function seal [src]
Encrypt a message m for a recipient whose public key is public_key.
c must be seal_length bytes larger than m, so that the required metadata can be added.
Prototype
pub fn seal(c: []u8, m: []const u8, public_key: [public_length]u8) (WeakPublicKeyError || IdentityElementError)!void
Parameters
c: []u8
m: []const u8
public_key: [public_length]u8
Source
pub fn seal(c: []u8, m: []const u8, public_key: [public_length]u8) (WeakPublicKeyError || IdentityElementError)!void {
debug.assert(c.len == m.len + seal_length);
var ekp = KeyPair.generate();
const nonce = createNonce(ekp.public_key, public_key);
c[0..public_length].* = ekp.public_key;
try Box.seal(c[Box.public_length..], m, nonce, public_key, ekp.secret_key);
crypto.secureZero(u8, ekp.secret_key[0..]);
}