aboutsummaryrefslogtreecommitdiffstats
path: root/Godeps/_workspace/src/github.com/ethereum/serpent-go/serpent/examples/ecc/jacobian_double.se
blob: b7d8221a6fc6d03a7852c871c3dc5d493e2517de (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
def call(axn, axd, ayn, ayd):
    if !axn and !ayn:
        return([0, 1, 0, 1], 4)
    with P = -4294968273:
        # No need to add (A, 1) because A = 0 for bitcoin
        with mn = mulmod(mulmod(mulmod(axn, axn, P), 3, P), ayd, P):
            with md = mulmod(mulmod(axd, axd, P), mulmod(ayn, 2, P), P):
                with msqn = mulmod(mn, mn, P):
                    with msqd = mulmod(md, md, P):
                        with xn = addmod(mulmod(msqn, axd, P), P - mulmod(msqd, mulmod(axn, 2, P), P), P):
                            with xd = mulmod(msqd, axd, P):
                                with mamxn = mulmod(addmod(mulmod(axn, xd, P), P - mulmod(axd, xn, P), P), mn, P):
                                    with mamxd = mulmod(mulmod(axd, xd, P), md, P):
                                        with yn = addmod(mulmod(mamxn, ayd, P), P - mulmod(mamxd, ayn, P), P):
                                            with yd = mulmod(mamxd, ayd, P):
                                                return([xn, xd, yn, yd], 4)