Beispiel #1
0
def GenSchnorr(hash_prefix, pub, sec, k): 
    #modified from original algorithm to match Monero better
    #see the ag schnorr pdf for original alg.
    #Note in Monero, hash prefix is always 32 bytes..
    #hash_prefix = binascii.hexlify(prefix) 
    #k = PaperWallet.skGen() #comment for testing
    comm = MiniNero.scalarmultBase(k)
    print("comm", "hash_prefix", comm, hash_prefix)
    if MiniNero.scalarmultBase(sec) != pub:
        print"error in genSchnorr"
        return -1
    if MiniNero.sc_check(sec) == False:
        print "fail in geSchnorr"
        return -1
    c = MiniNero.sc_reduce_key(MiniNero.cn_fast_hash(hash_prefix + pub + comm))
    r = MiniNero.sc_sub_keys(k, MiniNero.sc_mul_keys(c, sec))
    #uncomment to test malleability
    c = MiniNero.sc_reduce_key(MiniNero.cn_fast_hash(hash_prefix + pub + comm))
    r = MiniNero.sc_unreduce_key(MiniNero.sc_sub_keys(k, MiniNero.sc_mul_keys(c, sec)))

    return r, c
Beispiel #2
0
def GenSchnorr(hash_prefix, pub, sec, k):
    #modified from original algorithm to match ByteRub better
    #see the ag schnorr pdf for original alg.
    #Note in ByteRub, hash prefix is always 32 bytes..
    #hash_prefix = binascii.hexlify(prefix)
    #k = PaperWallet.skGen() #comment for testing
    comm = MiniNero.scalarmultBase(k)
    print("comm", "hash_prefix", comm, hash_prefix)
    if MiniNero.scalarmultBase(sec) != pub:
        print "error in genSchnorr"
        return -1
    if MiniNero.sc_check(sec) == False:
        print "fail in geSchnorr"
        return -1
    c = MiniNero.sc_reduce_key(MiniNero.cn_fast_hash(hash_prefix + pub + comm))
    r = MiniNero.sc_sub_keys(k, MiniNero.sc_mul_keys(c, sec))
    #uncomment to test malleability
    c = MiniNero.sc_reduce_key(MiniNero.cn_fast_hash(hash_prefix + pub + comm))
    r = MiniNero.sc_unreduce_key(
        MiniNero.sc_sub_keys(k, MiniNero.sc_mul_keys(c, sec)))

    return r, c