Function decryptPayload
Decrypt an encrypted payload with the shared secret generated from the ephemeral public key and the target node's private key.
bool decryptPayload
(
in ref const(EncryptedPayload) encrypted,
in ref const(agora .crypto .ECC .Scalar) our_key,
in ref const(agora .crypto .ECC .Point) ephemeral_pk,
out Payload payload,
out agora .crypto .ECC .Point shared_secret
);
bool decryptPayload
(
in ref const(EncryptedPayload) encrypted,
in ref const(agora .crypto .ECC .Scalar) our_key,
in ref const(agora .crypto .ECC .Point) ephemeral_pk,
out Payload payload
);
Parameters
Name | Description |
---|---|
encrypted | the encrypted payload |
our_key | the target node's private key |
ephemeral_pk | the ephemeral public key |
payload | on success will contain the decrypted payload |
shared_secret | secret used to decrypt the payload |
Returns
true if decryption and deserialization succeeded
Example
Payload payload =
{
next_chan_id : hashFull(42),
forward_amount : Amount(123),
};
Pair ephemeral_kp = Pair .random();
Pair bob_kp = Pair .random();
EncryptedPayload encrypted = encryptPayload(payload, ephemeral_kp, bob_kp .V);
Payload decrypted;
assert(decryptPayload(encrypted, bob_kp .v, ephemeral_kp .V, decrypted));
assert(decrypted == payload);