Skip to content

Commit

Permalink
chore(zencode_ecdh): avoid code duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
matteo-cristino authored and jaromil committed Jul 17, 2024
1 parent 73e167a commit c07967c
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/lua/zencode_ecdh.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,20 @@ When("create ecdh public key",function()
new_codec('ecdh public key')
end
)
When("create ecdh key with secret key ''",function(sec)
local sk = have(sec)
initkeyring'ecdh'
ECDH.pubgen(sk)
ACK.keyring.ecdh = sk
end)
When("create ecdh key with secret ''",function(sec)
local sk = have(sec)

local function _ecdh_key_from_secret(sec)
local sk = have(sec)
initkeyring'ecdh'
ECDH.pubgen(sk)
ACK.keyring.ecdh = sk
end)
end

When("create ecdh key with secret key ''",
_ecdh_key_from_secret
)
When("create ecdh key with secret ''",
_ecdh_key_from_secret
)

-- encrypt with a header and secret
When("encrypt secret message '' with ''",function(msg, sec)
Expand Down

0 comments on commit c07967c

Please sign in to comment.