Git Product home page Git Product logo

pysig's Introduction

PySig

signature shemes in python

  • pure python without any external dependencies
  • just copy and paste; no license; no installation
  • simple implementation for understanding not for performance

SPHINCS+

n = 16
algo = "shake"
robust = True
k = 14; a = 12
w = 4; h = 9; d = 7
pp = (n, algo, robust, k, a, w, h, d)

assert w in [4, 8]
    
secret_seed = b"\xaa"*n
public_seed = b"\xcc"*n

public_root = SPHINCS_GeneratePulicKey(pp, secret_seed, public_seed)
print(len(public_root), public_root.hex())

#16 9ab7a7b30bc9c6a8637a54caef3f9c27

rand = bytes.fromhex("a2fac94d6e320ad83fc049c6ba21033b")
msg = b"\xff"*32

signature = SPHINCS_Sign(pp, secret_seed, public_seed, public_root, msg, rand)

#        Random:                                           16 a2fac94d6e320ad83fc049c6ba21033b
#Hashed Message:         6391030117691388          241     21 265dc48ab5c151e14d73ddc62ab3646a5e1474ca73
#          FORS:                                           16 2f4db3d8172f2680e71f13e8b6dd3645
#       XMSS-MT:               tree_index   leaf_index
#    0-th layer:         6391030117691388          241 =>  16 85a91c6b80a1849f411d02ff73c1262a
#    1-th layer:           12482480698615          508 =>  16 774a93c53745b203bc89c2ccedcc40bf
#    2-th layer:              24379845114          247 =>  16 e698d35c86bc973a046f0cdbfed79bc1
#    3-th layer:                 47616884          506 =>  16 286c22499dca6d3a8cf0ba9ed9a8b5ed
#    4-th layer:                    93001          372 =>  16 ae3287acf595e9ef928f73484a60058e
#    5-th layer:                      181          329 =>  16 81b4e5c89d697835b45d23843b1f4e95
#    6-th layer:                        0          181 =>  16 9ab7a7b30bc9c6a8637a54caef3f9c27

root = SPHINCS_Verify(pp, public_seed, public_root, signature, msg)
assert root == public_root

FORS

  • Section 5. FORS: Forest Of Random Subsets
n = 16
algo = "shake"
robust = True
k = 14; a = 12

pp = (n, algo, robust, k, a)

secret_seed = b"\xaa"*n
#public_seed = b"\xbb"*n
public_seed = None

mt_addr = [0, 0, 0]

pk = FORS_GeneratePublicKey(pp, secret_seed, public_seed, mt_addr)
(public_seed, public_root) = pk

msg = b"Hello World!"

#rand = random.randbytes(n)
rand = None

signature = FORS_Sign(pp, sk, pk, msg, rand, mt_addr)
(rand, sigs) = signature

assert FORS_Verify(pp, pk, signature, msg, mt_addr)

WOTS+

  • Section 3. WOTS+ One-Time Signatures
n = 16
algo = "shake"
robust = True
w = 4
pp = (n, algo, robust, w)

secret_seed = b"\xaa"*n
#public_seed = b"\xbb"*n
public_seed = None

mt_addr = [0, 0, 0]
pk = WOTS_GeneratePublicKey(pp, secret_seed, public_seed, mt_addr)
(public_seed, public_root) = pk

msg = b"Hello World!"

#rand = random.randbytes(n)
rand = None

signature = WOTS_Sign(pp, sk, pk, msg, rand, mt_addr)
(rand, sigs) = signature

assert WOTS_Verify(pp, pk, signature, msg, mt_addr)

XMSS

  • Section 4.1. (Fixed Input-Length) XMSS

HT(XMSS-MT)

  • Section 4.2. HT: The Hypertee

pysig's People

Contributors

elzebra avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.