Reorganized pairing library

This commit is contained in:
Vitalik Buterin 2017-05-12 02:27:24 -04:00
parent 797c311466
commit 2cd5415396
12 changed files with 62 additions and 10 deletions

View File

@ -1,12 +1,12 @@
import random
import datetime
diffs = [298.04 * 10**12]
hashpower = diffs[0] / 14.6
times = [1493155305]
diffs = [343.14 * 10**12]
hashpower = diffs[0] / 15
times = [1493974999]
for i in range(3566076, 6010000):
for i in range(3653829, 6010000):
blocktime = random.expovariate(hashpower / diffs[-1])
adjfac = max(1 - int(blocktime / 10), -99) / 2048.
newdiff = diffs[-1] * (1 + adjfac)

View File

@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2015 Vitalik Buterin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -0,0 +1 @@
Implements optimal ate pairings over the bn\_128 curve.

View File

@ -0,0 +1,3 @@
from .optimized_curve import *
from .optimized_field_elements import *
from .optimized_pairing import *

View File

@ -1,5 +1,5 @@
from bn128_field_elements import field_modulus, FQ
from optimized_field_elements import FQ2, FQ12
from .bn128_field_elements import field_modulus, FQ
from .optimized_field_elements import FQ2, FQ12
# from bn128_field_elements import FQ2, FQ12
curve_order = 21888242871839275222246405745257275088548364400416034343698204186575808495617

View File

@ -1,6 +1,6 @@
from optimized_curve import double, add, multiply, is_on_curve, neg, twist, b, b2, b12, curve_order, G1, G2, G12, normalize
from bn128_field_elements import field_modulus, FQ
from optimized_field_elements import FQ2, FQ12
from .optimized_curve import double, add, multiply, is_on_curve, neg, twist, b, b2, b12, curve_order, G1, G2, G12, normalize
from .bn128_field_elements import field_modulus, FQ
from .optimized_field_elements import FQ2, FQ12
ate_loop_count = 29793968203157093288
log_ate_loop_count = 63

View File

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
from setuptools import setup, find_packages
with open('README.md') as f:
readme = f.read()
with open('LICENSE') as f:
license = f.read()
setup(
name='py_pairing',
version='0.0.1',
description='Optimal ate pairings over alt_bn128',
long_description=readme,
author='Vitalik Buterin',
author_email='',
url='https://github.com/ethereum/research',
license=license,
packages=find_packages(exclude=('tests', 'docs')),
install_requires=[
'ethereum == 1.3.7',
'nose',
],
)

View File

@ -1,4 +1,4 @@
from optimized_pairing import pairing, neg, G2, G1, multiply, FQ12, curve_order
from py_pairing.optimized_pairing import pairing, neg, G2, G1, multiply, FQ12, curve_order
# from bn128_pairing import pairing, neg, G2, G1, multiply, FQ12, curve_order
import time