{"id":18375707,"url":"https://github.com/factomproject/python-identitykeys","last_synced_at":"2025-04-11T04:39:48.882Z","repository":{"id":57457104,"uuid":"173374213","full_name":"FactomProject/python-identitykeys","owner":"FactomProject","description":"Tools for using Factom identity keys in Python","archived":false,"fork":false,"pushed_at":"2019-03-19T15:39:21.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-11T04:39:45.739Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FactomProject.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-01T22:05:34.000Z","updated_at":"2019-03-19T17:13:31.000Z","dependencies_parsed_at":"2022-09-15T14:20:43.808Z","dependency_job_id":null,"html_url":"https://github.com/FactomProject/python-identitykeys","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FactomProject%2Fpython-identitykeys","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FactomProject%2Fpython-identitykeys/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FactomProject%2Fpython-identitykeys/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FactomProject%2Fpython-identitykeys/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FactomProject","download_url":"https://codeload.github.com/FactomProject/python-identitykeys/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248345272,"owners_count":21088241,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T00:19:56.249Z","updated_at":"2025-04-11T04:39:48.860Z","avatar_url":"https://github.com/FactomProject.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# python-identitykeys\n\nA small module of tools to generate and use key pairs for Factom Identities.\n\n## Usage\nTo install this module from pypi, run the following:\n```$ pip3 install python-identitykeys```\n\nGenerating a new random key pair:\n```\n\u003e\u003e\u003e import identitykeys\n\u003e\u003e\u003e private_key, public_key = identitykeys.generate_key_pair()\n\u003e\u003e\u003e print(private_key.to_string(), public_key.to_string())\nidsec2ioPQqJvJzzwqskEW67yrWd2GwQMs1oCuLHsLHxejmBbEFpEY8 idpub23LV4aM3K3A3G1yyRebacQsMUGeBygi83jZiKwmbWM3DMP1cmr\n```\n\nSigning a message and then verifying the signature:\n```\nmessage = b'hello'\n\u003e\u003e\u003e signature = private_key.sign(message)\n\u003e\u003e\u003e if public_key.verify(signature, message):\n...     print(\"Signature verified successfully\")\n... \nSignature verified successfully\n```\n\n## Format of an Identity Key Pair\n*Note: the following text is taken from the [Application Identity Specification](https://github.com/FactomProject/FactomDocs/blob/FD-849_PublishNewIdentitySpec/ApplicationIdentity.md)*\n\nFor Factom Application Identities, ed25519 keys are used to sign and verify messages. Rather than simply using raw 32 byte arrays for keys, the following encoding scheme is used: \n\nPseudo-code for constructing a private key string:\n```\nprefix_bytes = [0x03, 0x45, 0xf3, 0xd0, 0xd6]              // gives an \"idsec\" prefix once in base58 \nkey_bytes = [32 bytes of raw private key]                  // the actual ed25519 private key seed\nchecksum = sha256( sha256(prefix_bytes + key_bytes) )[:4]  // 4 byte integrity check on the previous 37 bytes\n\nidsec_key_string = base58( prefix_bytes + key_bytes + checksum )\n```\n\nPseudo-code for constructing a public key string:\n```\nprefix_bytes = [0x03, 0x45, 0xef, 0x9d, 0xe0]              // gives an \"idpub\" prefix once in base58 \nkey_bytes = [32 bytes of raw public key]                   // the actual ed25519 public key\nchecksum = sha256( sha256(prefix_bytes + key_bytes) )[:4]  // 4 byte integrity check on the previous 37 bytes\n\nidpub_key_string = base58( prefix_bytes + key_bytes + checksum )\n```\n\nFor the sake of human-readability, all characters must be in Bitcoin's base58 character set, the private key will always begin with \"idsec\", and the public key will always begin with \"idpub\". Additionally, the checksum at the end serves to signal that a user has incorrectly typed/copied their key.\n\nExample key pair for the private key of all zeros:\n- `idsec19zBQP2RjHg8Cb8xH2XHzhsB1a6ZkB23cbS21NSyH9pDbzhnN6 idpub2Cy86teq57qaxHyqLA8jHwe5JqqCvL1HGH4cKRcwSTbymTTh5n`\n\nExample key pair for the private key of all ones:\n- `idsec1ARpkDoUCT9vdZuU3y2QafjAJtCsQYbE2d3JDER8Nm56CWk9ix idpub2op91ghJbRLrukBArtxeLJotFgXhc6E21syu3Ef8V7rCcRY5cc`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffactomproject%2Fpython-identitykeys","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffactomproject%2Fpython-identitykeys","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffactomproject%2Fpython-identitykeys/lists"}