also here

This commit is contained in:
Cassandra Heart 2024-11-04 20:16:11 -06:00
parent 8f955523d3
commit 0106afa298
No known key found for this signature in database
GPG Key ID: 6352152859385958

View File

@ -13,6 +13,7 @@ import (
"github.com/iden3/go-iden3-crypto/poseidon"
pcrypto "github.com/libp2p/go-libp2p/core/crypto"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/pkg/errors"
"go.uber.org/zap"
"google.golang.org/protobuf/proto"
@ -807,10 +808,23 @@ func (e *TokenExecutionEngine) getAddressFromSignature(
if sig.PublicKey == nil || sig.PublicKey.KeyValue == nil {
return nil, errors.New("invalid data")
}
addrBI, err := poseidon.HashBytes(sig.PublicKey.KeyValue)
pk, err := pcrypto.UnmarshalEd448PublicKey(
sig.PublicKey.KeyValue,
)
if err != nil {
return nil, errors.Wrap(err, "get address from signature")
}
return addrBI.FillBytes(make([]byte, 32)), nil
peerId, err := peer.IDFromPublicKey(pk)
if err != nil {
return nil, errors.Wrap(err, "get address from signature")
}
altAddr, err := poseidon.HashBytes([]byte(peerId))
if err != nil {
return nil, errors.Wrap(err, "get address from signature")
}
return altAddr.FillBytes(make([]byte, 32)), nil
}