[Python-modules-commits] [python-mnemonic] 03/08: Import python-mnemonic_0.12.orig.tar.gz
Tristan Seligmann
mithrandi at moszumanska.debian.org
Sun Nov 20 21:53:59 UTC 2016
This is an automated email from the git hooks/post-receive script.
mithrandi pushed a commit to branch master
in repository python-mnemonic.
commit c7e79332cf2ea39f477f629011e2aada07d44376
Author: Tristan Seligmann <mithrandi at mithrandi.net>
Date: Sun Nov 20 23:12:21 2016 +0200
Import python-mnemonic_0.12.orig.tar.gz
---
PKG-INFO | 14 +
README | 33 +
mnemonic.egg-info/PKG-INFO | 14 +
mnemonic.egg-info/SOURCES.txt | 12 +
mnemonic.egg-info/dependency_links.txt | 1 +
mnemonic.egg-info/not-zip-safe | 1 +
mnemonic.egg-info/requires.txt | 1 +
mnemonic.egg-info/top_level.txt | 1 +
mnemonic/__init__.py | 1 +
mnemonic/mnemonic.py | 116 ++
mnemonic/wordlist/english.txt | 2048 ++++++++++++++++++++++++++++++++
mnemonic/wordlist/japanese.txt | 2048 ++++++++++++++++++++++++++++++++
setup.cfg | 5 +
setup.py | 21 +
14 files changed, 4316 insertions(+)
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..1a637a0
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,14 @@
+Metadata-Version: 1.1
+Name: mnemonic
+Version: 0.12
+Summary: Implementation of Bitcoin BIP-0039
+Home-page: https://github.com/trezor/python-mnemonic
+Author: Bitcoin TREZOR
+Author-email: info at bitcointrezor.com
+License: UNKNOWN
+Description: UNKNOWN
+Platform: UNKNOWN
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Operating System :: POSIX :: Linux
+Classifier: Operating System :: Microsoft :: Windows
+Classifier: Operating System :: MacOS :: MacOS X
diff --git a/README b/README
new file mode 100644
index 0000000..dc5a179
--- /dev/null
+++ b/README
@@ -0,0 +1,33 @@
+<pre>
+ BIP: BIP-0039
+ Title: Mnemonic code for generating deterministic keys
+ Authors: Marek Palatinus <slush at satoshilabs.com>
+ Pavol Rusnak <stick at satoshilabs.com>
+ ThomasV <thomasv at bitcointalk.org>
+ Aaron Voisine <voisine at gmail.com>
+ Sean Bowe <ewillbefull at gmail.com>
+ Status: Draft
+ Type: Standards Track
+ Created: 10-09-2013
+</pre>
+
+==Abstract==
+
+This BIP describes the implementation of a mnemonic code or mnemonic sentence --
+a group of easy to remember words -- for the generation of deterministic wallets.
+
+It consists of two parts: generating the mnenomic, and converting it into a
+binary seed. This seed can be later used to generate deterministic wallets using
+BIP-0032 or similar methods.
+
+==BIP paper==
+
+See https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki for full
+specification
+
+==Reference Implementation==
+
+Reference implementation including wordlists is available from
+
+http://github.com/trezor/python-mnemonic
+
diff --git a/mnemonic.egg-info/PKG-INFO b/mnemonic.egg-info/PKG-INFO
new file mode 100644
index 0000000..1a637a0
--- /dev/null
+++ b/mnemonic.egg-info/PKG-INFO
@@ -0,0 +1,14 @@
+Metadata-Version: 1.1
+Name: mnemonic
+Version: 0.12
+Summary: Implementation of Bitcoin BIP-0039
+Home-page: https://github.com/trezor/python-mnemonic
+Author: Bitcoin TREZOR
+Author-email: info at bitcointrezor.com
+License: UNKNOWN
+Description: UNKNOWN
+Platform: UNKNOWN
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Operating System :: POSIX :: Linux
+Classifier: Operating System :: Microsoft :: Windows
+Classifier: Operating System :: MacOS :: MacOS X
diff --git a/mnemonic.egg-info/SOURCES.txt b/mnemonic.egg-info/SOURCES.txt
new file mode 100644
index 0000000..0f841d8
--- /dev/null
+++ b/mnemonic.egg-info/SOURCES.txt
@@ -0,0 +1,12 @@
+README
+setup.py
+mnemonic/__init__.py
+mnemonic/mnemonic.py
+mnemonic.egg-info/PKG-INFO
+mnemonic.egg-info/SOURCES.txt
+mnemonic.egg-info/dependency_links.txt
+mnemonic.egg-info/not-zip-safe
+mnemonic.egg-info/requires.txt
+mnemonic.egg-info/top_level.txt
+mnemonic/wordlist/english.txt
+mnemonic/wordlist/japanese.txt
\ No newline at end of file
diff --git a/mnemonic.egg-info/dependency_links.txt b/mnemonic.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/mnemonic.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/mnemonic.egg-info/not-zip-safe b/mnemonic.egg-info/not-zip-safe
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/mnemonic.egg-info/not-zip-safe
@@ -0,0 +1 @@
+
diff --git a/mnemonic.egg-info/requires.txt b/mnemonic.egg-info/requires.txt
new file mode 100644
index 0000000..4d76810
--- /dev/null
+++ b/mnemonic.egg-info/requires.txt
@@ -0,0 +1 @@
+pbkdf2
diff --git a/mnemonic.egg-info/top_level.txt b/mnemonic.egg-info/top_level.txt
new file mode 100644
index 0000000..9015942
--- /dev/null
+++ b/mnemonic.egg-info/top_level.txt
@@ -0,0 +1 @@
+mnemonic
diff --git a/mnemonic/__init__.py b/mnemonic/__init__.py
new file mode 100644
index 0000000..6adf6b8
--- /dev/null
+++ b/mnemonic/__init__.py
@@ -0,0 +1 @@
+from .mnemonic import Mnemonic
diff --git a/mnemonic/mnemonic.py b/mnemonic/mnemonic.py
new file mode 100644
index 0000000..4eaaf55
--- /dev/null
+++ b/mnemonic/mnemonic.py
@@ -0,0 +1,116 @@
+#
+# Copyright (c) 2013 Pavol Rusnak
+#
+# 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.
+#
+
+import binascii
+import hashlib
+import hmac
+import os
+import sys
+import unicodedata
+
+from pbkdf2 import PBKDF2
+
+PBKDF2_ROUNDS = 2048
+
+
+class Mnemonic(object):
+ def __init__(self, language):
+ self.radix = 2048
+ with open('%s/%s.txt' % (self._get_directory(), language), 'r') as f:
+ self.wordlist = [w.strip() for w in f.readlines()]
+ if len(self.wordlist) != self.radix:
+ raise Exception('Wordlist should contain %d words, but it contains %d words.' % (self.radix, len(self.wordlist)))
+
+ @classmethod
+ def _get_directory(cls):
+ return os.path.join(os.path.dirname(__file__), 'wordlist')
+
+ @classmethod
+ def list_languages(cls):
+ return [ f.split('.')[0] for f in os.listdir(cls._get_directory()) if f.endswith('.txt') ]
+
+ @classmethod
+ def normalize_string(cls, txt):
+ if isinstance(txt, str if sys.version < '3' else bytes):
+ utxt = txt.decode('utf8')
+ elif isinstance(txt, unicode if sys.version < '3' else str):
+ utxt = txt
+ else:
+ raise Exception("String value expected")
+
+ return unicodedata.normalize('NFKD', utxt)
+
+ @classmethod
+ def detect_language(cls, code):
+ first = code.split(' ')[0]
+ languages = cls.list_languages()
+
+ for lang in languages:
+ mnemo = cls(lang)
+ if first in mnemo.wordlist:
+ return lang
+
+ raise Exception("Language not detected")
+
+ def generate(self, strength = 128):
+ if strength % 32 > 0:
+ raise Exception('Strength should be divisible by 32, but it is not (%d).' % strength)
+ return self.to_mnemonic(os.urandom(strength // 8))
+
+ def to_mnemonic(self, data):
+ if len(data) % 4 > 0:
+ raise Exception('Data length in bits should be divisible by 32, but it is not (%d bytes = %d bits).' % (len(data), len(data) * 8))
+ h = hashlib.sha256(data).hexdigest()
+ b = bin(int(binascii.hexlify(data), 16))[2:].zfill(len(data) * 8) + \
+ bin(int(h, 16))[2:].zfill(256)[:len(data) * 8 // 32]
+ result = []
+ for i in range(len(b) // 11):
+ idx = int(b[i * 11:(i + 1) * 11], 2)
+ result.append(self.wordlist[idx])
+ if self.detect_language(' '.join(result)) == 'japanese': # Japanese must be joined by ideographic space.
+ result_phrase = '\xe3\x80\x80'.join(result)
+ else:
+ result_phrase = ' '.join(result)
+ return result_phrase
+
+ def check(self, mnemonic):
+ if self.detect_language(mnemonic.replace('\xe3\x80\x80', ' ')) == 'japanese':
+ mnemonic = mnemonic.replace('\xe3\x80\x80', ' ') # Japanese will likely input with ideographic space.
+ mnemonic = mnemonic.split(' ')
+ if len(mnemonic) % 3 > 0:
+ return False
+ try:
+ idx = map(lambda x: bin(self.wordlist.index(x))[2:].zfill(11), mnemonic)
+ b = ''.join(idx)
+ except:
+ return False
+ l = len(b)
+ d = b[:l // 33 * 32]
+ h = b[-l // 33:]
+ nd = binascii.unhexlify(hex(int(d, 2))[2:].rstrip('L').zfill(l // 33 * 8))
+ nh = bin(int(hashlib.sha256(nd).hexdigest(), 16))[2:].zfill(256)[:l // 33]
+ return h == nh
+
+ @classmethod
+ def to_seed(cls, mnemonic, passphrase = ''):
+ mnemonic = cls.normalize_string(mnemonic)
+ passphrase = cls.normalize_string(passphrase)
+ return PBKDF2(mnemonic, u'mnemonic' + passphrase, iterations=PBKDF2_ROUNDS, macmodule=hmac, digestmodule=hashlib.sha512).read(64)
diff --git a/mnemonic/wordlist/english.txt b/mnemonic/wordlist/english.txt
new file mode 100644
index 0000000..942040e
--- /dev/null
+++ b/mnemonic/wordlist/english.txt
@@ -0,0 +1,2048 @@
+abandon
+ability
+able
+about
+above
+absent
+absorb
+abstract
+absurd
+abuse
+access
+accident
+account
+accuse
+achieve
+acid
+acoustic
+acquire
+across
+act
+action
+actor
+actress
+actual
+adapt
+add
+addict
+address
+adjust
+admit
+adult
+advance
+advice
+aerobic
+affair
+afford
+afraid
+again
+age
+agent
+agree
+ahead
+aim
+air
+airport
+aisle
+alarm
+album
+alcohol
+alert
+alien
+all
+alley
+allow
+almost
+alone
+alpha
+already
+also
+alter
+always
+amateur
+amazing
+among
+amount
+amused
+analyst
+anchor
+ancient
+anger
+angle
+angry
+animal
+ankle
+announce
+annual
+another
+answer
+antenna
+antique
+anxiety
+any
+apart
+apology
+appear
+apple
+approve
+april
+arch
+arctic
+area
+arena
+argue
+arm
+armed
+armor
+army
+around
+arrange
+arrest
+arrive
+arrow
+art
+artefact
+artist
+artwork
+ask
+aspect
+assault
+asset
+assist
+assume
+asthma
+athlete
+atom
+attack
+attend
+attitude
+attract
+auction
+audit
+august
+aunt
+author
+auto
+autumn
+average
+avocado
+avoid
+awake
+aware
+away
+awesome
+awful
+awkward
+axis
+baby
+bachelor
+bacon
+badge
+bag
+balance
+balcony
+ball
+bamboo
+banana
+banner
+bar
+barely
+bargain
+barrel
+base
+basic
+basket
+battle
+beach
+bean
+beauty
+because
+become
+beef
+before
+begin
+behave
+behind
+believe
+below
+belt
+bench
+benefit
+best
+betray
+better
+between
+beyond
+bicycle
+bid
+bike
+bind
+biology
+bird
+birth
+bitter
+black
+blade
+blame
+blanket
+blast
+bleak
+bless
+blind
+blood
+blossom
+blouse
+blue
+blur
+blush
+board
+boat
+body
+boil
+bomb
+bone
+bonus
+book
+boost
+border
+boring
+borrow
+boss
+bottom
+bounce
+box
+boy
+bracket
+brain
+brand
+brass
+brave
+bread
+breeze
+brick
+bridge
+brief
+bright
+bring
+brisk
+broccoli
+broken
+bronze
+broom
+brother
+brown
+brush
+bubble
+buddy
+budget
+buffalo
+build
+bulb
+bulk
+bullet
+bundle
+bunker
+burden
+burger
+burst
+bus
+business
+busy
+butter
+buyer
+buzz
+cabbage
+cabin
+cable
+cactus
+cage
+cake
+call
+calm
+camera
+camp
+can
+canal
+cancel
+candy
+cannon
+canoe
+canvas
+canyon
+capable
+capital
+captain
+car
+carbon
+card
+cargo
+carpet
+carry
+cart
+case
+cash
+casino
+castle
+casual
+cat
+catalog
+catch
+category
+cattle
+caught
+cause
+caution
+cave
+ceiling
+celery
+cement
+census
+century
+cereal
+certain
+chair
+chalk
+champion
+change
+chaos
+chapter
+charge
+chase
+chat
+cheap
+check
+cheese
+chef
+cherry
+chest
+chicken
+chief
+child
+chimney
+choice
+choose
+chronic
+chuckle
+chunk
+churn
+cigar
+cinnamon
+circle
+citizen
+city
+civil
+claim
+clap
+clarify
+claw
+clay
+clean
+clerk
+clever
+click
+client
+cliff
+climb
+clinic
+clip
+clock
+clog
+close
+cloth
+cloud
+clown
+club
+clump
+cluster
+clutch
+coach
+coast
+coconut
+code
+coffee
+coil
+coin
+collect
+color
+column
+combine
+come
+comfort
+comic
+common
+company
+concert
+conduct
+confirm
+congress
+connect
+consider
+control
+convince
+cook
+cool
+copper
+copy
+coral
+core
+corn
+correct
+cost
+cotton
+couch
+country
+couple
+course
+cousin
+cover
+coyote
+crack
+cradle
+craft
+cram
+crane
+crash
+crater
+crawl
+crazy
+cream
+credit
+creek
+crew
+cricket
+crime
+crisp
+critic
+crop
+cross
+crouch
+crowd
+crucial
+cruel
+cruise
+crumble
+crunch
+crush
+cry
+crystal
+cube
+culture
+cup
+cupboard
+curious
+current
+curtain
+curve
+cushion
+custom
+cute
+cycle
+dad
+damage
+damp
+dance
+danger
+daring
+dash
+daughter
+dawn
+day
+deal
+debate
+debris
+decade
+december
+decide
+decline
+decorate
+decrease
+deer
+defense
+define
+defy
+degree
+delay
+deliver
+demand
+demise
+denial
+dentist
+deny
+depart
+depend
+deposit
+depth
+deputy
+derive
+describe
+desert
+design
+desk
+despair
+destroy
+detail
+detect
+develop
+device
+devote
+diagram
+dial
+diamond
+diary
+dice
+diesel
+diet
+differ
+digital
+dignity
+dilemma
+dinner
+dinosaur
+direct
+dirt
+disagree
+discover
+disease
+dish
+dismiss
+disorder
+display
+distance
+divert
+divide
+divorce
+dizzy
+doctor
+document
+dog
+doll
+dolphin
+domain
+donate
+donkey
+donor
+door
+dose
+double
+dove
+draft
+dragon
+drama
+drastic
+draw
+dream
+dress
+drift
+drill
+drink
+drip
+drive
+drop
+drum
+dry
+duck
+dumb
+dune
+during
+dust
+dutch
+duty
+dwarf
+dynamic
+eager
+eagle
+early
+earn
+earth
+easily
+east
+easy
+echo
+ecology
+economy
+edge
+edit
+educate
+effort
+egg
+eight
+either
+elbow
+elder
+electric
+elegant
+element
+elephant
+elevator
+elite
+else
+embark
+embody
+embrace
+emerge
+emotion
+employ
+empower
+empty
+enable
+enact
+end
+endless
+endorse
+enemy
+energy
+enforce
+engage
+engine
+enhance
+enjoy
+enlist
+enough
+enrich
+enroll
+ensure
+enter
+entire
+entry
+envelope
+episode
+equal
+equip
+era
+erase
+erode
+erosion
+error
+erupt
+escape
+essay
+essence
+estate
+eternal
+ethics
+evidence
+evil
+evoke
+evolve
+exact
+example
+excess
+exchange
+excite
+exclude
+excuse
+execute
+exercise
+exhaust
+exhibit
+exile
+exist
+exit
+exotic
+expand
+expect
+expire
+explain
+expose
+express
+extend
+extra
+eye
+eyebrow
+fabric
+face
+faculty
+fade
+faint
+faith
+fall
+false
+fame
+family
+famous
+fan
+fancy
+fantasy
+farm
+fashion
+fat
+fatal
+father
+fatigue
+fault
+favorite
+feature
+february
+federal
+fee
+feed
+feel
+female
+fence
+festival
+fetch
+fever
+few
+fiber
+fiction
+field
+figure
+file
+film
+filter
+final
+find
+fine
+finger
+finish
+fire
+firm
+first
+fiscal
+fish
+fit
+fitness
+fix
+flag
+flame
+flash
+flat
+flavor
+flee
+flight
+flip
+float
+flock
+floor
+flower
... 3423 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-mnemonic.git
More information about the Python-modules-commits
mailing list