Skip to content

Instantly share code, notes, and snippets.

@KardanovIR
Created May 13, 2020 15:26
Show Gist options
  • Save KardanovIR/4ffd63d0616e5c103cfb8e92c703a58e to your computer and use it in GitHub Desktop.
Save KardanovIR/4ffd63d0616e5c103cfb8e92c703a58e to your computer and use it in GitHub Desktop.
{-# STDLIB_VERSION 3 #-}
{-# CONTENT_TYPE EXPRESSION #-}
{-# SCRIPT_TYPE ACCOUNT #-}
# array of 5 public keys
let pks = [base58'', base58'', base58'', base58'', base58'']
# inner fold step for each signature
func signedBy(pk:ByteVector) = {
# is signed by the public key or not
func f(acc: Boolean, sig: ByteVector)
= acc || sigVerify(tx.bodyBytes, sig, pk)
FOLD<8>(tx.proofs, false, f)
}
# outer fold step for each public key
func signedFoldStep(acc:Int, pk:ByteVector)
= acc + (if(signedBy(pk)) then 1 else 0)
# comparing total number of correct signatures
# to required number of correct signatures
FOLD<5>(pks, 0, signedFoldStep) >= 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment