{"action":"created","comment":{"url":"https://api.github.com/repos/ripple/rippled/pulls/comments/28777072","id":28777072,"diff_hunk":"@@ -0,0 +1,139 @@\n+#!/usr/bin/env python\n+\n+from __future__ import print_function\n+\n+import base64, os, random, sys\n+import ed25519\n+import ecdsa\n+from ripple.util import Base58\n+from ripple.ledger import SField\n+\n+ED_BYTE = chr(0xed)\n+\n+USAGE = \"\"\"\\\n+Usage:\n+    create\n+        Create a new master public/secret key pair.\n+\n+    check <key>\n+        Check an existing key for validity.\n+\n+    sign <sequence> <validator-public> <master-secret>\n+        Create a new signed manifest with the given sequence\n+        number, validator public key, and master secret key.\n+    \"\"\"\n+\n+def to_bytes_bigend(n, length):\n+    h = '%x' % n\n+    return ('0' * (len(h) % 2) + h).zfill(length * 2).decode('hex')\n+\n+def prepend_length_byte(b):\n+    assert len(b) < 192, 'Too long'\n+    return chr(len(b)) + b\n+\n+#-----------------------------------------------------------\n+\n+def make_seed(urandom=os.urandom):\n+    # This is not used.\n+    return urandom(16)\n+\n+def make_ed25519_keypair(urandom=os.urandom):\n+    private_key = urandom(32)\n+    return private_key, ed25519.publickey(private_key)\n+\n+def make_ecdsa_keypair():\n+    # This is not used.\n+    private_key = ecdsa.SigningKey.generate(curve=ecdsa.SECP256k1)\n+    # Can't be unit tested easily - need a mock for ecdsa.\n+    vk = private_key.get_verifying_key()\n+    sig = private_key.sign('message')\n+    assert vk.verify(sig, 'message')\n+    return private_key, vk\n+\n+def make_manifest(pk, vpk, seq):\n+    return ''.join([\n+        SField.sfSequence,\n+        to_bytes_bigend(seq, 4),\n+        SField.sfPublicKey,\n+        prepend_length_byte(pk),\n+        SField.sfSigningPubKey,\n+        prepend_length_byte(vpk)])\n+\n+def sign_manifest(manifest, private_key, pk):\n+    sig = ed25519.signature('MAN\\0' + manifest, private_key, pk)\n+    return manifest + SField.sfSignature + prepend_length_byte(sig)\n+\n+def wrap(s, cols=60):\n+    if s:\n+        size = max((len(s) + cols - 1) / cols, 1)\n+        w = len(s) / size\n+        s = '\\n'.join(s[i:i + w] for i in range(0, len(s), w))\n+    return s\n+\n+def create_ed_keys(urandom=os.urandom):\n+    private_key, pk = make_ed25519_keypair(urandom)\n+    apk = ED_BYTE + pk\n+    pkh = Base58.encode_version(Base58.VER_NODE_PUBLIC, apk)\n+    skh = Base58.encode_version(Base58.VER_NODE_PRIVATE, private_key)\n+    v0, apk0 = Base58.decode_version(pkh)\n+    assert v0 == Base58.VER_NODE_PUBLIC\n+    assert apk0 == apk\n+    return pkh, skh\n+\n+def create():\n+    pkh, skh = create_ed_keys()\n+    print('[validators]', pkh, '', '[master_secret]', skh, sep='\\n')\n+\n+def check(s):\n+    ver, b = Base58.decode_version(s)\n+    print('version        = ' + Base58.version_name(ver))\n+    print('decoded length = ' + str(len(b)))\n+    h = Base58.encode_version(ver, b)\n+    assert h == s\n+\n+def check_validator_public(v, avpk):\n+    assert v == Base58.VER_NODE_PUBLIC, 'Not a validator-public.'\n+    assert len(avpk) == 33, 'Length of validating key must be 33.'\n+    assert ord(avpk[0]) in (2, 3), 'First validating key byte must be 2 or 3.'\n+\n+def check_master_secret(v, private_key):\n+    assert v == Base58.VER_NODE_PRIVATE, 'Version is not private.'\n+    assert len(private_key) == 32, 'Length of master secret must be 32.'\n+\n+def get_signature(seq, vpkh, skh):\n+    v, avpk = Base58.decode_version(vpkh)","path":"bin/python/ripple/util/Sign.py","position":104,"original_position":104,"commit_id":"703a6afafe2f8e7be673d03146dd3a01bd15ffc7","original_commit_id":"703a6afafe2f8e7be673d03146dd3a01bd15ffc7","user":{"login":"sublimator","id":525211,"avatar_url":"https://avatars.githubusercontent.com/u/525211?v=3","gravatar_id":"","url":"https://api.github.com/users/sublimator","html_url":"https://github.com/sublimator","followers_url":"https://api.github.com/users/sublimator/followers","following_url":"https://api.github.com/users/sublimator/following{/other_user}","gists_url":"https://api.github.com/users/sublimator/gists{/gist_id}","starred_url":"https://api.github.com/users/sublimator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sublimator/subscriptions","organizations_url":"https://api.github.com/users/sublimator/orgs","repos_url":"https://api.github.com/users/sublimator/repos","events_url":"https://api.github.com/users/sublimator/events{/privacy}","received_events_url":"https://api.github.com/users/sublimator/received_events","type":"User","site_admin":false},"body":"ah, of course!\n","created_at":"2015-04-21T13:30:46Z","updated_at":"2015-04-21T13:30:46Z","html_url":"https://github.com/ripple/rippled/pull/999#discussion_r28777072","pull_request_url":"https://api.github.com/repos/ripple/rippled/pulls/999","_links":{"self":{"href":"https://api.github.com/repos/ripple/rippled/pulls/comments/28777072"},"html":{"href":"https://github.com/ripple/rippled/pull/999#discussion_r28777072"},"pull_request":{"href":"https://api.github.com/repos/ripple/rippled/pulls/999"}}},"pull_request":{"url":"https://api.github.com/repos/ripple/rippled/pulls/999","id":33719412,"html_url":"https://github.com/ripple/rippled/pull/999","diff_url":"https://github.com/ripple/rippled/pull/999.diff","patch_url":"https://github.com/ripple/rippled/pull/999.patch","issue_url":"https://api.github.com/repos/ripple/rippled/issues/999","number":999,"state":"open","locked":false,"title":"New manifest tool.","user":{"login":"rec","id":253362,"avatar_url":"https://avatars.githubusercontent.com/u/253362?v=3","gravatar_id":"","url":"https://api.github.com/users/rec","html_url":"https://github.com/rec","followers_url":"https://api.github.com/users/rec/followers","following_url":"https://api.github.com/users/rec/following{/other_user}","gists_url":"https://api.github.com/users/rec/gists{/gist_id}","starred_url":"https://api.github.com/users/rec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rec/subscriptions","organizations_url":"https://api.github.com/users/rec/orgs","repos_url":"https://api.github.com/users/rec/repos","events_url":"https://api.github.com/users/rec/events{/privacy}","received_events_url":"https://api.github.com/users/rec/received_events","type":"User","site_admin":false},"body":"Reviewers: @seelabs @sublimator \r\n\r\nProbably @vinniefalco wants to see this too.","created_at":"2015-04-21T00:30:52Z","updated_at":"2015-04-21T13:30:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7a49e5393b6eed579e60276751f1b2f198c5067e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ripple/rippled/pulls/999/commits","review_comments_url":"https://api.github.com/repos/ripple/rippled/pulls/999/comments","review_comment_url":"https://api.github.com/repos/ripple/rippled/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ripple/rippled/issues/999/comments","statuses_url":"https://api.github.com/repos/ripple/rippled/statuses/703a6afafe2f8e7be673d03146dd3a01bd15ffc7","head":{"label":"rec:manifest.py","ref":"manifest.py","sha":"703a6afafe2f8e7be673d03146dd3a01bd15ffc7","user":{"login":"rec","id":253362,"avatar_url":"https://avatars.githubusercontent.com/u/253362?v=3","gravatar_id":"","url":"https://api.github.com/users/rec","html_url":"https://github.com/rec","followers_url":"https://api.github.com/users/rec/followers","following_url":"https://api.github.com/users/rec/following{/other_user}","gists_url":"https://api.github.com/users/rec/gists{/gist_id}","starred_url":"https://api.github.com/users/rec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rec/subscriptions","organizations_url":"https://api.github.com/users/rec/orgs","repos_url":"https://api.github.com/users/rec/repos","events_url":"https://api.github.com/users/rec/events{/privacy}","received_events_url":"https://api.github.com/users/rec/received_events","type":"User","site_admin":false},"repo":{"id":18302070,"name":"rippled","full_name":"rec/rippled","owner":{"login":"rec","id":253362,"avatar_url":"https://avatars.githubusercontent.com/u/253362?v=3","gravatar_id":"","url":"https://api.github.com/users/rec","html_url":"https://github.com/rec","followers_url":"https://api.github.com/users/rec/followers","following_url":"https://api.github.com/users/rec/following{/other_user}","gists_url":"https://api.github.com/users/rec/gists{/gist_id}","starred_url":"https://api.github.com/users/rec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rec/subscriptions","organizations_url":"https://api.github.com/users/rec/orgs","repos_url":"https://api.github.com/users/rec/repos","events_url":"https://api.github.com/users/rec/events{/privacy}","received_events_url":"https://api.github.com/users/rec/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rec/rippled","description":"Ripple peer-to-peer network daemon","fork":true,"url":"https://api.github.com/repos/rec/rippled","forks_url":"https://api.github.com/repos/rec/rippled/forks","keys_url":"https://api.github.com/repos/rec/rippled/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rec/rippled/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rec/rippled/teams","hooks_url":"https://api.github.com/repos/rec/rippled/hooks","issue_events_url":"https://api.github.com/repos/rec/rippled/issues/events{/number}","events_url":"https://api.github.com/repos/rec/rippled/events","assignees_url":"https://api.github.com/repos/rec/rippled/assignees{/user}","branches_url":"https://api.github.com/repos/rec/rippled/branches{/branch}","tags_url":"https://api.github.com/repos/rec/rippled/tags","blobs_url":"https://api.github.com/repos/rec/rippled/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rec/rippled/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rec/rippled/git/refs{/sha}","trees_url":"https://api.github.com/repos/rec/rippled/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rec/rippled/statuses/{sha}","languages_url":"https://api.github.com/repos/rec/rippled/languages","stargazers_url":"https://api.github.com/repos/rec/rippled/stargazers","contributors_url":"https://api.github.com/repos/rec/rippled/contributors","subscribers_url":"https://api.github.com/repos/rec/rippled/subscribers","subscription_url":"https://api.github.com/repos/rec/rippled/subscription","commits_url":"https://api.github.com/repos/rec/rippled/commits{/sha}","git_commits_url":"https://api.github.com/repos/rec/rippled/git/commits{/sha}","comments_url":"https://api.github.com/repos/rec/rippled/comments{/number}","issue_comment_url":"https://api.github.com/repos/rec/rippled/issues/comments{/number}","contents_url":"https://api.github.com/repos/rec/rippled/contents/{+path}","compare_url":"https://api.github.com/repos/rec/rippled/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rec/rippled/merges","archive_url":"https://api.github.com/repos/rec/rippled/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rec/rippled/downloads","issues_url":"https://api.github.com/repos/rec/rippled/issues{/number}","pulls_url":"https://api.github.com/repos/rec/rippled/pulls{/number}","milestones_url":"https://api.github.com/repos/rec/rippled/milestones{/number}","notifications_url":"https://api.github.com/repos/rec/rippled/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rec/rippled/labels{/name}","releases_url":"https://api.github.com/repos/rec/rippled/releases{/id}","created_at":"2014-03-31T17:41:21Z","updated_at":"2015-04-21T02:21:16Z","pushed_at":"2015-04-21T02:21:35Z","git_url":"git://github.com/rec/rippled.git","ssh_url":"git@github.com:rec/rippled.git","clone_url":"https://github.com/rec/rippled.git","svn_url":"https://github.com/rec/rippled","homepage":"https://ripple.com","size":58163,"stargazers_count":2,"watchers_count":2,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":2,"default_branch":"develop"}},"base":{"label":"ripple:develop","ref":"develop","sha":"9019f3a4f2172902194f4f4bf6d70d66f945861a","user":{"login":"ripple","id":3165523,"avatar_url":"https://avatars.githubusercontent.com/u/3165523?v=3","gravatar_id":"","url":"https://api.github.com/users/ripple","html_url":"https://github.com/ripple","followers_url":"https://api.github.com/users/ripple/followers","following_url":"https://api.github.com/users/ripple/following{/other_user}","gists_url":"https://api.github.com/users/ripple/gists{/gist_id}","starred_url":"https://api.github.com/users/ripple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ripple/subscriptions","organizations_url":"https://api.github.com/users/ripple/orgs","repos_url":"https://api.github.com/users/ripple/repos","events_url":"https://api.github.com/users/ripple/events{/privacy}","received_events_url":"https://api.github.com/users/ripple/received_events","type":"Organization","site_admin":false},"repo":{"id":2724167,"name":"rippled","full_name":"ripple/rippled","owner":{"login":"ripple","id":3165523,"avatar_url":"https://avatars.githubusercontent.com/u/3165523?v=3","gravatar_id":"","url":"https://api.github.com/users/ripple","html_url":"https://github.com/ripple","followers_url":"https://api.github.com/users/ripple/followers","following_url":"https://api.github.com/users/ripple/following{/other_user}","gists_url":"https://api.github.com/users/ripple/gists{/gist_id}","starred_url":"https://api.github.com/users/ripple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ripple/subscriptions","organizations_url":"https://api.github.com/users/ripple/orgs","repos_url":"https://api.github.com/users/ripple/repos","events_url":"https://api.github.com/users/ripple/events{/privacy}","received_events_url":"https://api.github.com/users/ripple/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ripple/rippled","description":"Ripple peer-to-peer network daemon","fork":false,"url":"https://api.github.com/repos/ripple/rippled","forks_url":"https://api.github.com/repos/ripple/rippled/forks","keys_url":"https://api.github.com/repos/ripple/rippled/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ripple/rippled/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ripple/rippled/teams","hooks_url":"https://api.github.com/repos/ripple/rippled/hooks","issue_events_url":"https://api.github.com/repos/ripple/rippled/issues/events{/number}","events_url":"https://api.github.com/repos/ripple/rippled/events","assignees_url":"https://api.github.com/repos/ripple/rippled/assignees{/user}","branches_url":"https://api.github.com/repos/ripple/rippled/branches{/branch}","tags_url":"https://api.github.com/repos/ripple/rippled/tags","blobs_url":"https://api.github.com/repos/ripple/rippled/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ripple/rippled/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ripple/rippled/git/refs{/sha}","trees_url":"https://api.github.com/repos/ripple/rippled/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ripple/rippled/statuses/{sha}","languages_url":"https://api.github.com/repos/ripple/rippled/languages","stargazers_url":"https://api.github.com/repos/ripple/rippled/stargazers","contributors_url":"https://api.github.com/repos/ripple/rippled/contributors","subscribers_url":"https://api.github.com/repos/ripple/rippled/subscribers","subscription_url":"https://api.github.com/repos/ripple/rippled/subscription","commits_url":"https://api.github.com/repos/ripple/rippled/commits{/sha}","git_commits_url":"https://api.github.com/repos/ripple/rippled/git/commits{/sha}","comments_url":"https://api.github.com/repos/ripple/rippled/comments{/number}","issue_comment_url":"https://api.github.com/repos/ripple/rippled/issues/comments{/number}","contents_url":"https://api.github.com/repos/ripple/rippled/contents/{+path}","compare_url":"https://api.github.com/repos/ripple/rippled/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ripple/rippled/merges","archive_url":"https://api.github.com/repos/ripple/rippled/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ripple/rippled/downloads","issues_url":"https://api.github.com/repos/ripple/rippled/issues{/number}","pulls_url":"https://api.github.com/repos/ripple/rippled/pulls{/number}","milestones_url":"https://api.github.com/repos/ripple/rippled/milestones{/number}","notifications_url":"https://api.github.com/repos/ripple/rippled/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ripple/rippled/labels{/name}","releases_url":"https://api.github.com/repos/ripple/rippled/releases{/id}","created_at":"2011-11-07T04:40:15Z","updated_at":"2015-04-20T23:39:12Z","pushed_at":"2015-04-21T13:06:11Z","git_url":"git://github.com/ripple/rippled.git","ssh_url":"git@github.com:ripple/rippled.git","clone_url":"https://github.com/ripple/rippled.git","svn_url":"https://github.com/ripple/rippled","homepage":"https://ripple.com","size":110873,"stargazers_count":939,"watchers_count":939,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":261,"mirror_url":null,"open_issues_count":133,"forks":261,"open_issues":133,"watchers":939,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/ripple/rippled/pulls/999"},"html":{"href":"https://github.com/ripple/rippled/pull/999"},"issue":{"href":"https://api.github.com/repos/ripple/rippled/issues/999"},"comments":{"href":"https://api.github.com/repos/ripple/rippled/issues/999/comments"},"review_comments":{"href":"https://api.github.com/repos/ripple/rippled/pulls/999/comments"},"review_comment":{"href":"https://api.github.com/repos/ripple/rippled/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ripple/rippled/pulls/999/commits"},"statuses":{"href":"https://api.github.com/repos/ripple/rippled/statuses/703a6afafe2f8e7be673d03146dd3a01bd15ffc7"}}}}