Files
tss-lib/tss/wire.go
cong 9d8889d446 Internal mobile wrapper eddsa (#124)
* [R4R] Add eddsa (#88)

* [R4R] Add eddsa keygen and signing (#3)

* add eddsa signing and keygen

* contruct extended element from x,y

* update dep

* fix test

* fix bug

* delete unused code

* add resharing

* fix comments

* refactor RejectionSampl;e

* rename variable (#4)

* delete printf

* update dependency

* resolve conflict

* Update readme about EdDSA (#91)

* update readme about eddsa

* minor fix

* S in eddsa signature is not encoded correctly

* fix msg in eddsa hasn't to be a int.

* fix unit test

* register DGRound4Message for eddsa resharing (#99)

Co-authored-by: yutianwu <wzxingbupt@gmail.com>
Co-authored-by: dylenfu <dylenfu@126.com>
2020-12-08 16:50:06 +08:00

48 lines
1.4 KiB
Go

// Copyright © 2019 Binance
//
// This file is part of Binance. The full Binance copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.
package tss
import (
"errors"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes"
"github.com/golang/protobuf/ptypes/any"
)
const (
ECDSAProtoNamePrefix = "binance.tss-lib.ecdsa."
EDDSAProtoNamePrefix = "binance.tss-lib.eddsa."
)
// Used externally to update a LocalParty with a valid ParsedMessage
func ParseWireMessage(wireBytes []byte, from *PartyID, isBroadcast bool) (ParsedMessage, error) {
wire := new(MessageWrapper)
wire.Message = new(any.Any)
wire.From = from.MessageWrapper_PartyID
wire.IsBroadcast = isBroadcast
if err := proto.Unmarshal(wireBytes, wire.Message); err != nil {
return nil, err
}
return parseWrappedMessage(wire, from)
}
func parseWrappedMessage(wire *MessageWrapper, from *PartyID) (ParsedMessage, error) {
var any ptypes.DynamicAny
meta := MessageRouting{
From: from,
IsBroadcast: wire.IsBroadcast,
}
if err := ptypes.UnmarshalAny(wire.Message, &any); err != nil {
return nil, err
}
if content, ok := any.Message.(MessageContent); ok {
return NewMessage(meta, content, wire), nil
}
return nil, errors.New("ParseWireMessage: the message contained unknown content")
}