{"action":"created","comment":{"url":"https://api.github.com/repos/dojo/crypto/pulls/comments/36573204","id":36573204,"diff_hunk":"@@ -0,0 +1,92 @@\n+/**\n+ * Notation:\n+ *   - A \"word\" is a 32-bit interger\n+ */\n+import { ByteBuffer } from 'dojo-core/encoding';\n+\n+/**\n+ * A script hash function\n+ */\n+export interface ScriptHash {\n+\t(data: ByteBuffer): ByteBuffer;\n+\tblockSize: number;\n+}\n+\n+/**\n+ * A general math function\n+ */\n+export interface MathFunction {\n+\t(...inputs: number[]): number\n+}\n+\n+/**\n+ * Add a list of words, with rollover\n+ */\n+export function addWords(...words: number[]): number {\n+\tconst numWords = words.length;\n+\tlet sum = words[0];\n+\tfor (let i = 1; i < numWords; i++) {\n+\t\tconst a = sum;\n+\t\tconst b = words[i];\n+\t\tconst low = (a & 0xFFFF) + (b & 0xFFFF);\n+\t\tconst high = (a >> 16) + (b >> 16) + (low >> 16);\n+\t\tsum = (high << 16) | (low & 0xFFFF);\n+\t}\n+\treturn sum;\n+}\n+\n+/**\n+ * Specify the endian-ness of a integer values\n+ */\n+export enum Endian {\n+\tLittle = 0,\n+\tBig = 1\n+}\n+\n+/**\n+ * Convert an array of bytes to an array of 32-bit words. Words are assumed to be encoded in little-endian format (low\n+ * bytes are at lower indices).\n+ */\n+export function bytesToWords(bytes: ByteBuffer, endian: Endian = Endian.Big): number[] {\n+\tconst numWords = Math.ceil(bytes.length / 4);\n+\tconst words = new Array(numWords);","path":"src/providers/script/base.ts","position":52,"original_position":52,"commit_id":"8c76923115cfeddbc63c0277b4aced7abb8c1212","original_commit_id":"8c76923115cfeddbc63c0277b4aced7abb8c1212","user":{"login":"kfranqueiro","id":398379,"avatar_url":"https://avatars.githubusercontent.com/u/398379?v=3","gravatar_id":"","url":"https://api.github.com/users/kfranqueiro","html_url":"https://github.com/kfranqueiro","followers_url":"https://api.github.com/users/kfranqueiro/followers","following_url":"https://api.github.com/users/kfranqueiro/following{/other_user}","gists_url":"https://api.github.com/users/kfranqueiro/gists{/gist_id}","starred_url":"https://api.github.com/users/kfranqueiro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kfranqueiro/subscriptions","organizations_url":"https://api.github.com/users/kfranqueiro/orgs","repos_url":"https://api.github.com/users/kfranqueiro/repos","events_url":"https://api.github.com/users/kfranqueiro/events{/privacy}","received_events_url":"https://api.github.com/users/kfranqueiro/received_events","type":"User","site_admin":false},"body":"I could go either way on this.  It's not in our style guide, but from what I vaguely recall, the rule, when it exists, is usually specifically to discourage using `new Array()` when the intent is identical to `[ ... ]`, particularly since someone could mistakenly try `new Array(number)` when they mean `[ number ]` but will end up with an array of `number` undefined values.  in this case though, the intent *is* to preallocate.","created_at":"2015-08-08T01:27:52Z","updated_at":"2015-08-08T01:27:52Z","html_url":"https://github.com/dojo/crypto/pull/9#discussion_r36573204","pull_request_url":"https://api.github.com/repos/dojo/crypto/pulls/9","_links":{"self":{"href":"https://api.github.com/repos/dojo/crypto/pulls/comments/36573204"},"html":{"href":"https://github.com/dojo/crypto/pull/9#discussion_r36573204"},"pull_request":{"href":"https://api.github.com/repos/dojo/crypto/pulls/9"}}},"pull_request":{"url":"https://api.github.com/repos/dojo/crypto/pulls/9","id":36538742,"html_url":"https://github.com/dojo/crypto/pull/9","diff_url":"https://github.com/dojo/crypto/pull/9.diff","patch_url":"https://github.com/dojo/crypto/pull/9.patch","issue_url":"https://api.github.com/repos/dojo/crypto/issues/9","number":9,"state":"open","locked":false,"title":"API","user":{"login":"jason0x43","id":1042866,"avatar_url":"https://avatars.githubusercontent.com/u/1042866?v=3","gravatar_id":"","url":"https://api.github.com/users/jason0x43","html_url":"https://github.com/jason0x43","followers_url":"https://api.github.com/users/jason0x43/followers","following_url":"https://api.github.com/users/jason0x43/following{/other_user}","gists_url":"https://api.github.com/users/jason0x43/gists{/gist_id}","starred_url":"https://api.github.com/users/jason0x43/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jason0x43/subscriptions","organizations_url":"https://api.github.com/users/jason0x43/orgs","repos_url":"https://api.github.com/users/jason0x43/repos","events_url":"https://api.github.com/users/jason0x43/events{/privacy}","received_events_url":"https://api.github.com/users/jason0x43/received_events","type":"User","site_admin":false},"body":"This is the base API for crypto, along with the Node-backed implementation.","created_at":"2015-05-29T19:47:06Z","updated_at":"2015-08-08T01:27:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ecb8460a5038c69a9c94fd53ab7cda1201b5eddf","assignee":{"login":"bryanforbes","id":204106,"avatar_url":"https://avatars.githubusercontent.com/u/204106?v=3","gravatar_id":"","url":"https://api.github.com/users/bryanforbes","html_url":"https://github.com/bryanforbes","followers_url":"https://api.github.com/users/bryanforbes/followers","following_url":"https://api.github.com/users/bryanforbes/following{/other_user}","gists_url":"https://api.github.com/users/bryanforbes/gists{/gist_id}","starred_url":"https://api.github.com/users/bryanforbes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bryanforbes/subscriptions","organizations_url":"https://api.github.com/users/bryanforbes/orgs","repos_url":"https://api.github.com/users/bryanforbes/repos","events_url":"https://api.github.com/users/bryanforbes/events{/privacy}","received_events_url":"https://api.github.com/users/bryanforbes/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/dojo/crypto/milestones/1","html_url":"https://github.com/dojo/crypto/milestones/Milestone%201","labels_url":"https://api.github.com/repos/dojo/crypto/milestones/1/labels","id":1138157,"number":1,"title":"Milestone 1","description":"","creator":{"login":"eheasley","id":7253801,"avatar_url":"https://avatars.githubusercontent.com/u/7253801?v=3","gravatar_id":"","url":"https://api.github.com/users/eheasley","html_url":"https://github.com/eheasley","followers_url":"https://api.github.com/users/eheasley/followers","following_url":"https://api.github.com/users/eheasley/following{/other_user}","gists_url":"https://api.github.com/users/eheasley/gists{/gist_id}","starred_url":"https://api.github.com/users/eheasley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eheasley/subscriptions","organizations_url":"https://api.github.com/users/eheasley/orgs","repos_url":"https://api.github.com/users/eheasley/repos","events_url":"https://api.github.com/users/eheasley/events{/privacy}","received_events_url":"https://api.github.com/users/eheasley/received_events","type":"User","site_admin":false},"open_issues":9,"closed_issues":0,"state":"open","created_at":"2015-05-28T14:35:51Z","updated_at":"2015-06-03T15:19:50Z","due_on":"2015-06-27T04:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/dojo/crypto/pulls/9/commits","review_comments_url":"https://api.github.com/repos/dojo/crypto/pulls/9/comments","review_comment_url":"https://api.github.com/repos/dojo/crypto/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dojo/crypto/issues/9/comments","statuses_url":"https://api.github.com/repos/dojo/crypto/statuses/8c76923115cfeddbc63c0277b4aced7abb8c1212","head":{"label":"jason0x43:api","ref":"api","sha":"8c76923115cfeddbc63c0277b4aced7abb8c1212","user":{"login":"jason0x43","id":1042866,"avatar_url":"https://avatars.githubusercontent.com/u/1042866?v=3","gravatar_id":"","url":"https://api.github.com/users/jason0x43","html_url":"https://github.com/jason0x43","followers_url":"https://api.github.com/users/jason0x43/followers","following_url":"https://api.github.com/users/jason0x43/following{/other_user}","gists_url":"https://api.github.com/users/jason0x43/gists{/gist_id}","starred_url":"https://api.github.com/users/jason0x43/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jason0x43/subscriptions","organizations_url":"https://api.github.com/users/jason0x43/orgs","repos_url":"https://api.github.com/users/jason0x43/repos","events_url":"https://api.github.com/users/jason0x43/events{/privacy}","received_events_url":"https://api.github.com/users/jason0x43/received_events","type":"User","site_admin":false},"repo":{"id":36386195,"name":"crypto","full_name":"jason0x43/crypto","owner":{"login":"jason0x43","id":1042866,"avatar_url":"https://avatars.githubusercontent.com/u/1042866?v=3","gravatar_id":"","url":"https://api.github.com/users/jason0x43","html_url":"https://github.com/jason0x43","followers_url":"https://api.github.com/users/jason0x43/followers","following_url":"https://api.github.com/users/jason0x43/following{/other_user}","gists_url":"https://api.github.com/users/jason0x43/gists{/gist_id}","starred_url":"https://api.github.com/users/jason0x43/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jason0x43/subscriptions","organizations_url":"https://api.github.com/users/jason0x43/orgs","repos_url":"https://api.github.com/users/jason0x43/repos","events_url":"https://api.github.com/users/jason0x43/events{/privacy}","received_events_url":"https://api.github.com/users/jason0x43/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jason0x43/crypto","description":"Dojo 2 Crypto","fork":true,"url":"https://api.github.com/repos/jason0x43/crypto","forks_url":"https://api.github.com/repos/jason0x43/crypto/forks","keys_url":"https://api.github.com/repos/jason0x43/crypto/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jason0x43/crypto/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jason0x43/crypto/teams","hooks_url":"https://api.github.com/repos/jason0x43/crypto/hooks","issue_events_url":"https://api.github.com/repos/jason0x43/crypto/issues/events{/number}","events_url":"https://api.github.com/repos/jason0x43/crypto/events","assignees_url":"https://api.github.com/repos/jason0x43/crypto/assignees{/user}","branches_url":"https://api.github.com/repos/jason0x43/crypto/branches{/branch}","tags_url":"https://api.github.com/repos/jason0x43/crypto/tags","blobs_url":"https://api.github.com/repos/jason0x43/crypto/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jason0x43/crypto/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jason0x43/crypto/git/refs{/sha}","trees_url":"https://api.github.com/repos/jason0x43/crypto/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jason0x43/crypto/statuses/{sha}","languages_url":"https://api.github.com/repos/jason0x43/crypto/languages","stargazers_url":"https://api.github.com/repos/jason0x43/crypto/stargazers","contributors_url":"https://api.github.com/repos/jason0x43/crypto/contributors","subscribers_url":"https://api.github.com/repos/jason0x43/crypto/subscribers","subscription_url":"https://api.github.com/repos/jason0x43/crypto/subscription","commits_url":"https://api.github.com/repos/jason0x43/crypto/commits{/sha}","git_commits_url":"https://api.github.com/repos/jason0x43/crypto/git/commits{/sha}","comments_url":"https://api.github.com/repos/jason0x43/crypto/comments{/number}","issue_comment_url":"https://api.github.com/repos/jason0x43/crypto/issues/comments{/number}","contents_url":"https://api.github.com/repos/jason0x43/crypto/contents/{+path}","compare_url":"https://api.github.com/repos/jason0x43/crypto/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jason0x43/crypto/merges","archive_url":"https://api.github.com/repos/jason0x43/crypto/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jason0x43/crypto/downloads","issues_url":"https://api.github.com/repos/jason0x43/crypto/issues{/number}","pulls_url":"https://api.github.com/repos/jason0x43/crypto/pulls{/number}","milestones_url":"https://api.github.com/repos/jason0x43/crypto/milestones{/number}","notifications_url":"https://api.github.com/repos/jason0x43/crypto/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jason0x43/crypto/labels{/name}","releases_url":"https://api.github.com/repos/jason0x43/crypto/releases{/id}","created_at":"2015-05-27T18:10:47Z","updated_at":"2015-05-27T18:10:48Z","pushed_at":"2015-07-24T20:42:34Z","git_url":"git://github.com/jason0x43/crypto.git","ssh_url":"git@github.com:jason0x43/crypto.git","clone_url":"https://github.com/jason0x43/crypto.git","svn_url":"https://github.com/jason0x43/crypto","homepage":null,"size":251,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dojo:master","ref":"master","sha":"fb9c64be4d876f0c456b83fe14f6da203a3d94d7","user":{"login":"dojo","id":86896,"avatar_url":"https://avatars.githubusercontent.com/u/86896?v=3","gravatar_id":"","url":"https://api.github.com/users/dojo","html_url":"https://github.com/dojo","followers_url":"https://api.github.com/users/dojo/followers","following_url":"https://api.github.com/users/dojo/following{/other_user}","gists_url":"https://api.github.com/users/dojo/gists{/gist_id}","starred_url":"https://api.github.com/users/dojo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dojo/subscriptions","organizations_url":"https://api.github.com/users/dojo/orgs","repos_url":"https://api.github.com/users/dojo/repos","events_url":"https://api.github.com/users/dojo/events{/privacy}","received_events_url":"https://api.github.com/users/dojo/received_events","type":"Organization","site_admin":false},"repo":{"id":36316791,"name":"crypto","full_name":"dojo/crypto","owner":{"login":"dojo","id":86896,"avatar_url":"https://avatars.githubusercontent.com/u/86896?v=3","gravatar_id":"","url":"https://api.github.com/users/dojo","html_url":"https://github.com/dojo","followers_url":"https://api.github.com/users/dojo/followers","following_url":"https://api.github.com/users/dojo/following{/other_user}","gists_url":"https://api.github.com/users/dojo/gists{/gist_id}","starred_url":"https://api.github.com/users/dojo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dojo/subscriptions","organizations_url":"https://api.github.com/users/dojo/orgs","repos_url":"https://api.github.com/users/dojo/repos","events_url":"https://api.github.com/users/dojo/events{/privacy}","received_events_url":"https://api.github.com/users/dojo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dojo/crypto","description":"Dojo 2 Crypto","fork":false,"url":"https://api.github.com/repos/dojo/crypto","forks_url":"https://api.github.com/repos/dojo/crypto/forks","keys_url":"https://api.github.com/repos/dojo/crypto/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dojo/crypto/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dojo/crypto/teams","hooks_url":"https://api.github.com/repos/dojo/crypto/hooks","issue_events_url":"https://api.github.com/repos/dojo/crypto/issues/events{/number}","events_url":"https://api.github.com/repos/dojo/crypto/events","assignees_url":"https://api.github.com/repos/dojo/crypto/assignees{/user}","branches_url":"https://api.github.com/repos/dojo/crypto/branches{/branch}","tags_url":"https://api.github.com/repos/dojo/crypto/tags","blobs_url":"https://api.github.com/repos/dojo/crypto/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dojo/crypto/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dojo/crypto/git/refs{/sha}","trees_url":"https://api.github.com/repos/dojo/crypto/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dojo/crypto/statuses/{sha}","languages_url":"https://api.github.com/repos/dojo/crypto/languages","stargazers_url":"https://api.github.com/repos/dojo/crypto/stargazers","contributors_url":"https://api.github.com/repos/dojo/crypto/contributors","subscribers_url":"https://api.github.com/repos/dojo/crypto/subscribers","subscription_url":"https://api.github.com/repos/dojo/crypto/subscription","commits_url":"https://api.github.com/repos/dojo/crypto/commits{/sha}","git_commits_url":"https://api.github.com/repos/dojo/crypto/git/commits{/sha}","comments_url":"https://api.github.com/repos/dojo/crypto/comments{/number}","issue_comment_url":"https://api.github.com/repos/dojo/crypto/issues/comments{/number}","contents_url":"https://api.github.com/repos/dojo/crypto/contents/{+path}","compare_url":"https://api.github.com/repos/dojo/crypto/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dojo/crypto/merges","archive_url":"https://api.github.com/repos/dojo/crypto/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dojo/crypto/downloads","issues_url":"https://api.github.com/repos/dojo/crypto/issues{/number}","pulls_url":"https://api.github.com/repos/dojo/crypto/pulls{/number}","milestones_url":"https://api.github.com/repos/dojo/crypto/milestones{/number}","notifications_url":"https://api.github.com/repos/dojo/crypto/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dojo/crypto/labels{/name}","releases_url":"https://api.github.com/repos/dojo/crypto/releases{/id}","created_at":"2015-05-26T18:50:38Z","updated_at":"2015-06-08T12:33:48Z","pushed_at":"2015-07-24T20:42:34Z","git_url":"git://github.com/dojo/crypto.git","ssh_url":"git@github.com:dojo/crypto.git","clone_url":"https://github.com/dojo/crypto.git","svn_url":"https://github.com/dojo/crypto","homepage":null,"size":300,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":9,"forks":6,"open_issues":9,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dojo/crypto/pulls/9"},"html":{"href":"https://github.com/dojo/crypto/pull/9"},"issue":{"href":"https://api.github.com/repos/dojo/crypto/issues/9"},"comments":{"href":"https://api.github.com/repos/dojo/crypto/issues/9/comments"},"review_comments":{"href":"https://api.github.com/repos/dojo/crypto/pulls/9/comments"},"review_comment":{"href":"https://api.github.com/repos/dojo/crypto/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dojo/crypto/pulls/9/commits"},"statuses":{"href":"https://api.github.com/repos/dojo/crypto/statuses/8c76923115cfeddbc63c0277b4aced7abb8c1212"}}}}