func (m *RemoveServerMsg) Validate(state interfaces.IState) int { // Check to see if identity exists and is audit or fed server if !state.VerifyIsAuthority(m.ServerChainID) { //fmt.Printf("RemoveServerMsg Error: [%s] is not a server, cannot be removed\n", m.ServerChainID.String()[:8]) return -1 } // TODO: Check valid signatures return 1 }
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 }