From 0c04389afe69447a09f19503c3b60623f8922e2e Mon Sep 17 00:00:00 2001 From: Rob De Feo Date: Fri, 19 Feb 2021 22:44:04 +0000 Subject: [PATCH] feat: wire up algorand addressing --- internal/addressing/public_key.go | 3 +++ internal/addressing/public_key_test.go | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/internal/addressing/public_key.go b/internal/addressing/public_key.go index 0a75cdec9..9fa856b20 100644 --- a/internal/addressing/public_key.go +++ b/internal/addressing/public_key.go @@ -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" @@ -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: diff --git a/internal/addressing/public_key_test.go b/internal/addressing/public_key_test.go index f8767de23..30f14fa41 100644 --- a/internal/addressing/public_key_test.go +++ b/internal/addressing/public_key_test.go @@ -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{