本文整理匯總了Golang中github.com/FactomProject/factomd/common/interfaces.IState.VerifyAuthoritySignature方法的典型用法代碼示例。如果您正苦於以下問題:Golang IState.VerifyAuthoritySignature方法的具體用法?Golang IState.VerifyAuthoritySignature怎麽用?Golang IState.VerifyAuthoritySignature使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/FactomProject/factomd/common/interfaces.IState
的用法示例。
在下文中一共展示了IState.VerifyAuthoritySignature方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: UpdateState
func (e *ServerFault) UpdateState(state interfaces.IState) error {
core, err := e.MarshalCore()
if err != nil {
return err
}
verifiedSignatures := 0
for _, fullSig := range e.SignatureList.List {
sig := fullSig.GetSignature()
v, err := state.VerifyAuthoritySignature(core, sig, state.GetLeaderHeight())
if err != nil {
if err.Error() != "Signature Key Invalid or not Federated Server Key" {
return err
}
}
if v == 1 {
verifiedSignatures++
}
}
feds := state.GetFedServers(state.GetLeaderHeight())
//50% threshold
if verifiedSignatures <= len(feds)/2 {
return fmt.Errorf("Quorum not reached for ServerFault")
}
//TODO: do
/*
state.AddFedServer(e.DBHeight, e.IdentityChainID)
state.UpdateAuthorityFromABEntry(e)
*/
return nil
}
示例2: Validate
// Validate the message, given the state. Three possible results:
// < 0 -- Message is invalid. Discard
// 0 -- Cannot tell if message is Valid
// 1 -- Message is valid
func (m *Ack) Validate(state interfaces.IState) int {
if m.authvalid {
return 1
}
// Only new acks are valid. Of course, the VMIndex has to be valid too.
msg, err := state.GetMsg(m.VMIndex, int(m.DBHeight), int(m.Height))
if err != nil || msg != nil {
return -1
}
// Check signature
bytes, err := m.MarshalForSignature()
if err != nil {
//fmt.Println("Err is not nil on Ack sig check: ", err)
return -1
}
sig := m.Signature.GetSignature()
ackSigned, err := state.VerifyAuthoritySignature(bytes, sig, m.DBHeight)
//ackSigned, err := m.VerifySignature()
if err != nil {
//fmt.Println("Err is not nil on Ack sig check: ", err)
return -1
}
if ackSigned < 1 {
return -1
}
m.authvalid = true
return 1
}
示例3: SigTally
func (m *FullServerFault) SigTally(state interfaces.IState) int {
validSigCount := 0
// Check main signature
bytes, err := m.MarshalForSignature()
if err != nil {
return 0
}
sig := m.Signature.GetSignature()
sfSigned, err := state.VerifyAuthoritySignature(bytes, sig, m.DBHeight)
if err != nil {
return 0
}
if sfSigned < 1 {
return 0
}
cb, err := m.MarshalCore()
if err != nil {
return 0
}
for _, fedSig := range m.SignatureList.List {
check, err := state.VerifyAuthoritySignature(cb, fedSig.GetSignature(), m.DBHeight)
if err == nil && check == 1 {
validSigCount++
}
}
return validSigCount
}
示例4: Validate
func (m *ChangeServerKeyMsg) Validate(state interfaces.IState) int {
return 1
// Check to see if identity exists and is audit or fed server
if !state.VerifyIsAuthority(m.IdentityChainID) {
fmt.Println("ChangeServerKey Error. Server is not an authority")
return -1
}
// Should only be 20 bytes in the hash
if m.AdminBlockChange == constants.TYPE_ADD_BTC_ANCHOR_KEY {
for _, b := range m.Key.Bytes()[21:] {
if b != 0 {
fmt.Println("ChangeServerKey Error. Newkey is invalid length")
return -1
}
}
}
// Check signatures
bytes, err := m.MarshalForSignature()
if err != nil {
fmt.Println("ChangeServerKey Error: Err is not nil, err: ", err.Error())
return -1
}
if m.Signature == nil {
fmt.Println("ChangeServerKey Error: No signiture on ChangeServerKeyMessage")
return -1
}
sig := m.Signature.GetSignature()
authSigned, err := state.VerifyAuthoritySignature(bytes, sig, state.GetLeaderHeight())
//ackSigned, err := m.VerifySignature()
if err != nil {
fmt.Println("ChangeServerKey Error: Err is not nil, err: ", err.Error())
return -1
}
if authSigned < 1 {
fmt.Println("ChangeServerKey Error: Message not signed by an authority")
return -1
}
return 1
}