This repository has been archived by the owner on Nov 27, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: initial step for verifying messages * add mesage hash generation * message verification attempt * refactor: move message.ex to correct folder * feat: message verification * test: add message signing and verification test
- Loading branch information
1 parent
6d7a419
commit e4b82e7
Showing
3 changed files
with
23 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,6 @@ ark_elixir-*.tar | |
|
||
# Ignore package lock file | ||
mix.lock | ||
|
||
# Ignore osx .DS_Store | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
defmodule ArkEcosystem.Crypto.MessageTest do | ||
use ExUnit.Case, async: false | ||
alias ArkEcosystem.Crypto.Message | ||
|
||
test "should be able to sign a message" do | ||
signed = Message.sign("hello", "world") | ||
assert(signed[:message] == "hello") | ||
assert(signed[:publickey] == "039b101edcbe1ee37ff6b2318526a425b629e823d7d8d9154417880595a28000ee") | ||
assert(signed[:signature] == "3045022100ff2007e57064946fb80f4280dca2a9d312c8ec9a101f706700eae732947b65f302207a6a0fbd07d4084aba6dcd53d0c3ef531bd42d0281079323709ac2026420a8a7") | ||
end | ||
|
||
test "should be able to verify a message" do | ||
signed = Message.sign("hello", "world") | ||
assert(Message.verify(signed[:message], signed[:signature], signed[:publickey]) == true) | ||
# Change last character of signature, as verify should then return false | ||
assert(Message.verify(signed[:message], "3045022100ff2007e57064946fb80f4280dca2a9d312c8ec9a101f706700eae732947b65f302207a6a0fbd07d4084aba6dcd53d0c3ef531bd42d0281079323709ac2026420a8a2", signed[:publickey]) == false) | ||
end | ||
|
||
end |