diff options
Diffstat (limited to 'Godeps/_workspace/src/github.com/ethereum/serpent-go/serpent/examples/ecc/modexp.se')
-rw-r--r-- | Godeps/_workspace/src/github.com/ethereum/serpent-go/serpent/examples/ecc/modexp.se | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/github.com/ethereum/serpent-go/serpent/examples/ecc/modexp.se b/Godeps/_workspace/src/github.com/ethereum/serpent-go/serpent/examples/ecc/modexp.se new file mode 100644 index 000000000..687b12a04 --- /dev/null +++ b/Godeps/_workspace/src/github.com/ethereum/serpent-go/serpent/examples/ecc/modexp.se @@ -0,0 +1,11 @@ +def call(b, e, m): + with o = 1: + with bit = 2 ^ 255: + while gt(bit, 0): + # A touch of loop unrolling for 20% efficiency gain + o = mulmod(mulmod(o, o, m), b ^ !(!(e & bit)), m) + o = mulmod(mulmod(o, o, m), b ^ !(!(e & div(bit, 2))), m) + o = mulmod(mulmod(o, o, m), b ^ !(!(e & div(bit, 4))), m) + o = mulmod(mulmod(o, o, m), b ^ !(!(e & div(bit, 8))), m) + bit = div(bit, 16) + return(o) |