aboutsummaryrefslogblamecommitdiffstats
path: root/bls_smpl.py
blob: f834d80aa43d7b23f28e2b91497bb99e93055a2e (plain) (tree)






















                                                                         
                                           








                          

                                                        




                          
import os, sys, subprocess

EXE='bin/bls_smpl.exe'

def init():
    subprocess.check_call([EXE, "init"])

def sign(m, i=0):
    subprocess.check_call([EXE, "sign", "-m", m, "-id", str(i)])

def verify(m, i=0):
    subprocess.check_call([EXE, "verify", "-m", m, "-id", str(i)])

def share(n, k):
    subprocess.check_call([EXE, "share", "-n", str(n), "-k", str(k)])

def recover(ids):
    cmd = [EXE, "recover", "-ids"]
    for i in ids:
        cmd.append(str(i))
    subprocess.check_call(cmd)

def main():
    m = "hello bls threshold signature"
    n = 10
    ids = [1, 5, 3, 7]
    k = len(ids)
    init()
    sign(m)
    verify(m)
    share(n, k)
    for i in ids:
        sign(m, i)
        verify(m, i)
    subprocess.check_call(["rm", "sample/sign.txt"])
    recover(ids)
    verify(m)

if __name__ == '__main__':
    main()