diff --git a/pkg/smartcontract/contract.go b/pkg/smartcontract/contract.go index 0de8ade41..e413c7c07 100644 --- a/pkg/smartcontract/contract.go +++ b/pkg/smartcontract/contract.go @@ -41,7 +41,7 @@ func CreateMultiSigRedeemScript(m int, publicKeys keys.PublicKeys) ([]byte, erro // using publicKeys length with the default BFT assumptions of (n - (n-1)/3) for m. func CreateDefaultMultiSigRedeemScript(publicKeys keys.PublicKeys) ([]byte, error) { n := len(publicKeys) - m := n - (n-1)/3 + m := GetDefaultHonestNodeCount(n) return CreateMultiSigRedeemScript(m, publicKeys) } @@ -52,3 +52,9 @@ func CreateMajorityMultiSigRedeemScript(publicKeys keys.PublicKeys) ([]byte, err m := n - (n-1)/2 return CreateMultiSigRedeemScript(m, publicKeys) } + +// GetDefaultHonestNodeCount returns minimum number of honest nodes +// required for network of size n. +func GetDefaultHonestNodeCount(n int) int { + return n - (n-1)/3 +}