Skip to content

Commit

Permalink
feat: wire up algorand addressing
Browse files Browse the repository at this point in the history
  • Loading branch information
robdefeo committed Feb 19, 2021
1 parent 62fd610 commit 0c04389
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/addressing/public_key.go
Expand Up @@ -17,6 +17,7 @@ package addressing
import (
"github.com/mailchain/mailchain/crypto"
"github.com/mailchain/mailchain/internal/protocols"
"github.com/mailchain/mailchain/internal/protocols/algorand"
"github.com/mailchain/mailchain/internal/protocols/ethereum"
"github.com/mailchain/mailchain/internal/protocols/substrate"
"github.com/pkg/errors"
Expand All @@ -25,6 +26,8 @@ import (
// FromPublicKey creates an address from public key.
func FromPublicKey(pubKey crypto.PublicKey, protocol, network string) (address []byte, err error) {
switch protocol {
case protocols.Algorand:
return algorand.Address(pubKey)
case protocols.Ethereum:
return ethereum.Address(pubKey)
case protocols.Substrate:
Expand Down
10 changes: 10 additions & 0 deletions internal/addressing/public_key_test.go
Expand Up @@ -36,6 +36,16 @@ func TestFromPublicKey(t *testing.T) {
wantAddress []byte
wantErr bool
}{
{
"algorand",
args{
ed25519test.SofiaPublicKey,
"algorand",
"mainnet",
},
[]byte{0x72, 0x3c, 0xaa, 0x23, 0xa5, 0xb5, 0x11, 0xaf, 0x5a, 0xd7, 0xb7, 0xef, 0x60, 0x76, 0xe4, 0x14, 0xab, 0x7e, 0x75, 0xa9, 0xdc, 0x91, 0xe, 0xa6, 0xe, 0x41, 0x7a, 0x2b, 0x77, 0xa, 0x56, 0x71, 0x64, 0xea, 0x58, 0x50},
false,
},
{
"ethereum",
args{
Expand Down

0 comments on commit 0c04389

Please sign in to comment.