Ejemplo n.º 1
0
import requests
import hashlib
import base64
import json
import sys
from binascii import hexlify, unhexlify
import nak

from ecpy.curves import curve_secp256k1
from ecpy.point import Point, Generator
from ecpy.ecdsa import ECDSA
from Crypto.Random import random
from Crypto.Cipher import AES
from Crypto.Util import Counter

Point.set_curve(curve_secp256k1)
_G = Generator.init(curve_secp256k1['G'][0], curve_secp256k1['G'][1])
ECDSA.set_generator(_G)

client_p = random.randint(1,curve_secp256k1['n']-1)
client_P = _G * client_p

client_r = random.randint(1,curve_secp256k1['n']-1)
client_R = _G * client_r

ecdsa=ECDSA()

_server = "http://indigo.bounceme.net:5000/"
_server2 = "http://coopr8.com:5000/"
_server3 = "http://ciphrtxt.com:5000/"
_status = "api/status/"
Ejemplo n.º 2
0
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from Crypto.Random import random

from binascii import hexlify, unhexlify
import time
import json

from ecpy.curves import curve_secp256k1
from ecpy.point import Point, Generator
from ecpy.ecdsa import ECDSA

_def_curve = curve_secp256k1
Point.set_curve(_def_curve)
ECDSA.set_curve(_def_curve)
ECDSA.set_generator(Generator.init(_def_curve['G'][0], _def_curve['G'][1]))

class NAK(object):
    n = _def_curve['n']
    G = Generator.init(_def_curve['G'][0], _def_curve['G'][1])
    ecdsa = ECDSA()
    
    def __init__(self, expire=None, pubkey=None, signature=None, privkey=None):
        self.expire = expire
        self.pubkey = pubkey
        self.signature = signature
        self.privkey = privkey
        if privkey is not None and pubkey is None:
            self.pubkey = NAK.G * privkey
Ejemplo n.º 3
0
from binascii import hexlify, unhexlify
import json
import logging
import time
import os
import random
from tornado.httpclient import HTTPClient, HTTPRequest, HTTPError
from lbr import lbr
from msgstoreclient import MsgStore
import ctcoin.rpc

from ecpy.curves import curve_secp256k1
from ecpy.point import Point

_curve = curve_secp256k1
Point.set_curve(_curve)

_default_port=7754
_default_coin_port=7764
_default_max_age=(4*60*60)    # 4 hours
_default_max_fails=1

_statusPath = 'api/v2/status/'
_peerListPath = 'api/v2/peers/'
_peerUpdatePath = 'api/v2/peers/'

_peer_msync_timeout = 10
_peer_psync_interval = (2*60)   # 2 minutes

sclient = HTTPClient()
Ejemplo n.º 4
0
from binascii import hexlify, unhexlify
import json
import logging
import time
import os
import random
from tornado.httpclient import HTTPClient, HTTPRequest, HTTPError
from lbr import lbr
from msgstoreclient import MsgStore
import ctcoin.rpc

from ecpy.curves import curve_secp256k1
from ecpy.point import Point

_curve = curve_secp256k1
Point.set_curve(_curve)

_default_port = 7754
_default_coin_port = 7764
_default_max_age = (4 * 60 * 60)  # 4 hours
_default_max_fails = 1

_statusPath = 'api/v2/status/'
_peerListPath = 'api/v2/peers/'
_peerUpdatePath = 'api/v2/peers/'

_peer_msync_timeout = 10
_peer_psync_interval = (2 * 60)  # 2 minutes

sclient = HTTPClient()
Ejemplo n.º 5
0
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from ecpy.point import Point, Generator
import ecpy.curves as curves
from Crypto.Random import random
from Crypto.Hash import RIPEMD
from hashlib import sha256
import hashlib
from binascii import hexlify, unhexlify
from base58 import b58encode, b58decode

# set up elliptic curve environment
c = curves.curve_secp256k1
Point.set_curve(c)
G = Generator(c['G'][0], c['G'][1])

#mainnet
pub_prefix = '00'
prv_prefix = '80'
#testnet
pub_prefix = '6f'
prv_prefix = 'ef'
#simtest
pub_prefix = '3f'
prv_prefix = '64'
#ctindigonet
pub_prefix = '1c'
prv_prefix = 'bb'
#ctrednet
Ejemplo n.º 6
0
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from ecpy.point import Point, Generator
import ecpy.curves as curves
from Crypto.Random import random
from Crypto.Hash import RIPEMD
from hashlib import sha256
import hashlib
from binascii import hexlify, unhexlify
from base58 import b58encode, b58decode

# set up elliptic curve environment
_C = curves.curve_secp256k1
Point.set_curve(_C)
_G = Generator.init(_C['G'][0], _C['G'][1])

_network_id = {
    'ct-indigo': {
        'pub': b'1c',
        'priv': b'bb'
    },
    'ct-red': {
        'pub': b'50',
        'priv': b'a3'
    },
    'bt-main': {
        'pub': b'00',
        'priv': b'80'
    },
Ejemplo n.º 7
0
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from ecpy.point import Point, Generator
import ecpy.curves as curves
from Crypto.Random import random
from Crypto.Hash import RIPEMD
from hashlib import sha256
import hashlib
from binascii import hexlify, unhexlify
from base58 import b58encode, b58decode

# set up elliptic curve environment
_C = curves.curve_secp256k1
Point.set_curve(_C)
_G = Generator.init(_C['G'][0], _C['G'][1])

_network_id = {
    'ct-indigo': { 'pub': b'1c', 'priv': b'bb' },
    'ct-red': { 'pub': b'50', 'priv': b'a3' },
    'bt-main': { 'pub': b'00', 'priv': b'80' },
    'bt-test': { 'pub': b'6f', 'priv': b'ef' },
    'bt-simtest': { 'pub': b'3f', 'priv': b'64' },
}

_pfmt = '%%0%dx' % (((_C['bits'] + 7) >> 3) << 1)
_default_network = _network_id['ct-indigo']


class WalletPubkey (object):
Ejemplo n.º 8
0
import requests
import hashlib
import base64
import json
import sys
from binascii import hexlify, unhexlify
import nak

from ecpy.curves import curve_secp256k1
from ecpy.point import Point, Generator
from ecpy.ecdsa import ECDSA
from Crypto.Random import random
from Crypto.Cipher import AES
from Crypto.Util import Counter

Point.set_curve(curve_secp256k1)
_G = Generator.init(curve_secp256k1['G'][0], curve_secp256k1['G'][1])
ECDSA.set_generator(_G)

client_p = random.randint(1, curve_secp256k1['n'] - 1)
client_P = _G * client_p

client_r = random.randint(1, curve_secp256k1['n'] - 1)
client_R = _G * client_r

ecdsa = ECDSA()

_server = "http://indigo.bounceme.net:5000/"
_server2 = "http://coopr8.com:5000/"
_server3 = "http://ciphrtxt.com:5000/"
_status = "api/status/"
Ejemplo n.º 9
0
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from ecpy.point import Point, Generator
import ecpy.curves as curves
from Crypto.Random import random
from Crypto.Hash import RIPEMD
from hashlib import sha256
import hashlib
from binascii import hexlify, unhexlify
from base58 import b58encode, b58decode

# set up elliptic curve environment
c = curves.curve_secp256k1
Point.set_curve(c)
G = Generator(c['G'][0], c['G'][1])

#mainnet
pub_prefix = '00'
prv_prefix = '80'
#testnet
pub_prefix = '6f'
prv_prefix = 'ef'
#simtest
pub_prefix = '3f'
prv_prefix = '64'
#ctindigonet
pub_prefix = '1c'
prv_prefix = 'bb'
#ctrednet