conversion

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToHashString

func BytesToHashString(msg []byte) (string, error)

func CheckKeyOnCurve

func CheckKeyOnCurve(pkData []byte) (bool, error)

CheckKeyOnCurve check if a SECP256K1 public key is on the elliptic curve

func CheckUnicast

func CheckUnicast(round RoundInfo) bool

due to the nature of tss, we may find the invalid share of the previous round only when we get the shares from the peers in the current round. So, when we identify an error in this round, we check whether the previous round is the unicast

func GenerateSignature

func GenerateSignature(msg []byte, msgID string, privKey crypto.PrivKey) ([]byte, error)

func GetBroadcastMessageType

func GetBroadcastMessageType(msgType message.TssMsgType) message.TssMsgType

GetBroadcastMessageType gets the broadcast message type of the message

func GetECDSAPubKeyFromPubKeyData

func GetECDSAPubKeyFromPubKeyData(pkData []byte) (*ecdsa.PublicKey, error)

pkData -> ecdsa.PublicKey

func GetPIDFromPartyID

func GetPIDFromPartyID(partyID *btss.PartyID) (peer.ID, error)

partyID -> pid

func GetPIDFromPubKey

func GetPIDFromPubKey(pk crypto.PubKey) (peer.ID, error)

pubkey -> peer.ID

func GetPIDFromPubKeyData

func GetPIDFromPubKeyData(pk []byte) (peer.ID, error)

pkData -> peer.ID

func GetPIDsFromPubKeys

func GetPIDsFromPubKeys(pks [][]byte) ([]peer.ID, error)

[]pkData -> []peer.ID

func GetParties

func GetParties(keys []crypto.PubKey, localPK crypto.PubKey, peerMap map[string]*peer.AddrInfo) ([]*btss.PartyID, *btss.PartyID, error)

GetParties get parties and localParty according the parties pubkey and peersInfo. PeersInfo is needed to match the partyid.id with the serial number ID of the P2P Peer. []pubkeys, pubkey, peersInfo -> []partyIDs, partyID

func GetPatyIDInfoMap

func GetPatyIDInfoMap(partiesID []*btss.PartyID) (map[string]*btss.PartyID, error)

[]partyIDs -> map[partyID.id][partyID]

func GetPreviousKeySignUicast

func GetPreviousKeySignUicast(current string) string

GetPreviousKeySignUicast eets the last unicast message for the current message

func GetPubKeyDataFromPartyID

func GetPubKeyDataFromPartyID(partyID *btss.PartyID) ([]byte, error)

partyID -> pubkeyData

func GetPubKeyDatasFromPartyIDs

func GetPubKeyDatasFromPartyIDs(partyIDs []*btss.PartyID) ([][]byte, error)

[]partyID -> []pubkeyData

func GetPubKeyDatasMapFromPartyIDs

func GetPubKeyDatasMapFromPartyIDs(partyIDs []*btss.PartyID) (map[string][]byte, error)

[]partyID -> map[partyID.id][pubkeyData]

func GetPubKeyFromPartyID

func GetPubKeyFromPartyID(partyID *btss.PartyID) (crypto.PubKey, error)

partyID -> pubkey

func GetPubKeyFromPubKeyData

func GetPubKeyFromPubKeyData(pk []byte) (crypto.PubKey, error)

pkData -> pubkey

func GetPubKeyInfoFromECDSAPubkey

func GetPubKeyInfoFromECDSAPubkey(ecdsaPk *ecdsa.PublicKey) (string, []byte, error)

ecdsa.PublicKey -> addr, byte

func GetPubKeysFromPartyIDs

func GetPubKeysFromPartyIDs(partyIDs []*btss.PartyID) ([]crypto.PubKey, error)

[]partyID -> []pubkey

func GetPubKeysFromPubKeyDatas

func GetPubKeysFromPubKeyDatas(pksData [][]byte) ([]crypto.PubKey, error)

[]pkData -> []pubkey

func GetTssPubKey

func GetTssPubKey(pubKeyPoint *bcrypto.ECPoint) (*ecdsa.PublicKey, error)

ECPoint -> ecdsa.PublicKey

func MsgToHashInt

func MsgToHashInt(msg []byte) (*big.Int, error)

func MsgToHashString

func MsgToHashString(msg []byte) (string, error)

func SortPubKey

func SortPubKey(keys []crypto.PubKey)

func VerifySignature

func VerifySignature(pubKey crypto.PubKey, message, sig []byte, msgID string) (bool, error)

Types

type PartyInfo

type PartyInfo struct {
	// Message identifier -> localParty of the message
	// - only one in keygen
	// - maybe some in keysign. Each message to be signed corresponds to a corresponding current participant
	PartyMap *sync.Map
	// partyID.id -> partyID
	PartyIDMap map[string]*btss.PartyID
}

PartyInfo the information used by tss key gen and key sign

type RoundInfo

type RoundInfo struct {
	Index         int
	RoundMsg      string
	MsgIdentifier string
}

func GetMsgRound

func GetMsgRound(msg []byte, partyID *btss.PartyID, isBroadcast bool) (RoundInfo, error)

type Signature

type Signature struct {
	Msg         string `json:"signed_msg"`
	R           string `json:"r"`
	S           string `json:"s"`
	RecoveryID  string `json:"recovery_id"`
	SignEthData []byte `json:"sign_eth_data"`
}

func BatchSignatures

func BatchSignatures(sigs []*bcommon.SignatureData, msgsToSign [][]byte) []Signature

BatchSignatures package the signature list and message list as message signature list

func NewSignature

func NewSignature(msg, r, s, recoveryID string, data []byte) Signature

type Status

type Status byte
const (
	NA Status = iota
	Success
	Fail
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL