mirror of
https://github.com/QuilibriumNetwork/ceremonyclient.git
synced 2026-03-05 08:17:39 +08:00
also here
This commit is contained in:
parent
8f955523d3
commit
0106afa298
@ -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
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user